21.05.2016, 19:55
How is it not shown? I re-looked the code in case I missed anything but the code is fine.
As for the toggling, an array to store whether the player is in duty or not is needed.
As for the toggling, an array to store whether the player is in duty or not is needed.
PHP код:
// global:
new gPlayer_OnDuty[MAX_PLAYERS];
// OnPlayerConnect:
gPlayer_Duty[playerid] = 0;
// unless you want the player to be automatically on duty or even after logging, set them to 1 where needed
CMD:aod(pid, params[])
{
if(!IsPlayerAdmin(pid)) return SCM(pid, COLOR_RED, ADMIN_MESSAGE);
new string[65], name[MAX_PLAYER_NAME];
GetPlayerName(pid, name, MAX_PLAYER_NAME);
if (!gPlayer_Duty[playerid]) // not on duty
{
SPH(pid, 400);
SetPlayerArmour(pid, 100);
format(string, sizeof string, "Admin %s is now on duty. /w him for help.", name);
SCMToAll(COLOR_LIME, string);
gPlayer_Duty[playerid] = 1; // set them on duty
}
else // on duty
{
// code for health/armour..
format(string, sizeof string, "Admin %s is no longer on duty.", name);
SCMToAll(COLOR_LIME, string);
gPlayer_Duty[playerid] = 0;
}
return 1;
}