Admin restrict a command -
Fadel - 27.05.2013
I'm new to scripting and I want to know how to restrict a cmd.
In our roleplay server we got admin ranks. 1,2,3,4,1337,1338,99999
I want to restrict a cmd for a lvl 4+ admins. How to do that?
Note: I don't want a code that checks the player if he is a RCON admin. I just want a script to restrict for IG admins lvl 4+. Not RCON admins.
Re: Admin restrict a command -
mahdi499 - 27.05.2013
Well i'll predict your script
pawn Код:
If(PlayerInfo[playerid][pAdmin] >= 4)
{
//Code
}
Re: Admin restrict a command -
Fadel - 27.05.2013
What is that? Where to put the cmd? Where is the error text?
Re: Admin restrict a command -
Kurzalewski - 27.05.2013
It would've been nice if you provided the admin system you're using, but still, the logic works this way:
- Player issues a command
- You check his level
- If it's 4 or bigger than 4, success
- If his level is less than 4 you display your error message
Код:
if(playerinfo[playerid][alevel] >= 4)
{
// Success....
}
else if(playerinfo[playerid][alevel] < 4)
{
// Something like "You can't use the command specified."
}
Re: Admin restrict a command -
Fadel - 27.05.2013
Aigh't explained well, but can you show me the coding of let's say I wanna restrict the cmd. /kick to a level 2 admin. Because it is very hard to understand your example.
Re: Admin restrict a command -
Smokkr - 27.05.2013
Quote:
pawn Код:
if(playerinfo[playerid][alevel] >= 2) //This is admin level required to use an command. { // Success.... } else if(playerinfo[playerid][alevel] < 2) //That command can be used only by admin level 2+ { // Something like "You can't use the command specified." }
|
-Edited from Kurzalewski's example.
Re: Admin restrict a command -
Fadel - 27.05.2013
Where to I put the command?
Re: Admin restrict a command -
Smokkr - 27.05.2013
To "/kick" command, as you said.
Re: Admin restrict a command -
Fadel - 27.05.2013
Yes, but where do I put " /kick " in those codeS? I don't see you typing /kick in between them.
Re: Admin restrict a command -
Smokkr - 27.05.2013
Here you are a working command:
pawn Код:
CMD:kick(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 2)
{
new str[128], reason[64], targetid;
if(sscanf(params,"us", targetid, reason)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /kick [Player ID] [Reason]");
{
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "SERVER: Player not connected");
SendClientMessageToAll(COLOR_RED, str);
Kick(targetid);
}
}
else SendClientMessage(playerid, COLOR_RED, "You do not have access to this command!");
return 1;
}
NOTE: Make sure that you have sscanf and zcmd includes.
Define this on top of your script:
pawn Код:
#define C_WHITE 0xFFFFFFFF
#define COLOR_RED 0xFF0000FF