Fixed #305 already 
I think before we work on these tickets we need to address the amount of queries and unoptimized functions contained within the user/gang handler.
* CheckUserExists - Function that gets called at least 3 times when a player connects, and once in the gang handler. This performs a query to clarify if a player is registered. This should only perform the query once and store the result in a variable. = DONE
* Profile IDs in the gang handler - This performs a query to determine a players profile ID and stores it to a variable when they connect in the gang handler. This already happens in the user handler and is stored to the PlayerInfo[playerid][playerProfile] variable, which we can use.
* Gang handler initialization. I'm going to quote the code for this:
That's performing 102 queries at once. I'm very surprised it doesn't bottleneck the server.
* CGang:
layerConnect - This function is called from OnPlayerConnect and checks if a player is in a gang and updates all relevant information for the player. Surely this should be called when the player logs in!
- DONE
* mysql_free_result is called prior to every mysql_store_result function call. No idea why. - DONE
* CGang__GetNumberOfGangs() - This performs a query to get the result. Surely this can be stored in a variable.
* CGang__IsPlayerGangLeader(playerid) see above
* CGang__GetGangMoney(gangid) - see above

I think before we work on these tickets we need to address the amount of queries and unoptimized functions contained within the user/gang handler.
* CheckUserExists - Function that gets called at least 3 times when a player connects, and once in the gang handler. This performs a query to clarify if a player is registered. This should only perform the query once and store the result in a variable. = DONE
* Profile IDs in the gang handler - This performs a query to determine a players profile ID and stores it to a variable when they connect in the gang handler. This already happens in the user handler and is stored to the PlayerInfo[playerid][playerProfile] variable, which we can use.
* Gang handler initialization. I'm going to quote the code for this:
Code:
#define CUR_TURFS 102
gangInitialize()
{
for(new i; i < CUR_TURFS; i++)
{
CGang::T_WaitTimerOff(i);
format(query, sizeof(query), "SELECT gang_id FROM turfs WHERE turf_id = %d", i);
mysql_query(query);
mysql_free_result();
mysql_store_result();
mysql_fetch_row_format(result);
ActiveTurf[i][Owner] = strval(result);
...
}* CGang:
layerConnect - This function is called from OnPlayerConnect and checks if a player is in a gang and updates all relevant information for the player. Surely this should be called when the player logs in!- DONE
* mysql_free_result is called prior to every mysql_store_result function call. No idea why. - DONE
* CGang__GetNumberOfGangs() - This performs a query to get the result. Surely this can be stored in a variable.
* CGang__IsPlayerGangLeader(playerid) see above
* CGang__GetGangMoney(gangid) - see above