/aduty command - health not restoring. -
Anak - 27.06.2013
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;
}
Re: /aduty command - health not restoring. -
Akira297 - 27.06.2013
Want to explain this? ''SetPlayerHealth(playerid,0x7FB00000);''
- SetPlayerHealth(playerid,9999999999);
Re: /aduty command - health not restoring. -
Anak - 27.06.2013
nope you dont get me in my script my health is not restoring when i become off duty to previous health before using /aduty
Re: /aduty command - health not restoring. -
drichie - 27.06.2013
try to see my code in aduty and compare
PHP код:
CMD:aduty(playerid, params[])
{
new str[126];
if(PlayerInfo[playerid][pAdmin] < 1) return SCM(playerid, COLOR_GRAD2, NOTADMIN);
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(str, sizeof(str), "%s (ID %i - %s) is now on duty as a level %i admin.", PlayerInfo[playerid][pAName], playerid, GetName(playerid), PlayerInfo[playerid][pAdmin]);
SCMToAdmins(-1, str, 1);
SetPlayerName(playerid, PlayerInfo[playerid][pAName]);
SCM(playerid, -1, "You are now on duty as an admin, you do now have access to all of your commands.");
GetPlayerPos(playerid, PlayerInfo[playerid][pAx], PlayerInfo[playerid][pAy], PlayerInfo[playerid][pAz]);
}
else
{
TogglePlayerSpectating(playerid, false);
SetCameraBehindPlayer(playerid);
AdminDuty[playerid] = 0;
SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pLastX], PlayerInfo[playerid][pLastY], PlayerInfo[playerid][pLastZ], 0, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
SetPlayerInterior(playerid, PlayerInfo[playerid][pInt]);
SetPlayerVirtualWorld(playerid, PlayerInfo[playerid][pVW]);
SetPlayerScore(playerid,PlayerInfo[playerid][pLevel]);
SetPlayerHealth(playerid,PlayerInfo[playerid][pHealth]);
SetPlayerArmour(playerid,PlayerInfo[playerid][pArmour]);
SetPlayerName(playerid, PlayerInfo[playerid][pName]);
//ResetPlayerMoney(playerid);
//GiveDrichMoney(playerid, PlayerInfo[playerid][pCash]);
SetPlayerPos(playerid, PlayerInfo[playerid][pAx], PlayerInfo[playerid][pAy], PlayerInfo[playerid][pAz]);
format(str, sizeof(str), "%s (ID %i - %s) is now off admin duty.", PlayerInfo[playerid][pAName], playerid, GetName(playerid));
ABroadCast(-1, str, 1);
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;
}
Re: /aduty command - health not restoring. -
Anak - 27.06.2013
Explain.
Re: /aduty command - health not restoring. -
feartonyb - 27.06.2013
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;
}