09.04.2015, 11:19
Hi guys, I didn't manage to resolve a big problem that occurs to my gamemode.. I have recently added (two days ago) a new variable in the mysql by using the phpmyadmin. I've set it in this (click) way.
So I have scripted it in the gamemode and added into the register system.
I don't know why but sometimes people who relogs have their pg resetted, or better only the variables updated in mysql by OnPlayerDisconnect are resetted. By controlling the logs I have saw something strange:
Why it get me this Name? ('12|0') It takes this from the FetchRow return.. But it happens only sometimes; it usually works fine. I have noticed that it happens when a query is big such as in this case
But this isn't the only problem.. As I said before some PGs lost their stats but NOT COMPLETELY! Only the variables updated in OnPlayerDisconnect
Register Query (The '0' is the Banned variable)
OnPlayerDisconnect
salvadata stock
Banned variable setting query (Putted in Ban, it works)
Checking Banned variable (put in load player data stock, it works fine)
Update IP query (it is in load player data)
Everything was perfect before I insert the new variable, if I remove it everything goes great.
Hope you can help me Thanks
So I have scripted it in the gamemode and added into the register system.
I don't know why but sometimes people who relogs have their pg resetted, or better only the variables updated in mysql by OnPlayerDisconnect are resetted. By controlling the logs I have saw something strange:
Quote:
[08:02:57] CMySQLHandler::FetchRow() - Return: [Hunter]Akato$h[S]|passwordcensured|ipcensured|14|0|956|7882|6886338 |136|2015|3|15|0|7882|10227|0|4024|12|0 Column 1 : [08:02:57] CMySQLHandler::Query(UPDATE `users` SET `IP` = 'ipcensured', `Anno`= '2015', `Mese`= '4',`Giorno`= '8' WHERE `Nome` = '12|0') - Successfully executed. |
But this isn't the only problem.. As I said before some PGs lost their stats but NOT COMPLETELY! Only the variables updated in OnPlayerDisconnect
Quote:
[08:05:06] CMySQLHandler::FetchRow() - Return: [Hunter]NicO|passwordcensured|ipcensured|0|0|0|0|0|230|201 5|4|8|0|0|0|0|0|0|0 |
Register Query (The '0' is the Banned variable)
PHP код:
format(Query, sizeof(Query), "INSERT INTO `users` VALUES ('%s','%s','%s','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d', '0')",\
escnome, escpass, IPm, cookies[playerid], lvl[playerid],ak[playerid], GetPlayerScore(playerid), GetPlayerMoney(playerid), GetPlayerSkin(playerid),anno,mese,giorno,dpm[playerid],kills[playerid],morti[playerid],vip[playerid],exp[playerid],level[playerid]/*,raceswin[playerid]*/);
mysql_query(Query);
PHP код:
public OnPlayerDisconnect(playerid, reason)
{
D_OnPlayerDisconnect(playerid);
salvadata(playerid);//to store data
//resetting variables and timers activeted during the game
return 1;
}
PHP код:
stock salvadata(playerid)
{
new nome[MAX_PLAYER_NAME];
GetPlayerName(playerid,nome, sizeof(nome));
if(log[playerid] == 1)
{
new Query[300]; format(Query, sizeof(Query), "UPDATE `users` SET `Cookies`= '%d', `Livello` = '%d', `AK` = '%d', `Score` = '%d', `Soldi` = '%d', `Skin` = '%d',`PMs` = '%d',`Kills` = '%d',`Morti` = '%d' WHERE `Nome` = '%s'", cookies[playerid], lvl[playerid], ak[playerid], GetPlayerScore(playerid), GetPlayerMoney(playerid),GetPlayerSkin(playerid), dpm[playerid],kills[playerid],morti[playerid],nome);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `users` SET `exp` = '%d',`level`= '%d' WHERE `Nome` = '%s'",exp[playerid],level[playerid],nome);
mysql_query(Query);
}
return 1;
}
PHP код:
format(Query, sizeof(Query), "UPDATE `users` SET `Banned` = '1' WHERE `Nome` = '%s'", name);
mysql_query(Query);
//log
Column 1 : [08:04:42] CMySQLHandler::Query(UPDATE `users` SET `Banned` = '1' WHERE `Nome` = 'DurexGEL') - Successfully executed.
PHP код:
mysql_fetch_field_row(datastr,"Banned");
if(strval(datastr) == 1)
{
new name[MAX_PLAYER_NAME], str[128], str1[128];
GetPlayerName(playerid, name, sizeof name);
format(str, sizeof str,"*** %s и stato automaticamente bannato per: Evader!", name);
format(str1, sizeof str1,"*** %s has automatically been banned for: Evader!", name);
SendLanguageMessageToAll(COLOR_RED, str, str1);
SendLanguageMessage(playerid,COLOR_RED,"*** Sei stato automaticamente bannato perchй hai evaso il ban!","*** You've automatically been banned because you escaped the ban!");
SystemBan(playerid,"Anti-Evader");
return 1;
}
PHP код:
new IPm[16], new nome[MAX_PLAYER_NAME];
GetPlayerName(playerid,nome, sizeof(nome));
GetPlayerIp(playerid,IPm, sizeof(IPm));
new dataz[300];
format(dataz, sizeof(dataz), "UPDATE `users` SET `IP` = '%s', `Anno`= '%d', `Mese`= '%d',`Giorno`= '%d' WHERE `Nome` = '%s'", IPm, anno, mese, giorno, nome);
mysql_query(dataz);
Hope you can help me Thanks