[MySQL] LoadPlayerStats(playerid) - Unknown123 - 13.05.2011
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();
}
Re: [MySQL] LoadPlayerStats(playerid) -
Georgelopez1 - 13.05.2011
Try loading it in your CheckUser stock instead. Works a whole lot better.
Re: [MySQL] LoadPlayerStats(playerid) - Unknown123 - 13.05.2011
Quote:
Originally Posted by Georgelopez1
Try loading it in your CheckUser stock instead. Works a whole lot better.
|
Thanks :P
Re: [MySQL] LoadPlayerStats(playerid) -
Georgelopez1 - 13.05.2011
Did it work?
Re: [MySQL] LoadPlayerStats(playerid) - Unknown123 - 13.05.2011
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"
Re: [MySQL] LoadPlayerStats(playerid) -
Skylar Paul - 13.05.2011
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.
Re: [MySQL] LoadPlayerStats(playerid) -
__ - 13.05.2011
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.