SA-MP Forums Archive
How to make commands just work for admins - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to make commands just work for admins (/showthread.php?tid=451561)



How to make commands just work for admins - TomMax - 17.07.2013

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.


Re: How to make commands just work for admins - DobbysGamertag - 17.07.2013

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.


Re: How to make commands just work for admins - TomMax - 17.07.2013

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


Re: How to make commands just work for admins - Calvingreen17 - 18.07.2013

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;