#1

I've created this for a basic rank system to save,

pawn Код:
format(Query, sizeof(Query), "UPDATE `userinfo` SET `score` = %d, `rank` = %d,`xp` = %d, `kills` = %d WHERE `user` = '%s'", GetPlayerScore(playerid), rank[playerid], score2[playerid], kills[playerid], pname(playerid));
But the problem is, the function xp only saves, not score/rank/kills.

What am i doing wrong?

P.S newbie to MySQL.
Reply
#2

Show mysql.log
Reply
#3

pawn Код:
[02:46:50] CMySQLHandler::Query(UPDATE `userinfo` SET `score` = 0, `rank` = 0,`xp` = 0, `kills` = 0 WHERE `user` = '') - Successfully executed.
[02:46:50] >> mysql_free_result( Connection handle: 1 )
[02:46:50] CMySQLHandler::FreeResult() - The result is already empty.
Reply
#4

Nothing is wrong
pawn Код:
new Score = GetPlayerScore(playerid);
new Rank = rank[playerid];
new Score2 = score2[playerid];
new Kills = kills[playerid];
printf("%d %d %d %d", Score, Rank, Score2, Kills);
format(Query, sizeof(Query), "UPDATE `userinfo` SET `score` = '%d', `rank` = '%d', `xp` = '%d', `kills` = '%d' WHERE `user` = '%s'", Score, Rank, Score2, Kills, pname(playerid));
mysql_query(Query);
I tried to do a printf to see if the variables isnt empty
Reply
#5

Your "user" variable is empty for that matter. What does "pname(playerid)" actually do?

If you want another method, use this:
pawn Код:
stock pname(playerid)
{
    new playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername, 24);
    return playername;
}
Reply
#6

Quote:
Originally Posted by Skribblez
Посмотреть сообщение
Your "user" variable is empty for that matter. What does "pname(playerid)" actually do?

If you want another method, use this:
pawn Код:
stock pname(playerid)
{
    new playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername, 24);
    return playername;
}
pawn Код:
new name[24];
stock pname(playerid)
{
    new escname[24];
    GetPlayerName(playerid, name, 24);
    mysql_real_escape_string(name, escname);
    return escname;
}
Reply
#7

Try using the code I posted. There's no need to escape the string since I'm pretty sure that the player's name wouldn't contain any invalid characters, unless you allow them to.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)