SSCANF Error
#1

Im trying to make mysql system.
Using sscanf like that:
pawn Код:
new row[1024];
new ExplodeSplit[210];
sscanf(row, "e<p<|>s[30]s[30]dddddddddddds[30]ddddddddddddddddddddddddddddddddddddddffddddddddddddddddddddddddddddddddddddddddds[30]s[30]s[30]s[30]s[30]dffffdffffdffffddffffffffdfffffffffffffffddds[30]s[30]s[30]s[30]s[30]ffffdddddddddddddddddddddddddddddddddddddddddddddddddds[30]>", ExplodeSplit);
strmid(PlayerInfo[playerid][pKey], ExplodeSplit[1], 0, strlen(ExplodeSplit[1]), 255);
PlayerInfo[playerid][pLevel] = strval(ExplodeSplit[2]);
PlayerInfo[playerid][pAdmin] = strval(ExplodeSplit[3]);
Why its not loading yet?
Reply
#2

and if i change it to " PlayerInfo[playerid] "
somthing like this:
pawn Код:
and this is the enum:
enum pInfo
{
pNick[128],
pKey[128],
pLevel,
pAdmin,
pDonateRank,
gPupgrade,
pConnectTime,
pReg,
}
new PlayerInfo[MAX_PLAYERS][pInfo];

sscanf(row, "e<p<|>s[30]s[30]dddddddddddds[30]ddddddddddddddddddddddddddddddddddddddffddddddddddddddddddddddddddddddddddddddddds[30]s[30]s[30]s[30]s[30]dffffdffffdffffddffffffffdfffffffffffffffddds[30]s[30]s[30]s[30]s[30]ffffdddddddddddddddddddddddddddddddddddddddddddddddddds[30]>", PlayerInfo[playerid]);


its still doesnt work.
Reply
#3

See, this is my full code:
pawn Код:
public LoadMYSQL(playerid, password[])
{
    new sscanfinput[64], string[256];
     new name[24],
      Escape[2][128];
     GetPlayerName(playerid, name, 50);
     mysql_real_escape_string(name, Escape[0]); // This function makes sure you don't get MySQL injected. Read about it by searching it on ******.
     mysql_real_escape_string(sscanfinput, Escape[1]);
     //format(string, 128, "SELECT * FROM `playerinfo` WHERE `user` = '%s' AND `password` = '%s'", name, password);
     format(string, sizeof(string), "SELECT * FROM `playerinfo` WHERE `user` = '%s' AND `password` = '%s'", name, password);
     mysql_query(string);
     mysql_store_result();
     SendClientMessage(playerid, COLOR_PURPLE, "You're logged in.");
     new row[2048];
     sscanf(row, "p<|>e<s[128]s[128]iiiiiiiiiiiis[128]iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiis[128]s[128]s[128]s[128]s[128]iffffiffffiffffiiffffffffifffffffffffffffiiis[128]s[128]s[128]s[128]s[128]ffffiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiis[128]>", PlayerInfo[playerid]);
     mysql_store_result();
     mysql_free_result();
     gPlayerLogged[playerid] = 1;
     SendClientMessage(playerid, COLOR_YELLOW, "Account loaded.");
     return 1;
}
If i change the PlayerInfo[playerid] to new var[pInfo]; its just stuck there, and its not continue with the loading.
what can be the problem ?
Reply
#4

PlayerInfo[playerid][PINFOVARHERE]
Reply
#5

No. It should work with PlayerInfo[playerid].
Just ensure that all fields in the database are in exactly the same order as the enum.
Reply
#6

Quote:
Originally Posted by Vince
Посмотреть сообщение
No. It should work with PlayerInfo[playerid].
Just ensure that all fields in the database are in exactly the same order as the enum.
Really!? Thanks for telling me
Reply
#7

Theres no exactly the same name, but it the same place.
like if in pInfo its "pNick" in the database its "user"
its a problem ?

EDIT: change it right now to the same and its still doesnt work..
Reply
#8

Ran into the same problem earlier today, i found a solution, and mad a thread about it, https://sampforum.blast.hk/showthread.php?tid=177139 feel free to comment
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)