Mysql problem
#1

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:


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.

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

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(Querysizeof(Query), "INSERT INTO `users` VALUES ('%s','%s','%s','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d', '0')",\
                             
escnomeescpassIPmcookies[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); 
OnPlayerDisconnect

PHP код:
public OnPlayerDisconnect(playeridreason)
{
    
D_OnPlayerDisconnect(playerid);
    
salvadata(playerid);//to store data 
    //resetting variables and timers activeted during the game
    
return 1;

salvadata stock

PHP код:
stock salvadata(playerid)
{
    new 
nome[MAX_PLAYER_NAME];
    
GetPlayerName(playerid,nomesizeof(nome));
    if(
log[playerid] == 1)
    {
        new 
Query[300]; format(Querysizeof(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(Querysizeof(Query), "UPDATE `users` SET `exp` = '%d',`level`= '%d' WHERE `Nome` = '%s'",exp[playerid],level[playerid],nome);
        
mysql_query(Query);
    }
    return 
1;

Banned variable setting query (Putted in Ban, it works)

PHP код:
format(Querysizeof(Query), "UPDATE `users` SET `Banned` = '1' WHERE `Nome` = '%s'"name);
    
mysql_query(Query);
//log 
Column 1  : [08:04:42CMySQLHandler::Query(UPDATE `usersSET `Banned` = '1' WHERE `Nome` = 'DurexGEL') - Successfully executed
Checking Banned variable (put in load player data stock, it works fine)

PHP код:
        mysql_fetch_field_row(datastr,"Banned");
        if(
strval(datastr) == 1)
        {
            new 
name[MAX_PLAYER_NAME], str[128], str1[128];
            
GetPlayerName(playeridnamesizeof name);
            
format(strsizeof str,"*** %s и stato automaticamente bannato per: Evader!"name);
            
format(str1sizeof str1,"*** %s has automatically been banned for: Evader!"name);
            
SendLanguageMessageToAll(COLOR_REDstrstr1);
            
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;
        } 
Update IP query (it is in load player data)

PHP код:
    new IPm[16], new nome[MAX_PLAYER_NAME];
    
GetPlayerName(playerid,nomesizeof(nome));
    
GetPlayerIp(playerid,IPmsizeof(IPm));
        new 
dataz[300];
    
format(datazsizeof(dataz), "UPDATE `users` SET `IP` = '%s', `Anno`= '%d', `Mese`= '%d',`Giorno`= '%d' WHERE `Nome` = '%s'"IPmannomesegiornonome);
         
mysql_query(dataz); 
Everything was perfect before I insert the new variable, if I remove it everything goes great.

Hope you can help me Thanks
Reply
#2

If you don't have time to read all, could you get me some ideas of where is the problem? Some doubt? I'll try to fix by myself, but I really don't know where I should correct :/
Reply
#3

Vuoi che ti aiuti quando torno a casa via skype? Mi dispiace per il cattivo italiano, sto imparando.
Reply
#4

are you reseting veriable? if yes in which ? OnPlayerConnect or OnPlayerDisconnect? show us
Reply
#5

Yes, but I put the load stock or the save stock BEFORE the variables resetting..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)