input line too long
#1

Код:
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;
}
Reply
#2

I use strcat and format in these situations
Reply
#3

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]); 
Reply
#4

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);
Reply
#5

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); 
Reply
#6

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.
Reply
#7

or just simply use Zeex's PAWN Compiler.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)