24.10.2010, 08:44
Hello,
I have a huge problem with my script.
Everything goes fine with the saving to database, loading and all other, BUT, there is a problem: on the server, id 1 and id 2 are connected to the server (this is an example). If id 1 quits, and someone else (or the same player) joins (it'll take id 1, ofc), the player with id 2 loses his stats (level, adminlevel, etc... they all get 0). This happens if any id with 1 lower connects, the next id loses his stats.
Why is that ?
This is a part of the script:
Can someone help me, please ?
I have a huge problem with my script.
Everything goes fine with the saving to database, loading and all other, BUT, there is a problem: on the server, id 1 and id 2 are connected to the server (this is an example). If id 1 quits, and someone else (or the same player) joins (it'll take id 1, ofc), the player with id 2 loses his stats (level, adminlevel, etc... they all get 0). This happens if any id with 1 lower connects, the next id loses his stats.
Why is that ?
This is a part of the script:
Код:
// mysql table = playerleveling
public LoadPlayerLeveling(playerid)
{
new cereresql[80], row[512], pdata[9][32];
format(cereresql, sizeof(cereresql), "SELECT * FROM playerleveling WHERE id=%d", PlayerInfo[playerid][pSQLID]);
samp_mysql_query(cereresql);
SQLLog(cereresql);
samp_mysql_store_result();
if (samp_mysql_num_rows() != 0)
{
samp_mysql_fetch_row(row);
split(row, pdata, '|');
PlayerInfo[playerid][pLevel] = strvalEx(pdata[1]); //Level
PlayerInfo[playerid][pAdmin] = strvalEx(pdata[2]); ///AdminLevel
PlayerInfo[playerid][pUpgrade] = strvalEx(pdata[3]); //UpgradePoints
PlayerInfo[playerid][pConnectTime] = strvalEx(pdata[4]); //ConnectedTime
PlayerInfo[playerid][pExp] = strvalEx(pdata[5]); //Respect
PlayerInfo[playerid][pPayDay] = strvalEx(pdata[6]); //PayDay
PlayerInfo[playerid][pPayDayHad] = strvalEx(pdata[7]); //PayDayHad
PlayerInfo[playerid][pPayCheck] = strvalEx(pdata[8]); //Paycheck
}
return 1;
}
public SavePlayerLeveling(playerid)
{
new query[512],name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(query, sizeof(query), "UPDATE playerleveling SET PlayerLevel=%d, AdminLevel=%d, UpgradePoints=%d, ConnectedTime=%d, Respect=%d, PayDay=%d, PayDayHad=%d, Paycheck=%d WHERE id=%d",
PlayerInfo[playerid][pLevel],//Level
PlayerInfo[playerid][pAdmin], ///AdminLevel
PlayerInfo[playerid][pUpgrade], //UpgradePoints
PlayerInfo[playerid][pConnectTime], //ConnectedTime
PlayerInfo[playerid][pExp], //Respect
PlayerInfo[playerid][pPayDay], //PayDay
PlayerInfo[playerid][pPayDayHad], //PayDayHad
PlayerInfo[playerid][pPayCheck],//Paycheck
PlayerInfo[playerid][pSQLID]);
samp_mysql_query(query);
SQLLog(query);
printf("SavePlayerLeveling for %s", name);
return 1;
}


