SA-MP Forums Archive
input line too long - 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: input line too long (/showthread.php?tid=626470)



input line too long - XStormiest - 15.01.2017

Код:
forward SaveAccount(playerid);
public SaveAccount(playerid)
{
	new rows;
	cache_get_row_count(rows);
	if(rows >= 1)
	{
	    new string[2048];
	    format(string, sizeof(string), "UPDATE `ptp` SET `Admin` = '%d', `Kills` = '%d', `Deaths` = '%d', `Ratio` = '%f' ,`HoursPlayed` = '%d', `MinutesPlayed` = '%d', `SecondsPlayed` = '%d', `Score` = '%d', `Cash` = '%d' WHERE `username` = '%s'", P_Account[playerid][Admin], P_Account[playerid][Kills], P_Account[playerid][Deaths], P_Account[playerid][Ratio], P_Account[playerid][HoursPlayed], P_Account[playerid][MinutesPlayed], P_Account[playerid][SecondsPlayed], P_Account[playerid][Score], P_Account[playerid][Cash]);
	    
	}
	return 1;
}



Re: input line too long - Eoussama - 15.01.2017

I use strcat and format in these situations


Re: input line too long - BiosMarcel - 15.01.2017

U can insert line breaks like this:

PHP код:
format(stringsizeof(string), "UPDATE `ptp` SET `Admin` = '%d', `Kills` = '%d', `Deaths` = '%d', `Ratio`\
 = '%f' ,`HoursPlayed` = '%d', `MinutesPlayed` = '%d', `SecondsPlayed` = '%d', `Score` = '%d', `Cash` =\
  '%d' WHERE `username` = '%s'"
P_Account[playerid][Admin], P_Account[playerid][Kills], P_Account[playerid][Deaths],\
   
P_Account[playerid][Ratio], P_Account[playerid][HoursPlayed], P_Account[playerid][MinutesPlayed], \
   
P_Account[playerid][SecondsPlayed], P_Account[playerid][Score], P_Account[playerid][Cash]); 



Re: input line too long - GoldenLion - 15.01.2017

Quote:
Originally Posted by [Bios]Marcel
Посмотреть сообщение
U can insert line breaks like this:

PHP код:
format(stringsizeof(string), "UPDATE `ptp` SET `Admin` = '%d', `Kills` = '%d', `Deaths` = '%d', `Ratio`\
 = '%f' ,`HoursPlayed` = '%d', `MinutesPlayed` = '%d', `SecondsPlayed` = '%d', `Score` = '%d', `Cash` =\
  '%d' WHERE `username` = '%s'"
P_Account[playerid][Admin], P_Account[playerid][Kills], P_Account[playerid][Deaths],\
   
P_Account[playerid][Ratio], P_Account[playerid][HoursPlayed], P_Account[playerid][MinutesPlayed], \
   
P_Account[playerid][SecondsPlayed], P_Account[playerid][Score], P_Account[playerid][Cash]); 
I'm pretty sure these slashes are not needed.
What you can also do is break the string into pieces like this:
Код:
format(string, sizeof(string), "item1 = 1, item2 = 2);
format(string, sizeof(string), %s, item3 = 3, item4 = 4, string);



Re: input line too long - BiosMarcel - 15.01.2017

Quote:
Originally Posted by GoldenLion
Посмотреть сообщение
I'm pretty sure these slashes are not needed.
What you can also do is break the string into pieces like this:
Код:
format(string, sizeof(string), "item1 = 1, item2 = 2);
format(string, sizeof(string), %s, item3 = 3, item4 = 4, string);
Opinion based ^^ but yeah, that would work, but you shouldnt use format when you could do this:

PHP код:
string "Test%dTest";
format(stringsizeof(string), string5); 



Re: input line too long - Vince - 15.01.2017

But what you should do is remove stuff that isn't needed. Admin level doesn't change on a constant basis so isn't needed. Ratio is (presumably) kills divided by deaths so isn't needed, sixty seconds is one minute and sixty times sixty seconds is an hour so MinutesPlayed and HoursPlayed aren't needed. That's four out of nine columns that can be eliminated by applying logic.


Re: input line too long - oMa37 - 15.01.2017

or just simply use Zeex's PAWN Compiler.