SA-MP Forums Archive
Need help with faster loading. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Need help with faster loading. (/showthread.php?tid=583710)



Need help with faster loading. - danielpalade - 30.07.2015

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?


Re: Need help with faster loading. - Abagail - 30.07.2015

Show the query you use for selecting player data.


Re: Need help with faster loading. - danielpalade - 30.07.2015

Quote:
Originally Posted by Abagail
Посмотреть сообщение
Show the query you use for selecting player data.
Код:
mysql_tquery(Handle, szQuery, "LoadPlayerData", "d", playerid);
here yo go.


Re: Need help with faster loading. - danielpalade - 30.07.2015

Anyone?


Re: Need help with faster loading. - Jacket - 30.07.2015

Show the szQuery.


Re: Need help with faster loading. - danielpalade - 30.07.2015

Quote:
Originally Posted by Jacket
Посмотреть сообщение
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);



Re: Need help with faster loading. - Abagail - 30.07.2015

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

pawn Код:
`ColumnName`, `ColumnName`, `ColumnName`, `ColumnName`



Re: Need help with faster loading. - danielpalade - 30.07.2015

Quote:
Originally Posted by Abagail
Посмотреть сообщение
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

pawn Код:
`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?