OnPlayerRequestClass save
#1

I need help guys. I want to save the skin of the player directly to MySQL after they choose their desired skin on onPlayerRequestClass but I don't know how and what the correct format script is.

This is script for my command cmd:/skin, you might need this for more info.
PHP код:
format(gsQuery,sizeof(gsQuery),"UPDATE `accounts` SET `SavedSkin` = '%d'  WHERE `Key` = '%d'",skinid,PlayerInfoplayerid ][ AccID ]);
mysql_querygsQueryTHREAD_NONEplayerid );
format(gsQuery,sizeof(gsQuery),"UPDATE `accounts` SET `IsSavedSkin` = '1'  WHERE `Key` = '%d'",skinid,PlayerInfoplayerid ][ AccID ]);
mysql_querygsQueryTHREAD_NONEplayerid );
SetPlayerSkin(playeridskinid);
PlayerInfoplayerid ][ SavedSkin ] = skinid;
PlayerInfoplayerid ][ IsSavedSkin ] = 1
Reply
#2

Execute that query in OnPlayerRequestClass and when the player connects later, use SetSpawnInfo and SpawnPlayer to bypass the skin choosing process.
Reply
#3

Thanks for the tips @Freaksken

But I solved it using this. Putting it under OnPlayerRequestSpawn and adding
Код:
skinid = GetPlayerSkin(playerid);

PHP код:
public OnPlayerRequestSpawnplayerid )
{
    new 
skinid;
    
format(gsQuery,sizeof(gsQuery),"UPDATE `accounts` SET `SavedSkin` = '%d'  WHERE `Key` = '%d'",skinid,PlayerInfoplayerid ][ AccID ]);
    
mysql_querygsQueryTHREAD_NONEplayerid );
    
format(gsQuery,sizeof(gsQuery),"UPDATE `accounts` SET `IsSavedSkin` = '1'  WHERE `Key` = '%d'",skinid,PlayerInfoplayerid ][ AccID ]);
    
mysql_querygsQueryTHREAD_NONEplayerid );
    
skinid GetPlayerSkin(playerid);
    
SetPlayerSkin(playeridskinid);
    
PlayerInfoplayerid ][ SavedSkin ] = skinid;
    
PlayerInfoplayerid ][ IsSavedSkin ] = 1;
    return ( 
);

Reply
#4

You might want to double check this line...:
pawn Код:
format(gsQuery,sizeof(gsQuery),"UPDATE `accounts` SET `IsSavedSkin` = '1'  WHERE `Key` = '%d'",skinid,PlayerInfo[ playerid ][ AccID ]);
Reply
#5

It looks like the skin are not still saving, after hitting Spawn it shoul've changed the value to the skin id of the player which he chooses and IsSavedSkin should be 1. Am I missing something?



@thereshold I noticed the skinid parameter which is not needed right?

So I've managed to fix it by doing this. But the problem was when i'm in a different world expect 0 and I died there. It keeps spawning me as CJ skin

PHP код:
    new skinidIsSaved 1;
    
skinid GetPlayerSkin(playerid);
    
SetPlayerSkin(playeridskinid);
    
PlayerInfoplayerid ][ SavedSkin ] = skinid;
    
PlayerInfoplayerid ][ IsSavedSkin ] = IsSaved;
    
format(gsQuery,sizeof(gsQuery),"UPDATE `accounts` SET `SavedSkin` = '%d'  WHERE `Key` = '%d'",skinid,PlayerInfoplayerid ][ AccID ]);
    
mysql_querygsQueryTHREAD_NONEplayerid );
    
format(gsQuery,sizeof(gsQuery),"UPDATE `accounts` SET `IsSavedSkin` = '%d'  WHERE `Key` = '%d'",IsSaved,PlayerInfoplayerid ][ AccID ]);
    
mysql_querygsQueryTHREAD_NONEplayerid ); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)