MySQL - wont save stats on disconnect
#1

I have a little problem with saving my stats upon disconnecting
I registered, and then disconnected, this is the result

PHP код:
public OnPlayerDisconnect(playerid) {
        
Invisible[playerid] = 0;
    
IsControlling[playerid] = 0;
    
ControlNumber[playerid] = -1
    
OrigPName[playerid] = "\0";
    
OrigTName[playerid] = "\0";
    
Mysql_SAVE(playerid);
        return 
1;
}
stock Mysql_SAVE(playerid)
{
    new 
query[256];
    new 
Float:xFloat:yFloat:z;
    
GetPlayerPos(playeridxyz);
    
mysql_format(mysqlquerysizeof(query), "UPDATE `users` SET `PosX` = %f, `PosY`=%f,`PosZ`=%f,`Admin`=%d,`Cash`=%d,`Kills`=%d,`Deaths`=%d,`Skin`=%d,`IsBanned`=%d WHERE `UID` = %d"xyzPlayerInfo[playerid][pAdmin],PlayerInfo[playerid][pCash],PlayerInfo[playerid][pKills], PlayerInfo[playerid][pDeaths],PlayerInfo[playerid][pSkin],PlayerInfo[playerid][pBanned], PlayerInfo[playerid][UID]);
    
mysql_tquery(mysqlquery);
    return 
1;

and also my pass wont show up in the database, but when I login, i can just type any word and i continue and play

PHP код:
public OnPlayerConnect(playerid)
{
    new 
query[128];
    
GetPlayerIp(playeridIP[playerid], 16);
    
mysql_format(mysqlquerysizeof(query),"SELECT `Pass`,`UID` FROM `users` WHERE `Name` = '%s'"GetName(playerid));
    
mysql_tquery(mysqlquery"OnConnection""i"playerid);
    
cp[playerid] = 1;
    
SetPlayerCheckpoint(playerid,1642.5245,-2241.6150,-2.7038,5);
    return 
1;
}
forward OnConnection(playerid);
public 
OnConnection(playerid) {
    new 
rowsfields;
    
cache_get_data(rowsfieldsmysql);
    if(
rows) {
        
cache_get_field_content(0"Pass"PlayerInfo[playerid][pPass], mysql129);
        
PlayerInfo[playerid][UID] = cache_get_field_content_int(0"UID");
        
printf("%s"PlayerInfo[playerid][pPass]);
        
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_PASSWORD"Login""Your account is found in our database!\nPlease enter your password to continue!""Login""Quit");
    } else {
        
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT"Register""Your account is not found in our databse!\nPlease enter a password so that you can save your stats and load it in the future.""Register""Quit");
    }
}
public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    new 
query[144], ip[20];
    switch( 
dialogid )
    {
        case 
DIALOG_REGISTER:
        {
            if (!
response) return Kick(playerid); //If the player clicks the second button
            
if(response//If he clicks the first button
            
{
                if(!
strlen(inputtext)) return ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT"Registering","You have entered an invalid password.\nType your password below to register a new account.","Register","Quit"); //This happens if the user has input no password. You can add limits here.
                
else {
                    
WP_Hash(PlayerInfo[playerid][pPass], 129inputtext);
                    
GetPlayerIp(playeridipsizeof(ip));
                    
mysql_format(mysqlquerysizeof(query), "INSERT INTO `users` (Name, Pass, IP) VALUES ('%s', '%e', '%s')"GetName(playerid), PlayerInfo[playerid][pPass], ip);
                    
mysql_tquery(mysqlquery"OnRegisteration""i"playerid);
                    
SendMessage(playerid"Succesfully registered!");
                }
                
pNewlyRegged[playerid] = true//Changing the value of our boolean
            
}
        }
        case 
DIALOG_LOGIN:
        {
            if ( !
response ) return Kick playerid ); //If the player clicks the second button
            
if( response )
            {
                new 
hashpass[129];
                
WP_Hash(hashpass,sizeof(hashpass),inputtext);
                if(!
strcmp(hashpassPlayerInfo[playerid][pPass], false))  //Compares the inputtext to the player's pass, pPass.
                
{
                    
mysql_format(mysqlquerysizeof(query), "SELECT * FROM `users` WHERE `Name` = '%s' AND `Pass` = '%e'" GetName(playerid), hashpass);
                    
mysql_tquery(mysqlquery"OnLogin""i"playerid);
                    
TogglePlayerSpectating(playeridfalse);
                    
SetTimerEx("UnsetFirstSpawn"5000false"i"playerid); //We're using this for other purposes, to fix a bug in skin selection (OnPlayerRequestClass)
                
}
                else
                {
                    
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT,"Login","You have entered an incorrect password.\nType your password below to login.","Login","Quit"); //If the player has entered an invalid password, he's prompted to retype his password
                
}
                return 
1;
            }
        }
     }
     return 
