Posts: 1,076
Threads: 70
Joined: Jul 2016
Reputation:
0
I use strcat and format in these situations
Posts: 1,219
Threads: 51
Joined: Jul 2012
U can insert line breaks like this:
PHP код:
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]);
Posts: 1,219
Threads: 51
Joined: Jul 2012
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(string, sizeof(string), string, 5);
Posts: 10,066
Threads: 38
Joined: Sep 2007
Reputation:
0
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.
Posts: 928
Threads: 13
Joined: Feb 2016
Reputation:
0
or just simply use Zeex's PAWN Compiler.