[MySQL] LoadPlayerStats(playerid)
#1

Looks this right? if it does then it have to be something with my saving
pawn Код:
stock LoadPlayerStats(playerid)
{
    new string[200];
    format(string, sizeof(string), "SELECT * FROM `playeraccounts` WHERE `Username` = '%s'", PlayerName(playerid));
    mysql_query(string);
    mysql_store_result();

    mysql_fetch_row(string, "|");

    sscanf(string, "p<|>s[16]dddd", PlayerData[playerid][IP], PlayerData[playerid][Score], PlayerData[playerid][Money], PlayerData[playerid][Kills], PlayerData[playerid][Deaths]);
   
    SetPlayerScore(playerid, PlayerData[playerid][Score]);
    GivePlayerMoney(playerid, PlayerData[playerid][Money]);
    mysql_free_result();
}
Reply
#2

Try loading it in your CheckUser stock instead. Works a whole lot better.
Reply
#3

Quote:
Originally Posted by Georgelopez1
Посмотреть сообщение
Try loading it in your CheckUser stock instead. Works a whole lot better.
Thanks :P
Reply
#4

Did it work?
Reply
#5

Quote:
Originally Posted by Georgelopez1
Посмотреть сообщение
Did it work?
Not really :P i solved it by myslef :P

had to change

pawn Код:
sscanf(string, "p<|>s[16]dddd", PlayerData[playerid][IP], PlayerData[playerid][Score], PlayerData[playerid][Money], PlayerData[playerid][Kills], PlayerData[playerid][Deaths]);
//TO
new name[MAX_PLAYER_NAME], password[145];
sscanf(string, "p<|>s[24]s[145]s[16]dddd", name, password, PlayerData[playerid][IP], PlayerData[playerid][Score], PlayerData[playerid][Money], PlayerData[playerid][Kills], PlayerData[playerid][Deaths]);

//So iy get loaded correctly :P
but i got another question

When the player leave i save the account right

Save score, money, ip ect... you know

and i use this function to save the IP
pawn Код:
stock PlayerIP(playerid)
{
    new playerip[16];
    GetPlayerIp(playerid, playerip, sizeof(playerip));
    return playerip;
}
....When the account get created (using that function to get IP) then it works fine, but if i save the IP at OnPlayerDisConnect then hes IP gets saved as "255.255.255.255"
Reply
#6

Quote:
Originally Posted by Unknown123
Посмотреть сообщение
Not really :P i solved it by myslef :P

had to change

pawn Код:
sscanf(string, "p<|>s[16]dddd", PlayerData[playerid][IP], PlayerData[playerid][Score], PlayerData[playerid][Money], PlayerData[playerid][Kills], PlayerData[playerid][Deaths]);
//TO
new name[MAX_PLAYER_NAME], password[145];
sscanf(string, "p<|>s[24]s[145]s[16]dddd", name, password, PlayerData[playerid][IP], PlayerData[playerid][Score], PlayerData[playerid][Money], PlayerData[playerid][Kills], PlayerData[playerid][Deaths]);

//So iy get loaded correctly :P
but i got another question

When the player leave i save the account right

Save score, money, ip ect... you know

and i use this function to save the IP
pawn Код:
stock PlayerIP(playerid)
{
    new playerip[16];
    GetPlayerIp(playerid, playerip, sizeof(playerip));
    return playerip;
}
....When the account get created (using that function to get IP) then it works fine, but if i save the IP at OnPlayerDisConnect then hes IP gets saved as "255.255.255.255"
IP cannot be saved OnPlayerDisconnect, it just doesn't work. Save it on OnPlayerConnect.
Reply
#7

Alternatively, store the player's IP in a global variable on player connect and just save it on disconnect.

An IP can't be obtained after a player disconnects, but as for player vars and other stats (score, money, etc) - they're cached for OnPlayerDisconnect.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)