SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 12/02/2016, 04:31 PM   #1
Terrorizt
Big Clucker
 
Terrorizt's Avatar
 
Join Date: Jun 2015
Posts: 110
Reputation: 6
Default SaveAccount taking too long time

Hi everyone, I had a problem which is whenever the player dies / changes his name or anything with SaveAccount in it. It takes like 5 - 7 seconds to be done and i hate this. Is there anyway to make it faster? here is the SaveAccount code:
Code:
stock File__SaveAccount(playerid)
{
	if(PLAYERLIST_authed[playerid] == 0) return 1;
	new pname[24];
    GetPlayerName(playerid, pname, 24);
	if(PLAYERLIST_authed[playerid])
	{
		new query[750];
		format(query, sizeof(query), "UPDATE PlayerInfo SET bank=%d WHERE user='%s'", PlayerInfo[playerid][bank], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET curmoney=%d WHERE user='%s'", PlayerTemp[playerid][sm], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET playerlvl=%d WHERE user='%s'", PlayerInfo[playerid][playerlvl], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET rpoints=%d WHERE user='%s'", PlayerInfo[playerid][rpoints], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET playertime=%d WHERE user='%s'", PlayerInfo[playerid][playertime], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET jail=%d WHERE user='%s'", PlayerInfo[playerid][jail], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET jailreason='%s' WHERE user='%s'", PlayerInfo[playerid][jailreason], pname);
		mysql_query(query);
		format(query, sizeof(query), "UPDATE PlayerInfo SET jailtime=%d WHERE user='%s'", PlayerInfo[playerid][jailtime], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET banned=%d WHERE user='%s'", PlayerInfo[playerid][banned], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET banreason='%s' WHERE user='%s'", PlayerInfo[playerid][banreason], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET whobannedme='%s' WHERE user='%s'", PlayerInfo[playerid][whobannedme], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET whenigotbanned='%s' WHERE user='%s'", PlayerInfo[playerid][whenigotbanned], pname);
		mysql_query(query);
  		format(query, sizeof(query), "UPDATE PlayerInfo SET forumname='%s' WHERE user='%s'", PlayerInfo[playerid][forumname], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET Skin=%d WHERE user='%s'", PlayerInfo[playerid][Skin], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET ranklvl=%d WHERE user='%s'", PlayerInfo[playerid][ranklvl], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET rentprice=%d WHERE user='%s'", PlayerInfo[playerid][rentprice], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET driverlic=%d WHERE user='%s'", PlayerInfo[playerid][driverlic], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET flylic=%d WHERE user='%s'", PlayerInfo[playerid][flylic], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET boatlic=%d WHERE user='%s'", PlayerInfo[playerid][boatlic], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET weaplic=%d WHERE user='%s'", PlayerInfo[playerid][weaplic], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET jobtime=%d WHERE user='%s'", PlayerInfo[playerid][jobtime], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET jobskill=%d WHERE user='%s'", PlayerInfo[playerid][jobskill], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET totalpayt=%d WHERE user='%s'", PlayerInfo[playerid][totalpayt], pname);
		mysql_query(query);
  		format(query, sizeof(query), "UPDATE PlayerInfo SET pbkills=%d WHERE user='%s'", PlayerInfo[playerid][pbkills], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET pbdeaths=%d WHERE user='%s'", PlayerInfo[playerid][pbdeaths], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET housenum=%d WHERE user='%s'", PlayerInfo[playerid][housenum], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET loan=%d WHERE user='%s'", PlayerInfo[playerid][loan], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET guns=%d WHERE user='%s'", PlayerInfo[playerid][guns], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET sguns=%d WHERE user='%s'", PlayerInfo[playerid][sguns], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET sdrugs=%d WHERE user='%s'", PlayerInfo[playerid][sdrugs], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET power=%d WHERE user='%s'", PlayerInfo[playerid][power], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET female=%d WHERE user='%s'", PlayerInfo[playerid][female], pname);
		mysql_query(query);
  		format(query, sizeof(query), "UPDATE PlayerInfo SET ethnic=%d WHERE user='%s'", PlayerInfo[playerid][ethnic], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET bail=%d WHERE user='%s'", PlayerInfo[playerid][bail], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET premium=%d WHERE user='%s'", PlayerInfo[playerid][premium], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET gotphone=%d WHERE user='%s'", PlayerInfo[playerid][gotphone], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET phonenumber=%d WHERE user='%s'", PlayerInfo[playerid][phonenumber], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET phonebook=%d WHERE user='%s'", PlayerInfo[playerid][phonebook], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET laptop=%d WHERE user='%s'", PlayerInfo[playerid][laptop], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET age=%d WHERE user='%s'", PlayerInfo[playerid][age], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET premiumexpire=%d WHERE user='%s'", PlayerInfo[playerid][premiumexpire], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET playerteam=%d WHERE user='%s'", PlayerInfo[playerid][playerteam], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET radio=%d WHERE user='%s'", PlayerInfo[playerid][radio], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET freq1=%d WHERE user='%s'", PlayerInfo[playerid][freq1], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET freq2=%d WHERE user='%s'", PlayerInfo[playerid][freq2], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET freq3=%d WHERE user='%s'", PlayerInfo[playerid][freq3], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET tutorial=%d WHERE user='%s'", PlayerInfo[playerid][tutorial], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET tbanned=%d WHERE user='%s'", PlayerInfo[playerid][tbanned], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET city='%s' WHERE user='%s'", PlayerInfo[playerid][city], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET PTeamName='%s' WHERE user='%s'", PlayerInfo[playerid][PTeamName], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET job='%s' WHERE user='%s'", PlayerInfo[playerid][job], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET totalruns=%d WHERE user='%s'", PlayerInfo[playerid][totalruns], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET fpay=%d WHERE user='%s'", PlayerInfo[playerid][fpay], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET warns=%d WHERE user='%s'", PlayerInfo[playerid][warns], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET helper=%d WHERE user='%s'", PlayerInfo[playerid][helper], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET curfreq=%d WHERE user='%s'", PlayerInfo[playerid][curfreq], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET rankname='%s' WHERE user='%s'", PlayerInfo[playerid][rankname], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET phonechanges=%d WHERE user='%s'", PlayerInfo[playerid][phonechanges], pname);
		mysql_query(query);
		format(query, sizeof(query), "UPDATE PlayerInfo SET namechanges=%d WHERE user='%s'", PlayerInfo[playerid][namechanges], pname);
		mysql_query(query);
 		format(query, sizeof(query), "UPDATE PlayerInfo SET lastonline='%s' WHERE user='%s'", TimeDate(), pname);
		mysql_query(query);
		format(query, sizeof(query), "UPDATE PlayerInfo SET iPod=%d WHERE user='%s'", PlayerInfo[playerid][iPod], pname);
		mysql_query(query);
   		format(query, sizeof(query), "UPDATE PlayerInfo SET finvite='%d' WHERE user='%s'", PlayerInfo[playerid][finvite], pname);
		mysql_query(query);
  		format(query, sizeof(query), "UPDATE PlayerInfo SET fradio='%d' WHERE user='%s'", PlayerInfo[playerid][fradio], pname);
		mysql_query(query);
  		format(query, sizeof(query), "UPDATE PlayerInfo SET fstock='%d' WHERE user='%s'", PlayerInfo[playerid][fstock], pname);
		mysql_query(query);
  		format(query, sizeof(query), "UPDATE PlayerInfo SET fwarehouse='%d' WHERE user='%s'", PlayerInfo[playerid][fwarehouse], pname);
		mysql_query(query);
		format(query, sizeof(query), "UPDATE PlayerInfo SET fweplic='%d' WHERE user='%s'", PlayerInfo[playerid][fweplic], pname);
		mysql_query(query);
   		format(query, sizeof(query), "UPDATE PlayerInfo SET fbarrier='%d' WHERE user='%s'", PlayerInfo[playerid][fwarehouse], pname);
		mysql_query(query);
  		format(query, sizeof(query), "UPDATE PlayerInfo SET tracker='%d' WHERE user='%s'", PlayerInfo[playerid][tracker], pname);
		mysql_query(query);
        format(query, sizeof(query), "UPDATE PlayerInfo SET fbk='%d' WHERE user='%s'", PlayerInfo[playerid][fbk], pname);
		mysql_query(query);
   		format(query, sizeof(query), "UPDATE PlayerInfo SET bslot='%d' WHERE user='%s'", PlayerInfo[playerid][bslot], pname);
		mysql_query(query);
   		format(query, sizeof(query), "UPDATE PlayerInfo SET vslot='%d' WHERE user='%s'", PlayerInfo[playerid][vslot], pname);
		mysql_query(query);
   		format(query, sizeof(query), "UPDATE PlayerInfo SET hslot='%d' WHERE user='%s'", PlayerInfo[playerid][hslot], pname);
		mysql_query(query);
		format(query, sizeof(query), "UPDATE PlayerInfo SET dealer=%d WHERE user='%s'", PlayerInfo[playerid][dealer], pname);
		mysql_query(query);
  		format(query, sizeof(query), "UPDATE PlayerInfo SET accent='%s' WHERE user='%s'", PlayerInfo[playerid][accent], pname);
		mysql_query(query);
   		format(query, sizeof(query), "UPDATE PlayerInfo SET togspawn='%d' WHERE user='%s'", PlayerTemp[playerid][togspawn], pname);
		mysql_query(query);
		format(query, sizeof(query), "UPDATE PlayerInfo SET spawnX='%f' WHERE user='%s'", PlayerInfo[playerid][spawnX], pname);
		mysql_query(query);
		format(query, sizeof(query), "UPDATE PlayerInfo SET spawnY='%f' WHERE user='%s'", PlayerInfo[playerid][spawnY], pname);
		mysql_query(query);
		format(query, sizeof(query), "UPDATE PlayerInfo SET spawnZ='%f' WHERE user='%s'", PlayerInfo[playerid][spawnZ], pname);
		mysql_query(query);
		format(query, sizeof(query), "UPDATE PlayerInfo SET spawnINT='%d' WHERE user='%s'", PlayerInfo[playerid][spawnINT], pname);
		mysql_query(query);
		format(query, sizeof(query), "UPDATE PlayerInfo SET spawnVW='%d' WHERE user='%s'", PlayerInfo[playerid][spawnVW], pname);
		mysql_query(query);
		
		new iString[ 50 ], tmp[ 10 ];
	    for(new c = 0; c < sizeof(drugtypes); c++)
		{
		    format(tmp,sizeof(tmp),"%d,", PlayerInfo[playerid][hasdrugs][c]);
		    strcat(iString,tmp);
		}
		strdel(iString,strlen(iString)-1, strlen(iString));
		format(query, sizeof(query), "UPDATE `PlayerInfo` SET `hasdrugs` = '%s' WHERE `user` = '%s'", iString, pname);
		mysql_query(query);
	}
    return 1;
}
Terrorizt is offline   Reply With Quote
Old 12/02/2016, 04:45 PM   #2
Morpheine
Big Clucker
 
Morpheine's Avatar
 
Join Date: Feb 2015
Location: Romania.
Posts: 114
Reputation: 4
Default Re: SaveAccount taking too long time

All this query are used? If aren't used remove them, try to update your mysql to r39-4.
Morpheine is offline   Reply With Quote
Old 12/02/2016, 04:53 PM   #3
SecretBoss
Gangsta
 
SecretBoss's Avatar
 
Join Date: Dec 2014
Location: Greece
Posts: 808
Reputation: 103
Default Re: SaveAccount taking too long time

What The Hell is that, you make a query to save one variable while you can save all of them with just one query

Here is a correct usage (Not made by me)

Code:
SaveData(playerid)
{
	new query[2500];
	format(query, sizeof(query), "UPDATE `accounts` SET");
	format(query, sizeof(query), "%s `score` = '%d',", query, Data[playerid][Score]);
	format(query, sizeof(query), "%s `kills` = '%d',", query, Data[playerid][Kills]);
	format(query, sizeof(query), "%s `deaths` = '%d',", query, Data[playerid][Deaths]);
	format(query, sizeof(query), "%s `money` = '%d',", query, Data[playerid][Money]);

	mysql_format(connection, query, sizeof(query), "%s", query);
	mysql_query(connection, query, false);
	return 1;
}
__________________
SecretBoss is offline   Reply With Quote
Old 12/02/2016, 05:08 PM   #4
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,089
Reputation: 2655
Default Re: SaveAccount taking too long time

That's what you get for treating SQL like a simple filesystem.
  • Using a query for each variable
  • Not using threaded queries
  • Using the name as the key instead of the id
  • Probably not having an index on the name either = full table scan = much slower queries
  • Saving multiple values in one columns (drugs) = seriously not done => different table
  • Saving too many variables at once => update as needed!
  • Having too many columns in one table => split up into association tables (e.g. User ↔ License ↔ LicenseType)
  • ...
And I could probably go on and on and on. Use it right or don't use it all otherwise it's going to give you more problems than it's worth.
__________________
Vince is offline   Reply With Quote
Old 12/02/2016, 05:51 PM   #5
Terrorizt
Big Clucker
 
Terrorizt's Avatar
 
Join Date: Jun 2015
Posts: 110
Reputation: 6
Default Re: SaveAccount taking too long time

So it took me like 1 hour or 30 minutes to put all of them in 1 query:
Code:
stock File__SaveAccount(playerid)
{
	if(PLAYERLIST_authed[playerid] == 0) return 1;
	new pname[24];
    GetPlayerName(playerid, pname, 24);
	if(PLAYERLIST_authed[playerid])
	{
		new query[750];
		format(query, sizeof(query), "UPDATE PlayerInfo SET bank=%d, curmoney=%d, playerlvl=%d, rpoints=%d, playertime=%d, jail=%d, jailreason='%s', jailtime=%d banned=%d, banreason='%s', whobannedme='%s', whenigotbanned='%s', forumname='%s', Skin=%d, ranklvl=%d, rentprice=%d, driverlic=%d, flylic=%d, boatlic=%d, weaplic=%d, jobtime=%d, totalpayt=%d, pbkills=%d, pbdeaths=%d, housenum=%d, loan=%d, guns=%d, sguns=%d, sdrugs=%d, power=%d, female=%d, ethnic=%d, bail=%d, premium=%d, gotphone=%d, phonenumber=%d, phonebook=%d, laptop=%d, age=%d , premiumexpire=%d, playerteam=%d, radio=%d, freq1=%d, freq2=%d, freq3=%d, tutorial=%d, tbanned=%d, city='%s', PTeamName='%s',job='%s', totalruns=%d, fpay=%d, warns=%d, helper=%d, curfreq=%d, rankname='%s', phonechanges=%d, namechanges=%d,lastonline='%s', iPod=%d, finvite='%d', fradio='%d', fstock='%d', fwarehouse='%d', fweplic='%d', fbarrier='%d',tracker='%d', fbk='%d', bslot='%d', vslot='%d', hslot='%d', dealer=%d, accent='%s', togspawn='%d', spawnX='%f',spawnY='%f',spawnZ='%f',spawnINT='%d', spawnVW='%d' WHERE user='%s'", PlayerInfo[playerid][bank],PlayerTemp[playerid][sm],PlayerInfo[playerid][playerlvl],PlayerInfo[playerid][rpoints],PlayerInfo[playerid][playertime],PlayerInfo[playerid][jail], PlayerInfo[playerid][jailreason], PlayerInfo[playerid][jailtime],PlayerInfo[playerid][banned],PlayerInfo[playerid][banreason],PlayerInfo[playerid][whobannedme],PlayerInfo[playerid][whenigotbanned],PlayerInfo[playerid][forumname],PlayerInfo[playerid][Skin],PlayerInfo[playerid][ranklvl], PlayerInfo[playerid][rentprice], PlayerInfo[playerid][driverlic],PlayerInfo[playerid][flylic], PlayerInfo[playerid][boatlic], PlayerInfo[playerid][weaplic],PlayerInfo[playerid][jobtime], PlayerInfo[playerid][jobskill], PlayerInfo[playerid][totalpayt],PlayerInfo[playerid][pbkills], PlayerInfo[playerid][pbdeaths], PlayerInfo[playerid][housenum], PlayerInfo[playerid][loan], PlayerInfo[playerid][guns], PlayerInfo[playerid][sguns], PlayerInfo[playerid][sdrugs] PlayerInfo[playerid][power], PlayerInfo[playerid][female], PlayerInfo[playerid][ethnic], PlayerInfo[playerid][bail], PlayerInfo[playerid][premium], PlayerInfo[playerid][gotphone], PlayerInfo[playerid][phonenumber], PlayerInfo[playerid][phonebook], PlayerInfo[playerid][laptop], PlayerInfo[playerid][age], PlayerInfo[playerid][premiumexpire], PlayerInfo[playerid][playerteam],PlayerInfo[playerid][radio], PlayerInfo[playerid][freq1], PlayerInfo[playerid][freq2], PlayerInfo[playerid][freq3],PlayerInfo[playerid][tutorial], PlayerInfo[playerid][tbanned],PlayerInfo[playerid][city],PlayerInfo[playerid][PTeamName],PlayerInfo[playerid][job], PlayerInfo[playerid][totalruns], PlayerInfo[playerid][fpay],PlayerInfo[playerid][warns], PlayerInfo[playerid][helper],PlayerInfo[playerid][curfreq], PlayerInfo[playerid][rankname], PlayerInfo[playerid][phonechanges], PlayerInfo[playerid][namechanges], TimeDate(), PlayerInfo[playerid][iPod], PlayerInfo[playerid][finvite], PlayerInfo[playerid][fradio], PlayerInfo[playerid][fstock], PlayerInfo[playerid][fwarehouse],PlayerInfo[playerid][fweplic],PlayerInfo[playerid][fwarehouse],PlayerInfo[playerid][tracker], PlayerInfo[playerid][fbk],PlayerInfo[playerid][bslot],PlayerInfo[playerid][vslot],PlayerInfo[playerid][hslot],PlayerInfo[playerid][dealer], PlayerInfo[playerid][accent],PlayerTemp[playerid][togspawn],PlayerInfo[playerid][spawnX], PlayerInfo[playerid][spawnY],PlayerInfo[playerid][spawnZ], PlayerInfo[playerid][spawnINT],PlayerInfo[playerid][spawnVW], pname);
		mysql_query(query);


		new iString[ 50 ], tmp[ 10 ];
	    for(new c = 0; c < sizeof(drugtypes); c++)
		{
		    format(tmp,sizeof(tmp),"%d,", PlayerInfo[playerid][hasdrugs][c]);
		    strcat(iString,tmp);
		}
		strdel(iString,strlen(iString)-1, strlen(iString));
		format(query, sizeof(query), "UPDATE `PlayerInfo` SET `hasdrugs` = '%s' WHERE `user` = '%s'", iString, pname);
		mysql_query(query);
	}
    return 1;
}
I'm getting these errors, can anyone fix this? help:
Code:
C:\Users\Asser\Desktop\CMRP\gamemodes\CMRP.pwn(18407) : error 075: input line too long (after substitutions)
C:\Users\Asser\Desktop\CMRP\gamemodes\CMRP.pwn(18408) : error 037: invalid string (possibly non-terminated string)
C:\Users\Asser\Desktop\CMRP\gamemodes\CMRP.pwn(18408) : error 017: undefined symbol "UPDATE"
C:\Users\Asser\Desktop\CMRP\gamemodes\CMRP.pwn(18408) : warning 215: expression has no effect
C:\Users\Asser\Desktop\CMRP\gamemodes\CMRP.pwn(18408) : error 001: expected token: ";", but found "-identifier-"
C:\Users\Asser\Desktop\CMRP\gamemodes\CMRP.pwn(18408) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


5 Errors.
Terrorizt is offline   Reply With Quote
Old 12/02/2016, 05:58 PM   #6
Terrorizt
Big Clucker
 
Terrorizt's Avatar
 
Join Date: Jun 2015
Posts: 110
Reputation: 6
Default Re: SaveAccount taking too long time

Quote:
Originally Posted by Vince View Post
That's what you get for treating SQL like a simple filesystem.
  • Using a query for each variable
  • Not using threaded queries
  • Using the name as the key instead of the id
  • Probably not having an index on the name either = full table scan = much slower queries
  • Saving multiple values in one columns (drugs) = seriously not done => different table
  • Saving too many variables at once => update as needed!
  • Having too many columns in one table => split up into association tables (e.g. User ↔ License ↔ LicenseType)
  • ...
And I could probably go on and on and on. Use it right or don't use it all otherwise it's going to give you more problems than it's worth.
Can you give me the fix please? cuze i didn't get a single thing of what you said xd
EDIT: I deleted all mysql_query(query); and put only one. It is no longer slow but does this affect something?
Terrorizt is offline   Reply With Quote
Old 12/02/2016, 09:51 PM   #7
AmigaBlizzard
Huge Clucker
 
Join Date: Jul 2012
Posts: 320
Reputation: 60
Default Re: SaveAccount taking too long time

Only update what needs to be updated ==> if your server-variable changes, use a small query to update that value in the database too.

Don't update 100 values in the database when only 1 value changes.

For a file-system, yes, you NEED to do that, because you probably need to overwrite the entire file.

But you're using a DATABASE, which has the possibility to change value per value.

I always get furious when people use such huge queries for saving everything at once, and then they complain why it's so slow or they get silly errors, just because they didn't see a little mistake like a misplaced comma or whatever.
But they get those errors because their query is a huge block of text and you can't spot the error by just looking at it.

Split your query over your entire gamemode and use functions to make it easier.

http://forum.sa-mp.com/showpost.php?...31&postcount=5

This is an example from my own code.
Instead of using GivePlayerMoney, I'm using that function listed there.
It changes the values in the server-memory and it also updates the correct values in the database using a small query.

It's very easy to debug and easy to follow and you won't make mistakes that often.

It also uses threaded queries, so it doesn't slow down the script at all, not even when this function is called every second per player for example (that won't happen anyway because nobody's money should change that often).
Threaded queries are executed in the background and don't let your script wait until the query has been executed completely.
AmigaBlizzard is offline   Reply With Quote
Old 12/02/2016, 11:32 PM   #8
Sew_Sumi
Banned
 
Join Date: Jun 2008
Location: Azerbaijan
Posts: 6,269
Reputation: 525
Default Re: SaveAccount taking too long time

When you don't understand something, you'd be best to ****** it, and read up on it.

Quote:
Originally Posted by Vince View Post
That's what you get for treating SQL like a simple filesystem.
  • Using a query for each variable
  • Not using threaded queries
  • Using the name as the key instead of the id
  • Probably not having an index on the name either = full table scan = much slower queries
  • Saving multiple values in one columns (drugs) = seriously not done => different table
  • Saving too many variables at once => update as needed!
  • Having too many columns in one table => split up into association tables (e.g. User ↔ License ↔ LicenseType)
  • ...
And I could probably go on and on and on. Use it right or don't use it all otherwise it's going to give you more problems than it's worth.
What he actually said was quite straight forward in the sense of the previous reply to his.

Quote:
Originally Posted by SecretBoss View Post
What The Hell is that, you make a query to save one variable while you can save all of them with just one query

Here is a correct usage (Not made by me)

Code:
SaveData(playerid)
{
	new query[2500];
	format(query, sizeof(query), "UPDATE `accounts` SET");
	format(query, sizeof(query), "%s `score` = '%d',", query, Data[playerid][Score]);
	format(query, sizeof(query), "%s `kills` = '%d',", query, Data[playerid][Kills]);
	format(query, sizeof(query), "%s `deaths` = '%d',", query, Data[playerid][Deaths]);
	format(query, sizeof(query), "%s `money` = '%d',", query, Data[playerid][Money]);

	mysql_format(connection, query, sizeof(query), "%s", query);
	mysql_query(connection, query, false);
	return 1;
}
Both of which are saying the same thing. You need to optimize your script.

Last edited by Sew_Sumi; 13/02/2016 at 12:24 AM.
Sew_Sumi is offline   Reply With Quote
Old 12/02/2016, 11:51 PM   #9
Tamer
High-roller
 
Tamer's Avatar
 
Join Date: Nov 2011
Location: Turkey
Posts: 1,103
Reputation: 172
Default Re: SaveAccount taking too long time

I strongly advice optimizing that code. You should do what Vince and the other guys said.I just want to state that what they said is correct and that is how it is supposed to be done.

However, something which catched my eye is the "input line too long" error.

This error can be addressed by using the updated compiler made by ZeeX. Use that, however don't use it to fix that error specifically, but to make coding easier on your side.
__________________
The three stages of truth:

- Ridicule.
- Violent opposition.
- Acceptance.


Quote:
The greatest hypnotist on the planet Earth is an oblong box in the corner of the room. It is constantly telling us what to believe is real. If you can persuade people that what they see with their eyes is what there is to see you've got them. you know because they'll laugh in your face of an explanation that portrays the biggest picture of what's happening... and they have.
Tamer is offline   Reply With Quote
Old 14/02/2016, 08:01 PM   #10
AmigaBlizzard
Huge Clucker
 
Join Date: Jul 2012
Posts: 320
Reputation: 60
Default Re: SaveAccount taking too long time

In normal circumstances, you should never see the error "input line too long".
Either split up your line into multiple formats or strcat, or change the way you're doing things.

For normal code, lines are long enough.
Only for dialog contents you could reach the limit.

If you reach the max length with normal code, re-design your code because something is seriously wrong.

And try to stay away from compiler adjustments, unless there is no other way to get what you need.
But whatever you need should be do-able with some code-adjustments.

Adjusting compiler settings to suit bad programming style is bad on top of bad (= not done).
Some people make gamemodes of 50k+ lines long and never adjust a single compiler setting and get their code to work just fine, so can you.
AmigaBlizzard is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SA-MP taking REALLY long to load gta_sa.exe supernerd2000 Client Support 25 16/01/2015 12:39 AM
SetTimerEx taking more time TwinkiDaBoss Scripting Help 3 17/10/2014 02:33 AM
Server taking a long time to load Jackatron99 Server Support 7 19/04/2014 03:42 PM
Why is it taking too much time on compiling my Gamemode? Magic_Time Scripting Help 3 19/07/2013 11:56 PM


All times are GMT. The time now is 10:32 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.