19.12.2017, 09:00
Replace with this, for having more space of your script and more understandable.
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.
Код:
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; }
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); }