02.11.2010, 05:21
After seeing quite a lot of people asking me about this i decided to make a tutorial for not only them but for every other person that has no clue how to.
Ok, lets get started.
Most you people have enums for storing items in one variable, well your going to need that, or some variable.
^^ like that (Enum's)
Single variables:
Now simply you can use any of those to create a admin command.
(In this instance ill use DCMD)
(Borrowed code of the wiki)
Making a heal command but only avaible for admins.
Thats plain and just for regular players. To simply make it for admins create a if statement and insert the variable.
E.G
^^ if the admin is level 3 then enable it
Insert it here
So your admin command should turn out to be like this:
To add a msg when the player uses the command without being admin create a else.
Ok, thats it. Now you should relise its simple!
Soz for awful editing in a rush D:
-Lorenc
Ok, lets get started.
Most you people have enums for storing items in one variable, well your going to need that, or some variable.
Code:
enum pInfo { pAdminLevel, } new PlayerInfo[MAX_PLAYERS][pInfo];
Single variables:
Code:
new IsAdmin[MAX_PLAYERS];
(In this instance ill use DCMD)
(Borrowed code of the wiki)
Making a heal command but only avaible for admins.
Code:
dcmd_heal(playerid, params[]) { new id; if (sscanf(params, "u", id)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/heal <playerid>\""); else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found"); else { SetPlayerHealth(id, 100.0); SendClientMessage(id, 0x00FF00AA, "You have been healed"); SendClientMessage(playerid, 0x00FF00AA, "Player healed"); } return 1; }
E.G
Code:
if(IsAdmin[playerid] == 3)
Insert it here
Code:
dcmd_heal(playerid, params[]) { //*** Here ***
Code:
dcmd_heal(playerid, params[]) { if(IsAdmin[playerid] == 3){ new id; if (sscanf(params, "u", id)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/heal <playerid>\""); else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found"); else { SetPlayerHealth(id, 100.0); SendClientMessage(id, 0x00FF00AA, "You have been healed"); SendClientMessage(playerid, 0x00FF00AA, "Player healed"); } } return 1; }
Code:
dcmd_heal(playerid, params[]) { if(IsAdmin[playerid] == 3){ new id; if (sscanf(params, "u", id)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/heal <playerid>\""); else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found"); else { SetPlayerHealth(id, 100.0); SendClientMessage(id, 0x00FF00AA, "You have been healed"); SendClientMessage(playerid, 0x00FF00AA, "Player healed"); } }else{ SendClientMessage(playerid, 0x00FF00AA, "Your not admin (LEVEL 3)"); } return 1; }
Soz for awful editing in a rush D:
-Lorenc