Save team
#1

How can i temperarily save a team, in otherwords i made this aduty command and i want to save the admin team and color and then restore it once he/she uses and /aduty command again and goes off duty...

PHP код:
CMD:adminduty(playerid, params[])
{
    if (
playerData[playerid][pd_AdminRank])
    {
        new 
message[MAX_STRING], playerName[MAX_PLAYER_NAME];
        
GetPlayerName(playerid, playerName, sizeof(playerName));
        if (!
playerData[playerid][pd_IsOnDuty])
        {
            
playerData[playerid][pd_IsOnDuty] = true;
            
format(message, sizeof(message), "[SERVER] %s %s(%i) is now on-duty.", GetStaffClassName(playerid), playerName, playerid);
              
SetPVarInt(playerid, "LastSkin", GetPlayerSkin(playerid));
            
GetPlayerHealth(playerid, aHealth[playerid]);
              
GetPlayerArmour(playerid, aArmour[playerid]);
            for (new 
i = 0; i<13; i++)
            {
                
GetPlayerWeaponData(playerid, i, pWeapon[playerid][i], pAmmo[playerid][i]);
            }
            
ResetPlayerWeapons(playerid);
            
SetPlayerSkinEx(playerid, SKIN_STAFF);
            
SetPlayerTeam(playerid, NO_TEAM);
            
SetPlayerColor(playerid, COLOR_ADMIN);
            
SetPlayerHealth(playerid, MAX_HEALTH_ADMINISTRATOR);
            
Update3DTextLabelText(t3dRankLabel[playerid], COLOR_ADMIN, "Staff");
            
playerData[playerid][pd_TeamId] = NO_TEAM;
            
GivePlayerWeaponEx(playerid, WEAPON_MINIGUN, MAX_WEAPON_AMMO);
        }
        else
        {
            
playerData[playerid][pd_IsOnDuty] = false;
            
format(message, sizeof(message), "[SERVER] %s %s(%i) is now off-duty.", GetStaffClassName(playerid), playerName, playerid);
               
ResetPlayerWeapons(playerid);
            
SetPlayerSkin(playerid, GetPVarInt(playerid, "LastSkin"));
            
SetPlayerHealth(playerid, aHealth[playerid]);
            
SetPlayerArmour(playerid, aArmour[playerid]);
            for(new 
i=0; i<13; i++)
            {
                
GivePlayerWeaponEx(playerid,pWeapon[playerid][i],pAmmo[playerid][i]);
            }
        
//    ForceClassSelection(playerid);
        //    SetPlayerHealth(playerid, 0.0);
        //    playerData[playerid][pd_Deaths] --;
        //    FirstSpawn[playerid] = 1;
        
}
        if (
pHasHelmet[playerid])
        {
            new const 
SKIN_ID = GetPlayerSkin(playerid);
            
SetPlayerAttachedObject(playerid, SLOT_PAO_HAT, 19108, BONE_HEAD, gHelmetOffsets[SKIN_ID][0], gHelmetOffsets[SKIN_ID][1], gHelmetOffsets[SKIN_ID][2], gHelmetOffsets[SKIN_ID][3], gHelmetOffsets[SKIN_ID][4], gHelmetOffsets[SKIN_ID][5], gHelmetOffsets[SKIN_ID][6], gHelmetOffsets[SKIN_ID][7], gHelmetOffsets[SKIN_ID][8]);
        }
        
SendClientMessageToAll(COLOR_SERVER, message);
    }
    else
    {
        
SendScreenMessage(playerid, LOCALE_MESSAGE_NOTAUTHORIZEDCOMMAND);
    }
    
    return 
1;
} 
Reply
#2

PHP код:
// on aduty
SetPVarInt(playerid, "my_Team", GetPlayerTeam(playerid));
// off aduty
SetPlayerTeam(playerid, GetPVarInt(playerid, "my_Team"));
DeletePVar(playerid, "my_Team"); 
Reply
#3

Quote:
Originally Posted by JaKe Elite
Посмотреть сообщение
PHP код:
// on aduty
SetPVarInt(playerid, "my_Team", GetPlayerTeam(playerid));
// off aduty
SetPlayerTeam(playerid, GetPVarInt(playerid, "my_Team"));
DeletePVar(playerid, "my_Team"); 
I tried that but it didn't work... This is how the teams are set so it should me like this?
PHP код:
    //SetPlayerTeam(playerid, playerData[playerid][pd_TeamId]);
SetPVarInt(playerid, "my_Team",playerData[playerid][pd_TeamId] );
// when they going off duty
SetPlayerTeam(playerid, GetPVarInt(playerid, "Team"));
DeletePVar(playerid, "my_Team"); 
Reply
#4

bump
Reply
#5

PHP код:
SetPVarInt(playerid, "my_Team",playerData[playerid][pd_TeamId] );
// when they going off duty
SetPlayerTeam(playerid, GetPVarInt(playerid, "my_Team"));
DeletePVar(playerid, "my_Team"); 
Reply
#6

Quote:
Originally Posted by Primes007
Посмотреть сообщение
PHP код:
SetPVarInt(playerid, "my_Team",playerData[playerid][pd_TeamId] );
// when they going off duty
SetPlayerTeam(playerid, GetPVarInt(playerid, "my_Team"));
DeletePVar(playerid, "my_Team"); 
didn't work, just want the command to work like this, once a player goes on duty it saves there weapons,health, armour , skin and team, and then the admin comes off duty it restore his/her health,armour,skin,weapons etc... but i don't what im doing wrong in my code
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)