Explain this for me, please .
#1

pawn Код:
sscanf(line, "p|ssdddds", data[0], data[1], data2[0], data2[1], data2[2], data2[3], data[2]);
 SetPVarInt(playerid, "Kills", data2[0]);
 SetPVarInt(playerid, "Logged", 1);
 SetPVarInt(playerid, "Deaths", data2[1]);
 SetPlayerScore(playerid, data2[2]);
 SetPVarInt(playerid, "MoneyGiven", data2[3]);
This is apart of the login command, using mysql and sscanf. Can someone explain to me how the datas work? Like how does
pawn Код:
etPVarInt(playerid, "MoneyGiven", data2[3]);
Give money? Thanks in advance to whoever explains this code to me .
Reply
#2

OK, lets break this down. The data in the table is in row formats. You will be retreiving the row that the certain player data is stored in. The line variable has the whole row, so we need to split it with sscanf because it will look something like this
Код:
[HiC]TheKiller|Password|5|5|5|5|192.168.2.1
Which is actually
Код:
User|Password|Kills|deaths|Score|money|Ip
Now we use sccanf with the delimiter p| because we are splitting at the |. Sccanf now splits the information into single variables. It's just easier having 2 variables instead of one.

pawn Код:
sscanf(line, "p|ssdddds", data[0], data[1], data2[0], data2[1], data2[2], data2[3], data[2]);
/*
p = showing the delimiter in the next character
| = Delimiter
s (data[0]) = Username, we may need that for something?
s (data[1]) = password, we may need that for something else?
d (data2[0]) = Kills (We set that into player variables later on)
d (data2[1]) = Deaths (We set that into a Pvar)
d (data2[2]) = Score (Sets player's score)
d (data2[3]) = Money (Sets players money)
s (data[2]) = Sets players IP in varaible.
*/
I'll update the tutorial later as some people may be confused with it.
Reply
#3

Thanks for the explanation, it helped out somewhat
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)