Saving MySQL account; too long.
#1

I use this
pawn Код:
format(s_Query,sizeof(s_Query),"UPDATE `accounts` SET sLevel='%d',sMoney='%d',sBank='%d',sSkin='%d', sIP ='%s', sX='%f',sY='%f',sZ='%f',sA='%f',sInterior='%d',sVw='%d', WHERE suser='%s'",PlayerInfo[playerid][sLevel],PlayerInfo[playerid][sMoney],PlayerInfo[playerid][sBank],PlayerInfo[playerid][sSkin],PlayerInfo[playerid][sIP],PlayerInfo[playerid][sPos][0],PlayerInfo[playerid][sPos][1],PlayerInfo[playerid][sPos][2],PlayerInfo[playerid][sPos][3],PlayerInfo[playerid][sInterior],PlayerInfo[playerid][sVw],PlayerName);
But it's too long, how can I shorten it?
Reply
#2

I used strcat for mine. Clicckkky

If you need any more help, just ask

EDIT:

When I did mine, I did it like:

pawn Код:
new str[128], str2[128];
format(str, sizeof(str), "UPDATE Users "); strcat(str, str2);
for every param.
Reply
#3

pawn Код:
new
    szStr[128];
strcat(szStr, "You can ");
format(szStr, sizeof(szStr), "%sdo this too", szStr);
Reply
#4

Код:
new str[128];
format(str, sizeof(str), "Something here \
And something here");
Reply
#5

Quote:
Originally Posted by Darnell
Посмотреть сообщение
But it's too long, how can I shorten it?
you can not...
Reply
#6

Can you give me a big example? Like, saving the user, password and the kills, I'll continue from there.
Reply
#7

Quote:
Originally Posted by Darnell
Посмотреть сообщение
Can you give me a big example? Like, saving the user, password and the kills, I'll continue from there.
pawn Код:
format(s_Query,sizeof(s_Query),"UPDATE `accounts` SET sLevel='%d',sMoney='%d',sBank='%d',sSkin='%d',\
sIP ='%s', sX='%f',sY='%f',sZ='%f',sA='%f',sInterior='%d',sVw='%d', WHERE suser='%s'"
,PlayerInfo[playerid][sLevel],PlayerInfo[playerid][sMoney],PlayerInfo[playerid][sBank],PlayerInfo[playerid][sSkin],PlayerInfo[playerid]sIP],
PlayerInfo[playerid][sPos][0],PlayerInfo[playerid][sPos][1],PlayerInfo[playerid][sPos][2],PlayerInfo[playerid][sPos][3],PlayerInfo[playerid][sInterior],PlayerInfo[playerid][sVw],PlayerName);
You could do it by adding the "backslash.
Reply
#8

Less stupid query?
Reply
#9

Код:
new string[512], string2[128];
format(string, sizeof(string), "UPDATE asd = %i, abc = '%s', agh = '%f', ", a, b, c); // In the end of the first or in the beginning of the second line must be a space.
format(string2, sizeof(string2), "ghj = %i, gsg = %i, ", d, e);
strcat(string, string2);
format(string2, sizeof(string2), "yue = '%s' WHERE agn = %i", f, g);
strcat(string, string2);
It may have some typos in it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)