/aduty command - health not restoring.
#1

Hello i have made this for my admin script, so say if i have 50 health and i /aduty i get maximum health and when i become off duty my previous health (50) will be restored but actually when i become off duty my health set to 0 but i dont die..

here is my script, please describe what is problem,Thanks

pawn Код:
CMD:aduty(playerid, params[])
{

        if(pInfo[playerid][Adminlevel] < 1) return SendClientMessage(playerid, COLOR_RED, ""ERROR_MESSAGE"");
        if(aduty[playerid] == 0)
        {

       
        new Float:health;
        new Float:armour;
        SetPVarInt(playerid, "LastHealth", GetPlayerHealth(playerid, health));
        SetPVarInt(playerid, "LastArmour", GetPlayerArmour(playerid, armour));
        SCM(playerid, COLOR_HOTPINK,"* You Have Gone On Duty.");
        SetPlayerArmour(playerid, 9999999999999);
        SetPlayerHealth(playerid,0x7FB00000);
        aduty[playerid] =1;
        }
        else
        {
        SCM(playerid, COLOR_HOTPINK,"* You Have Gone Off Duty.");
        SetPlayerHealth(playerid, GetPVarInt(playerid, "LastHealth"));
        SetPlayerArmour(playerid, GetPVarInt(playerid, "LastArmour"));
        aduty[playerid] =0;
       
        }
       
        return 1;
}
Reply
#2

Want to explain this? ''SetPlayerHealth(playerid,0x7FB00000);''

- SetPlayerHealth(playerid,9999999999);
Reply
#3

nope you dont get me in my script my health is not restoring when i become off duty to previous health before using /aduty
Reply
#4

try to see my code in aduty and compare

PHP код:
CMD:aduty(playeridparams[])
{
    new 
str[126];
    if(
PlayerInfo[playerid][pAdmin] < 1) return SCM(playeridCOLOR_GRAD2NOTADMIN);
    if(
AdminDuty[playerid] != 1)
    {
        
AdminDutyCash[playerid] = PlayerInfo[playerid][pCash];
        
SetPlayerHealth(playerid,999999);
        
SetPlayerArmour(playerid,999999);
        if(
isnull(PlayerInfo[playerid][pAName])) return SCM(playerid, -1"You don't have an admin name.");
        
AdminDuty[playerid] = 1;
        
format(strsizeof(str), "%s (ID %i - %s) is now on duty as a level %i admin."PlayerInfo[playerid][pAName], playeridGetName(playerid), PlayerInfo[playerid][pAdmin]);
        
SCMToAdmins(-1str1);
        
SetPlayerName(playeridPlayerInfo[playerid][pAName]);
        
SCM(playerid, -1"You are now on duty as an admin, you do now have access to all of your commands.");
        
GetPlayerPos(playeridPlayerInfo[playerid][pAx], PlayerInfo[playerid][pAy], PlayerInfo[playerid][pAz]);
    }
    else
    {
        
TogglePlayerSpectating(playeridfalse);
        
SetCameraBehindPlayer(playerid);
        
AdminDuty[playerid] = 0;
        
SetSpawnInfo(playerid0PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pLastX], PlayerInfo[playerid][pLastY], PlayerInfo[playerid][pLastZ], 0000000);
        
SpawnPlayer(playerid);
        
SetPlayerInterior(playeridPlayerInfo[playerid][pInt]);
        
SetPlayerVirtualWorld(playeridPlayerInfo[playerid][pVW]);
        
SetPlayerScore(playerid,PlayerInfo[playerid][pLevel]);
        
SetPlayerHealth(playerid,PlayerInfo[playerid][pHealth]);
        
SetPlayerArmour(playerid,PlayerInfo[playerid][pArmour]);
        
SetPlayerName(playeridPlayerInfo[playerid][pName]);
        
//ResetPlayerMoney(playerid);
        //GiveDrichMoney(playerid, PlayerInfo[playerid][pCash]);
        
SetPlayerPos(playeridPlayerInfo[playerid][pAx], PlayerInfo[playerid][pAy], PlayerInfo[playerid][pAz]);
        
format(strsizeof(str), "%s (ID %i - %s) is now off admin duty."PlayerInfo[playerid][pAName], playeridGetName(playerid));
        
ABroadCast(-1str1);
        
PlayerInfo[playerid][pCash] = AdminDutyCash[playerid];
        
SCM(playerid, -1"You are now off duty as an admin and have only a limited access to your commands.");
        
spec[playerid] = -1;
    }
    return 
1;

Reply
#5

Explain.
Reply
#6

On top of your script add:
Код:
new pDutyHealth[MAX_PLAYERS];
new pDutyArmour[MAX_PLAYERS];
Then replace your command with this one:
Код:
CMD:aduty(playerid, params[])
{

        if(pInfo[playerid][Adminlevel] < 1) return SendClientMessage(playerid, COLOR_RED, ""ERROR_MESSAGE"");
        if(aduty[playerid] == 0)
        {
        new Float:dutyhp;
        new Float:dutyarmour;
        pDutyHealth[playerid] = GetPlayerHealth(playerid, dutyhp);
        pDutyArmour[playerid] = GetPlayerArmour(playerid, dutyarmour);
        SCM(playerid, COLOR_HOTPINK,"* You Have Gone On Duty.");
        SetPlayerArmour(playerid, 9999999999);
        SetPlayerHealth(playerid, 9999999999);
        aduty[playerid] =1;
        }
        else
        {
        SCM(playerid, COLOR_HOTPINK,"* You Have Gone Off Duty.");
        SetPlayerHealth(playerid, pDutyHealth[playerid]);
        SetPlayerArmour(playerid, pDutyArmour[playerid]);
        aduty[playerid] =0;
        }
        
        return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)