How to make commands just work for admins
#1

I Want to know how to make CMDS But just work for admin
So when any normal player use the admin cmd it says "You are not an admin"

I Want command like Admin Aduty
So when admin type /aduty it says " [ADMIN NAME] is on admin duty, /report for assistance

Help me please
Thanks.
Reply
#2

Here's an example using RCON & zcmd.

pawn Код:
new AdminDuty[MAX_PLAYERS]; //top of the script.

public OnPlayerDisconnect(playerid,reason)
{
    AdminDuty[playerid]=0; //resetting it so random people dont get the admin duty.
    return 1;
}

CMD:duty(playerid,params[])
{
    if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid,-1,"You need to be admin to use this command");
    else
    {
        new string[124]; //declaring new string size for formatting
        AdminDuty[playerid]=1; //setting them on duty
        format(string,sizeof(string),"%s is now on admin duty!",Name(playerid)); //formatting the string. Using Name as the specifier thing
        SendClientMessageToAll(-1,string); //sending it. -1 is basic white color.
    }
    return 1;
}

//the stock  i used to get the players name
stock Name(playerid)
{
    new nname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, nname, sizeof(nname));
    return nname;
}
Let me know if it doesn't work.
Reply
#3

C:\Documents and Settings\edku dreams\Desktop\MyScript\gamemodes\avt.pwn(331) : error 017: undefined symbol "AdminDuty"

C:\Documents and Settings\edku dreams\Desktop\MyScript\gamemodes\avt.pwn(331) : error 001: expected token: ";", but found "]"
C:\Documents and Settings\edku dreams\Desktop\MyScript\gamemodes\avt.pwn(331) : error 029: invalid expression, assumed zero
C:\Documents and Settings\edku dreams\Desktop\MyScript\gamemodes\avt.pwn(331) : fatal error 107: too many error messages on one line
Reply
#4

Try this:

CMD:duty(playerid,params[])
{
if(!IsPlayerAdmin(playerid))
{
new string[124]; //declaring new string size for formatting
AdminDuty[playerid]=1; //setting them on duty
format(string,sizeof(string),"%s is now on admin duty!",Name(playerid)); //formatting the string. Using Name as the specifier thing
SendClientMessageToAll(-1,string); //sending it. -1 is basic white color.
}
else
{
SendClientMessage(playerid,COLOR_RED,"ERROR:You need to be an admin");
}
return 1;
}

if that gets any errors, try adding a extra } on top of return 1;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)