Admin Duty
#6

Replace with this, for having more space of your script and more understandable.
Код:
CMD:adminduty(playerid)
{
    if(!PlayerInfo[playerid][Level] && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOUR_BLUE, "You're not an admin!");
    static str[64];
    adminDuty[playerid] = !adminDuty[playerid];
    SetPlayerHealth(playerid, adminDuty[playerid] ? 9999 : 100);
    SetPlayerColor(playerid, COLOUR_BLUE);
    SetPlayerSkin(playerid, 294);

    format(string, sizeof(string), "%s is now %s Duty!", GetPlayerNameEx(playerid), adminDuty[playerid] ? "on" : "off");
    SendClientMessageToAll(COLOUR_BLUE, string);
    format(string, sizeof(string), "You are now %s duty!", adminDuty[playerid] ? "on" : "off");
    SendClientMessage(playerid, COLOUR_BLUE, string);
    return 1;
}
There are some issues I fixed for you.

if(PlayerInfo[playerid][Level] >=1 || IsPlayerAdmin(playerid)) You are determing a player if they are admin OR level >= 1, for pLevel, just using PlayerInfo[playerid][Level] to check if they are set

The rest coding you should use conditional operator to do that for less code, and more performance.

Код:
adminDuty[playerid] ? 9999 : 100 // returns a Boolean

=

if(AdminDuty[playerid] == true)
{
     SetPlayerHealth(playerid, 9999);
} else {
     SetPlayerHealth(playerid, 100);
}
Reply


Messages In This Thread
Admin Duty - by KyNe - 19.12.2017, 07:58
Re: Admin Duty - by RogueDrifter - 19.12.2017, 08:21
Re: Admin Duty - by KyNe - 19.12.2017, 08:23
Re: Admin Duty - by RogueDrifter - 19.12.2017, 08:26
Re: Admin Duty - by KyNe - 19.12.2017, 08:58
Re: Admin Duty - by 0x88 - 19.12.2017, 09:00
Re: Admin Duty - by Argument - 19.12.2017, 10:10
Re: Admin Duty - by jasperschellekens - 19.12.2017, 10:27

Forum Jump:


Users browsing this thread: 1 Guest(s)