PDA

View Full Version : Need help with faster loading.


danielpalade
30/07/2015, 01:54 PM
My current gamemode is mysql based, so whenever someone logins all the data needs to be transported from the DB to the server. Therefor I'm using the following thing.

pInfo[playerid][AdminLevel] = cache_get_field_content_int(0, "AdminLevel", Handle);
pInfo[playerid][HelperLevel] = cache_get_field_content_int(0, "HelperLevel", Handle);
pInfo[playerid][VIPLevel] = cache_get_field_content_int(0, "VIPLevel", Handle);
pInfo[playerid][Money] = cache_get_field_content_int(0, "Money", Handle );//Extrag din baza de date banii. Banii sunt o variabila de tip integer, se extrag cu aceasta functie.
pInfo[playerid][Bank] = cache_get_field_content_int(0, "Bank", Handle);
pInfo[playerid][Pincode] = cache_get_field_content_int(0, "Pincode", Handle);
pInfo[playerid][Score] = cache_get_field_content_int(0, "Score", Handle);
pInfo[playerid][Skin] = cache_get_field_content_int(0, "Skin", Handle);
pInfo[playerid][Gender] = cache_get_field_content_int(0, "Gender", Handle);
pInfo[playerid][Age] = cache_get_field_content_int(0, "Age", Handle);
cache_get_field_content( 0, "Email", pInfo[playerid][Email], Handle, 256 );
cache_get_field_content( 0, "IP", pInfo [playerid] [IP], Handle, 20 );//Extrag din baza de date ip-ul. IP-ul este un string iar string-urile se extrag cu aceasta functie.
pInfo[playerid][DrivingLic] = cache_get_field_content_int(0, "DrivingLic", Handle);
pInfo[playerid][MotorLic] = cache_get_field_content_int(0, "MotorLic", Handle);
pInfo[playerid][GunLic] = cache_get_field_content_int(0, "GunLic", Handle);
pInfo[playerid][BoatLic] = cache_get_field_content_int(0, "BoatLic", Handle);
pInfo[playerid][FishLic] = cache_get_field_content_int(0, "FishLic", Handle);
pInfo[playerid][MatsLic] = cache_get_field_content_int(0, "MatsLic", Handle);
pInfo[playerid][Banned] = cache_get_field_content_int(0, "Banned", Handle);
cache_get_field_content( 0, "Banner", pInfo[playerid][Banner], Handle, 256 );
cache_get_field_content( 0, "Reason", pInfo[playerid][Reason], Handle, 256 );
pInfo[playerid][pMember] = cache_get_field_content_int(0, "pMember", Handle);
pInfo[playerid][pLeader] = cache_get_field_content_int(0, "pLeader", Handle);
pInfo[playerid][pRank] = cache_get_field_content_int(0, "pRank", Handle);
pInfo[playerid][Kicks] = cache_get_field_content_int(0, "Kicks", Handle);
pInfo[playerid][Bans] = cache_get_field_content_int(0, "Bans", Handle);
pInfo[playerid][WantedLevel] = cache_get_field_content_int(0, "WantedLevel", Handle);
pInfo[playerid][Drugs] = cache_get_field_content_int(0, "Drugs", Handle);
pInfo[playerid][Materials] = cache_get_field_content_int(0, "Materials", Handle);
pInfo[playerid][Job] = cache_get_field_content_int(0, "Job", Handle);
pInfo[playerid][SkillTruck] = cache_get_field_content_int(0, "SkillTruck", Handle);

What can I do to reduce the loading time?

Abagail
30/07/2015, 02:18 PM
Show the query you use for selecting player data.

danielpalade
30/07/2015, 02:36 PM
Show the query you use for selecting player data.

mysql_tquery(Handle, szQuery, "LoadPlayerData", "d", playerid);
here yo go.

danielpalade
30/07/2015, 09:24 PM
Anyone?

Jacket
30/07/2015, 09:25 PM
Show the szQuery.

danielpalade
30/07/2015, 10:51 PM
Show the szQuery.
I assume you mean this one.

