Saving player skin onduty/offduty
#1

Hi everyone.
I have some job scripts which requires the player to go on duty.
The problem is, that i do not know how to save and restore the players skin.
Because when you go on garbage collector duty, your skin gets changed.
When you go off-duty it now gives you a skin and a free skin change.
Does anyone have an example for me on how to save and restore it?

code:
PHP код:
if(PlayerInfo[playerid][TrashDuty] == 0)
            {
                
PlayerInfo[playerid][TrashDuty] = 1;
                
SetPlayerSkin(playerid50);
                
SendClientMessage(playeridGREEN"You are now on garbage collector duty.");
              }
              else
              {
                  
PlayerInfo[playerid][TrashDuty] = 0;
                
SetPlayerSkin(playerid3);
                
PlayerInfo[playerid][FreeSkin] = 1;
                
SendClientMessage(playeridGREEN"You are not on garbage collector duty anymore. You can change ur skin for free once by using /freeskin");
              } 
Reply
#2

Nevermind.
Reply
#3

do a variable for playerskin and save skin in there like this
Код:
if(PlayerInfo[playerid][TrashDuty] == 0) 
            { 
                PlayerInfo[playerid][TrashDuty] = 1; 
                PlayerInfo[playerid][oldskin] = GetPlayerSkin(playerid); //addedline
                SetPlayerSkin(playerid, 50); 
                SendClientMessage(playerid, GREEN, "You are now on garbage collector duty."); 
              } 
              else 
              { 
                  PlayerInfo[playerid][TrashDuty] = 0; 
                SetPlayerSkin(playerid, PlayerInfo[playerid][oldskin]); //changed line
                PlayerInfo[playerid][FreeSkin] = 1; 
                SendClientMessage(playerid, GREEN, "You are not on garbage collector duty anymore. You can change ur skin for free once by using /freeskin"); 
              }
Also just a friendly reminder, you code seems unalingned idk if it happened when you copied here but keeping it alingned helps a lot of stuff with not mixing codes to eachother
Reply
#4

Quote:
Originally Posted by grymtn
Посмотреть сообщение
do a variable for playerskin and save skin in there like this
Код:
if(PlayerInfo[playerid][TrashDuty] == 0) 
            { 
                PlayerInfo[playerid][TrashDuty] = 1; 
                PlayerInfo[playerid][oldskin] = GetPlayerSkin(playerid); //addedline
                SetPlayerSkin(playerid, 50); 
                SendClientMessage(playerid, GREEN, "You are now on garbage collector duty."); 
              } 
              else 
              { 
                  PlayerInfo[playerid][TrashDuty] = 0; 
                SetPlayerSkin(playerid, PlayerInfo[playerid][oldskin]); //changed line
                PlayerInfo[playerid][FreeSkin] = 1; 
                SendClientMessage(playerid, GREEN, "You are not on garbage collector duty anymore. You can change ur skin for free once by using /freeskin"); 
              }
Also just a friendly reminder, you code seems unalingned idk if it happened when you copied here but keeping it alingned helps a lot of stuff with not mixing codes to eachother
And how the server will get [oldskin] ?
Reply
#5

Код:
PlayerInfo[playerid][oldskin] = GetPlayerSkin(playerid);
This enum variable will save temporarily, if he wants to save it like a constant that will save out to like mysql or dini or y_ini or whatever he will have to add those variables in his save script.
Код:
SetPlayerSkin(playerid, PlayerInfo[playerid][oldskin]);
And this will load that skin enum back to player.
How hard is it to guess this
Reply
#6

Uhmm lemme test it.
Reply
#7

Personally I use PVars for SetPlayerBacks (Such as entering paintball... ect).
PHP код:
if(PlayerInfo[playerid][TrashDuty] == 0) {
    
PlayerInfo[playerid][TrashDuty] = 1;
    
SetPVarInt(playerid"OldSkin"GetPlayerSkin(playerid) + 1); // +1 to avoid CJ skin.
       
SetPlayerSkin(playerid50);
      
SendClientMessage(playeridGREEN"You are now on garbage collector duty.");
} else {
     
PlayerInfo[playerid][TrashDuty] = 0;
     new 
oldskin GetPVarInt(playerid"OldSkin") - 1// -1 because the reason above.
     
DeletePVarInt(playerid"OldSkin");
    
SetPlayerSkin(playeridoldskin);
    
SendClientMessage(playeridGREEN"You are not on garbage collector duty anymore. You can change ur skin for free once by using /freeskin");

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)