Only Admins Can Use This Command -
SplinteX - 14.12.2013
Hello!
I am a bit new at scripting and I am still learning,and I need help with admin commands.When I type some admin command for example /ban and I am not admin on server I am player without admin level it says Usage: /ban [ID] [REASON] ,like this :

.I would like that only admins could see Usage of the command,not every player without admin level.So i would like it when player without admin level type /ban it should say Only Admins Can Use This Command ,like this :
Thanks in advance!
Re: Only Admins Can Use This Command -
rappy93 - 14.12.2013
I'm gonna show you my /kick command. Maybe you'll understand something.
pawn Код:
if(strcmp(cmd, "/akick", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /akick [playerid/PartOfName] [reason]");
return 1;
}
giveplayerid = ReturnUser(tmp);
if (PlayerInfo[playerid][pAdministrator] >= 1) // This is the condition of being an admin.
{
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /akick [playerid/PartOfName] [reason]");
return 1;
}
Kick(playerid);
}
}
}
}
}
Re: Only Admins Can Use This Command -
SilentSoul - 14.12.2013
First you should have an admin system and saving stats to save your admin variable stats , also you need some plugins and includes (ZCMD- command processoring) which will help you creating this , once you done the admin enum you can check if the player who typed the command is an admin or not , and to get the correct usage of the command you need to use
sscanf read more about that you need also to use a saving stats like (y_ini , MySQL , SQlite,and so on..) search for those saving player data processors and once you got that , try to search for tutorials on
Tutorial section.
PS: If you don't want to use all what i said and use this command as rcon admin simply you can do this , but you need to download sscanf first !
pawn Код:
CMD:ban(playerid, params[])
{
new id, reason[28];//here we declay a new variables , id is the player we want to ban him , reason is the reason of his ban
if(!IsPlayerAdmin(playerid)) SendClientMessageToAll(0xFF0000FF, "Error you need to be an admin to use this command");//here we are goning to check if the player rcon admin or not
else if(sscanf(params, "ds[28]", id, reason))SendClientMessage(playerid,-1,"{FF0000}System Usage: {FAF5F5}/ban [playerid] [reason]");//d is used for integer , s[28] means string with max letters 28 !
Ban(id);//here we are going to ban the player , you need to send client message with the reason , read more about formating strings!
return 1;
}
Re: Only Admins Can Use This Command -
StuartD - 14.12.2013
pawn Код:
CMD:test(playerid, params[])
{
if(pInfo[playerid][AdminLevel] < 5) return SendClientMessage(playerid, -1, "Error, You can't use this command");
// rest of the command
return 1;
}
Just change the:
pInfo[playerid][AdminLevel] bit with your Admin Information stuff and also change < 5 to what ever level you want to use your command.