1;
}
forward OnRegisteration(playerid);
public 
OnRegisteration(playerid) {
    new 
rowsfields;
    
cache_get_data(rowsfieldsmysql);
    if(
rows) {
        
PlayerInfo[playerid][UID] = cache_get_field_content_int(0"UID");
        
Logged[playerid] = 1;
        
SpawnPlayer(playerid);
    }
    return 
1;
}
forward OnLogin(playerid);
public 
OnLogin(playerid) {
    new 
rowsfields;
    
cache_get_data(rowsfields);
    if(
rows)
    {
        
PlayerInfo[playerid][UID] = cache_get_field_content_int(0"UID");
        
PlayerInfo[playerid][pAdmin] = cache_get_field_content_int(0"Admin");
        
PlayerInfo[playerid][pKills] = cache_get_field_content_int(0"Kills");
        
PlayerInfo[playerid][pDeaths] = cache_get_field_content_int(0"Deaths");
        
PlayerInfo[playerid][pBanned] = cache_get_field_content_int(0"IsBanned");
        
SpawnPlayer(playerid);
        
Loggedplayerid ] = 1;
        
GivePlayerCash(playeridPlayerInfo[playerid][pCash]);
        
SetSpawnInfo(playerid0PlayerInfo[playerid][pSkin], PlayerInfo[playerid][posX], PlayerInfo[playerid][posY], PlayerInfo[playerid][posZ], 1.0, -1, -1, -1, -1, -1, -1);
        
SendMessage(playerid"Succesfully logged in!");
    }
    else
    {
         
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_PASSWORD"Login""It seems that the password you have entered is incorrect.\nPlease enter a correct one.\n""Login""Quit");
    }
    return 
1;

I don't see anything wrong.. please help, and it compiles with no errors.
Reply
#2

bump
Reply
#3

Show the debug log...
It is created in server directory when you use mysql_debug or mysql_log depending on what version you use..
If u dont know how to create debug log then tell us the mysql version u use
And also make sure that mysql database is online at time the server is running...
Reply
#4

The size of your save query may not be big enough. Check it before you change it though, I'm on my phone right now and can't check .
Reply
#5

Quote:
Originally Posted by BroZeus
Посмотреть сообщение
Show the debug log...
It is created in server directory when you use mysql_debug or mysql_log depending on what version you use..
If u dont know how to create debug log then tell us the mysql version u use
And also make sure that mysql database is online at time the server is running...
i'm using the latest R39-2

Quote:
Originally Posted by DanishHaq
Посмотреть сообщение
The size of your save query may not be big enough. Check it before you change it though, I'm on my phone right now and can't check .
I'll test it later, can't right now

