SA-MP Forums Archive
MySQL Skin saving system. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL Skin saving system. (/showthread.php?tid=575755)



MySQL Skin saving system. - sscarface - 29.05.2015

Well, I need help because i am new in mysql scripting. I would be your thankful if you guyz help me.

I'm using.

PHP код:
enum _PSTATS
{
    
pLayaName[24],
    
pPassword[35],
    
pKills,
    
pDeaths,
    
pMoney,
    
pLevel
} 
PHP код:
stock SavePInfo(playerid)
{
    if(
GetPVarInt(playerid, "LoggedIN") == 1)
    {
        new
            
Query[600];
        
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `kills` = %d, `deaths` = %d, `money` = %d, `Level` = %d WHERE `user` = '%s'", // Also remember to update this...
        
PVar[playerid][pKills],
        
PVar[playerid][pDeaths],
        
GetPlayerMoney(playerid),
        
PVar[playerid][pLevel],
        
pName(playerid));
        
mysql_query(Query);
        
mysql_free_result();
        return 
1;
    }
    else return 
0;
} 
PHP код:
stock ResetPVars(playerid)
{
    
PVar[playerid][pLevel]         = 0;
    
PVar[playerid][pKills]         = 0;
    
PVar[playerid][pDeaths]     = 0;
    
PVar[playerid][pMoney]         = 0;
} 
Now, Help me how to script which save players skin when they relog. Thanks!


Re: MySQL Skin saving system. - J0sh... - 29.05.2015

PHP код:
 enum _PSTATS
{
    
pLayaName[24],
    
pPassword[35],
    
pKills,
    
pDeaths,
    
pMoney,
    
pLevel,
    
pSkin
} 
stock SavePInfo(playerid)
{
    if(
GetPVarInt(playerid, "LoggedIN") == 1)
    {        
       
PVar[playerid][pSkin] = GetPlayerSkin(playerid);
       new
            
Query[600];
        
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `kills` = %d, `deaths` = %d, `money` = %d, `Level` = %d, `Skin` = %d WHERE `user` = '%s'", // Also remember to update this...
        
PVar[playerid][pKills],
        
PVar[playerid][pDeaths],
        
GetPlayerMoney(playerid),
        
PVar[playerid][pLevel],
        
PVar[playerid][pSkin],
        
pName(playerid));
        
mysql_query(Query);
        
mysql_free_result();
        return 
1;
    }
    else return 
0;
}
stock ResetPVars(playerid)
{
    
PVar[playerid][pLevel]         = 0;
    
PVar[playerid][pKills]         = 0;
    
PVar[playerid][pDeaths]     = 0;
    
PVar[playerid][pMoney]         = 0;
    
PVar[playerid][pSkin]         = 0;
} 
That should be correct.

By the way, if you're new to MySQL, you should really upgrade to the latest.


Re: MySQL Skin saving system. - sscarface - 30.05.2015

Link of new mysql?


Re: MySQL Skin saving system. - sscarface - 30.05.2015

It doesn't work. Compile fine but it doesn't saving skin


Re: MySQL Skin saving system. - BroZeus - 30.05.2015

Do you call those stocks OnPlayerDisconnect?
If not then the code will be like this :
PHP код:
public OnPlayerDisconnect(playerid, reason)
{
     
SavePInfo(playerid);
     
ResetPVars(playerid);
     return 
1;
} 
If this doesn't work then in OnGameModeInit put this line :
Код:
mysql_log(LOG_ALL);
And then login to server and then see the mysql log which is created in the server directory, if any error occurred during the execution of query it should be stored in those logs.