new Cache: r;
szQuery[0] = EOS;
mysql_format(Handle, szQuery, 128, "SELECT * FROM `accounts` WHERE `Username` = '%e' LIMIT 1;", GetPName(playerid));
r = mysql_query(Handle, szQuery);

Abagail
30/07/2015, 10:59 PM
Do you load all columns when the player initially loads? If you don't - you can only select the columns you need by replacing "*" with


`ColumnName`, `ColumnName`, `ColumnName`, `ColumnName`

danielpalade
30/07/2015, 11:36 PM
Do you load all columns when the player initially loads? If you don't - you can only select the columns you need by replacing "*" with


`ColumnName`, `ColumnName`, `ColumnName`, `ColumnName`


Yea, I load all columns. But its slow because of this part.

pInfo[playerid][AdminLevel] = cache_get_field_content_int(0, "AdminLevel", Handle);
pInfo[playerid][HelperLevel] = cache_get_field_content_int(0, "HelperLevel", Handle);
pInfo[playerid][VIPLevel] = cache_get_field_content_int(0, "VIPLevel", Handle);
pInfo[playerid][Money] = cache_get_field_content_int(0, "Money", Handle );//Extrag din baza de date banii. Banii sunt o variabila de tip integer, se extrag cu aceasta functie.
pInfo[playerid][Bank] = cache_get_field_content_int(0, "Bank", Handle);
pInfo[playerid][Pincode] = cache_get_field_content_int(0, "Pincode", Handle);
pInfo[playerid][Score] = cache_get_field_content_int(0, "Score", Handle);
pInfo[playerid][Skin] = cache_get_field_content_int(0, "Skin", Handle);
pInfo[playerid][Gender] = cache_get_field_content_int(0, "Gender", Handle);
pInfo[playerid][Age] = cache_get_field_content_int(0, "Age", Handle);
cache_get_field_content( 0, "Email", pInfo[playerid][Email], Handle, 256 );
cache_get_field_content( 0, "IP", pInfo [playerid] [IP], Handle, 20 );//Extrag din baza de date ip-ul. IP-ul este un string iar string-urile se extrag cu aceasta functie.
pInfo[playerid][DrivingLic] = cache_get_field_content_int(0, "DrivingLic", Handle);
pInfo[playerid][MotorLic] = cache_get_field_content_int(0, "MotorLic", Handle);
pInfo[playerid][GunLic] = cache_get_field_content_int(0, "GunLic", Handle);
pInfo[playerid][BoatLic] = cache_get_field_content_int(0, "BoatLic", Handle);
pInfo[playerid][FishLic] = cache_get_field_content_int(0, "FishLic", Handle);
pInfo[playerid][MatsLic] = cache_get_field_content_int(0, "MatsLic", Handle);
pInfo[playerid][Banned] = cache_get_field_content_int(0, "Banned", Handle);
cache_get_field_content( 0, "Banner", pInfo[playerid][Banner], Handle, 256 );
cache_get_field_content( 0, "Reason", pInfo[playerid][Reason], Handle, 256 );
pInfo[playerid][pMember] = cache_get_field_content_int(0, "pMember", Handle);
pInfo[playerid][pLeader] = cache_get_field_content_int(0, "pLeader", Handle);
pInfo[playerid][pRank] = cache_get_field_content_int(0, "pRank", Handle);
pInfo[playerid][Kicks] = cache_get_field_content_int(0, "Kicks", Handle);
pInfo[playerid][Bans] = cache_get_field_content_int(0, "Bans", Handle);
pInfo[playerid][WantedLevel] = cache_get_field_content_int(0, "WantedLevel", Handle);
pInfo[playerid][Drugs] = cache_get_field_content_int(0, "Drugs", Handle);
pInfo[playerid][Materials] = cache_get_field_content_int(0, "Materials", Handle);
pInfo[playerid][Job] = cache_get_field_content_int(0, "Job", Handle);
pInfo[playerid][SkillTruck] = cache_get_field_content_int(0, "SkillTruck", Handle);

Is there a way to make this way simpler and faster?