mysql_log.txt
NOTES: i noticed some queries has EXACTLY 64 CHARACTERS
Код:
[16:55:27] [DEBUG] mysql_errno - connection: 1
[16:55:27] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[16:55:27] [DEBUG] CMySQLConnection::Connect - connection was successful
[16:55:27] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[16:55:27] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[16:55:27] [DEBUG] CMySQLConnection::Connect - connection was successful
[16:55:27] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[16:55:27] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[16:55:27] [DEBUG] CMySQLConnection::Connect - connection was successful
[16:55:27] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[17:01:22] [DEBUG] mysql_format - connection: 1, len: 128, format: "SELECT `Pass`,`UID` FROM `users` WHERE `Name` = '%s'"
[17:01:22] [DEBUG] mysql_tquery - connection: 1, query: "SELECT `Pass`,`UID` FROM `users` WHERE `Name` = '[PL]NatsuDragne", callback: "OnConnection", format: "i"
[17:01:22] [DEBUG] CMySQLQuery::Execute[OnConnection] - starting query execution
[17:01:22] [DEBUG] CMySQLQuery::Execute[OnConnection] - query was successfully executed within 0.449 milliseconds
[17:01:22] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[17:01:22] [DEBUG] Calling callback "OnConnection"..
[17:01:22] [DEBUG] cache_get_data - connection: 1
[17:01:22] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[17:01:36] [DEBUG] mysql_format - connection: 1, len: 144, format: "INSERT INTO `users` (Name, Pass, IP) VALUES ('%s', '%e', '%s')"
[17:01:36] [DEBUG] mysql_tquery - connection: 1, query: "INSERT INTO `users` (Name, Pass, IP) VALUES ('[PL]NatsuDragneel'", callback: "OnRegisteration", format: "i"
[17:01:36] [DEBUG] CMySQLQuery::Execute[OnRegisteration] - starting query execution
[17:01:36] [DEBUG] CMySQLQuery::Execute[OnRegisteration] - query was successfully executed within 85.252 milliseconds
[17:01:36] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[17:01:36] [DEBUG] Calling callback "OnRegisteration"..
[17:01:36] [DEBUG] cache_get_data - connection: 1
[17:01:36] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[17:02:01] [DEBUG] mysql_format - connection: 1, len: 256, format: "UPDATE `users` SET `PosX` = '%f', `PosY`='%f',`PosZ`='%f',`Admin`='%d',`Cash`='%d',`Kills`='%d',`Deaths`='%d',`Skin`='%d',`IsBan..."
[17:02:01] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `users` SET `PosX` = '1647.466', `PosY`='-2247.993',`PosZ", callback: "(null)", format: "(null)"
[17:02:01] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[17:02:01] [DEBUG] CMySQLQuery::Execute[] - query was successfully executed within 0.456 milliseconds
[17:02:01] [DEBUG] CMySQLQuery::Execute[] - no callback specified, skipping result saving
[22:41:25] [DEBUG] mysql_format - connection: 1, len: 128, format: "SELECT `Pass`,`UID` FROM `users` WHERE `Name` = '%s'"
[22:41:25] [DEBUG] mysql_tquery - connection: 1, query: "SELECT `Pass`,`UID` FROM `users` WHERE `Name` = 'delta'", callback: "OnConnection", format: "i"
[22:41:25] [DEBUG] CMySQLQuery::Execute[OnConnection] - starting query execution
[22:41:25] [DEBUG] CMySQLQuery::Execute[OnConnection] - query was successfully executed within 0.408 milliseconds
[22:41:25] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[22:41:25] [DEBUG] Calling callback "OnConnection"..
[22:41:25] [DEBUG] cache_get_data - connection: 1
[22:41:25] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[22:41:31] [DEBUG] mysql_format - connection: 1, len: 144, format: "INSERT INTO `users` (Name, Pass, IP) VALUES ('%s', '%e', '%s')"
[22:41:31] [DEBUG] mysql_tquery - connection: 1, query: "INSERT INTO `users` (Name, Pass, IP) VALUES ('delta', '', '186.1", callback: "OnRegisteration", format: "i"
[22:41:31] [DEBUG] CMySQLQuery::Execute[OnRegisteration] - starting query execution
[22:41:31] [DEBUG] CMySQLQuery::Execute[OnRegisteration] - query was successfully executed within 25.89 milliseconds
[22:41:31] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[22:41:31] [DEBUG] Calling callback "OnRegisteration"..
[22:41:31] [DEBUG] cache_get_data - connection: 1
[22:41:31] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[22:42:44] [DEBUG] mysql_format - connection: 1, len: 256, format: "UPDATE `users` SET `PosX` = '%f', `PosY`='%f',`PosZ`='%f',`Admin`='%d',`Cash`='%d',`Kills`='%d',`Deaths`='%d',`Skin`='%d',`IsBan..."
[22:42:44] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `users` SET `PosX` = '-1511.036', `PosY`='-493.629',`PosZ", callback: "(null)", format: "(null)"
[22:42:44] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[22:42:44] [DEBUG] CMySQLQuery::Execute[] - query was successfully executed within 0.201 milliseconds
[22:42:44] [DEBUG] CMySQLQuery::Execute[] - no callback specified, skipping result saving
[22:42:45] [DEBUG] mysql_format - connection: 1, len: 128, format: "SELECT `Pass`,`UID` FROM `users` WHERE `Name` = '%s'"
[22:42:45] [DEBUG] mysql_tquery - connection: 1, query: "SELECT `Pass`,`UID` FROM `users` WHERE `Name` = '145891458'", callback: "OnConnection", format: "i"
[22:42:45] [DEBUG] CMySQLQuery::Execute[OnConnection] - starting query execution
[22:42:45] [DEBUG] CMySQLQuery::Execute[OnConnection] - query was successfully executed within 0.200 milliseconds
[22:42:45] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[22:42:45] [DEBUG] Calling callback "OnConnection"..
[22:42:45] [DEBUG] cache_get_data - connection: 1
[22:42:45] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[22:42:51] [DEBUG] mysql_format - connection: 1, len: 144, format: "INSERT INTO `users` (Name, Pass, IP) VALUES ('%s', '%e', '%s')"
[22:42:51] [DEBUG] mysql_tquery - connection: 1, query: "INSERT INTO `users` (Name, Pass, IP) VALUES ('145891458', '', '2", callback: "OnRegisteration", format: "i"
[22:42:51] [DEBUG] CMySQLQuery::Execute[OnRegisteration] - starting query execution
[22:42:51] [DEBUG] CMySQLQuery::Execute[OnRegisteration] - query was successfully executed within 47.411 milliseconds
[22:42:51] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[22:42:51] [DEBUG] Calling callback "OnRegisteration"..
[22:42:51] [DEBUG] cache_get_data - connection: 1
[22:42:51] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[22:44:14] [DEBUG] mysql_format - connection: 1, len: 256, format: "UPDATE `users` SET `PosX` = '%f', `PosY`='%f',`PosZ`='%f',`Admin`='%d',`Cash`='%d',`Kills`='%d',`Deaths`='%d',`Skin`='%d',`IsBan..."
[22:44:14] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `users` SET `PosX` = '1782.181', `PosY`='1169.888',`PosZ`", callback: "(null)", format: "(null)"
[22:44:14] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[22:44:14] [DEBUG] CMySQLQuery::Execute[] - query was successfully executed within 0.309 milliseconds
[22:44:14] [DEBUG] CMySQLQuery::Execute[] - no callback specified, skipping result saving
[09:53:30] [DEBUG] mysql_format - connection: 1, len: 128, format: "SELECT `Pass`,`UID` FROM `users` WHERE `Name` = '%s'"
[09:53:30] [DEBUG] mysql_tquery - connection: 1, query: "SELECT `Pass`,`UID` FROM `users` WHERE `Name` = '[PPs]Natsu'", callback: "OnConnection", format: "i"
[09:53:30] [DEBUG] CMySQLQuery::Execute[OnConnection] - starting query execution
[09:53:30] [DEBUG] CMySQLQuery::Execute[OnConnection] - query was successfully executed within 1.364 milliseconds
[09:53:30] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[09:53:30] [DEBUG] Calling callback "OnConnection"..
[09:53:30] [DEBUG] cache_get_data - connection: 1
[09:53:30] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[09:53:34] [DEBUG] mysql_format - connection: 1, len: 144, format: "INSERT INTO `users` (Name, Pass, IP) VALUES ('%s', '%e', '%s')"
[09:53:34] [DEBUG] mysql_tquery - connection: 1, query: "INSERT INTO `users` (Name, Pass, IP) VALUES ('[PPs]Natsu', '', '", callback: "OnRegisteration", format: "i"
[09:53:34] [DEBUG] CMySQLQuery::Execute[OnRegisteration] - starting query execution
[09:53:34] [DEBUG] CMySQLQuery::Execute[OnRegisteration] - query was successfully executed within 108.334 milliseconds
[09:53:34] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[09:53:34] [DEBUG] Calling callback "OnRegisteration"..
[09:53:34] [DEBUG] cache_get_data - connection: 1
[09:53:34] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[09:54:32] [DEBUG] mysql_format - connection: 1, len: 256, format: "UPDATE `users` SET `PosX` = '%f', `PosY`='%f',`PosZ`='%f',`Admin`='%d',`Cash`='%d',`Kills`='%d',`Deaths`='%d',`Skin`='%d',`IsBan..."
[09:54:32] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `users` SET `PosX` = '-1419.34', `PosY`='-304.152',`PosZ`", callback: "(null)", format: "(null)"
[09:54:32] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[09:54:32] [DEBUG] CMySQLQuery::Execute[] - query was successfully executed within 0.273 milliseconds
[09:54:32] [DEBUG] CMySQLQuery::Execute[] - no callback specified, skipping result saving
Reply
#6

mysql_tquery(mysql, query, "", "");

Maybe this will help.
Reply
#7

On your OnGameModeInit Call back put the following line on top
mysql_debug(1);

After putting htis compile your script run ur game mode enter the game then leave it
And then go to server directory and look for a txt file named Debug
Open it copy its content and show us here
Reply
#8

There's no mysql_debug in r33 and above
and i've put in game mode init
mysql_log(LOG_ERROR | LOG_WARNING | LOG_DEBUG);
Reply
#9

i downloaded the latest version just now and i saw there is...
can u give the link to the version u using?
Or give me ur skype or come on IRC u know which channel..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)