SA-MP Forums Archive
Help Making Admin Command - 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: Help Making Admin Command (/showthread.php?tid=289078)



Help Making Admin Command - Warren - 10.10.2011

Hello, I have this if (!strcmp(cmdtext, "/weapons", true)) , I need the cmd to be for RCON admins only, any help please?


Re: Help Making Admin Command - TheLazySloth - 10.10.2011

add if(IsPlayerAdmin(playerid))
in front of it.


Re: Help Making Admin Command - Warren - 10.10.2011

Thankyou, how would i add a message like "You must be RCON Admin to use that command"


Re: Help Making Admin Command - TheLazySloth - 10.10.2011

if(!IsPlayerAdmin(playerid)) // if not an rcon admin
{
SendClientMessage(playerid, -1, "You must be RCON Admin to use that command!"); //send message
} else {
if (!strcmp(cmdtext, "/weapons", true)) // checks if player typed /weapons
{
// blahblahblah
}
}


Edit: Aha, mmm it might be better this way....

if (!strcmp(cmdtext, "/weapons", true)) // checks if player typed /weapons
{
if(!IsPlayerAdmin(playerid)) // if not an rcon admin
{
SendClientMessage(playerid, -1, "You must be RCON Admin to use that command!"); //send message
} else {
// blahblahblah
}
}


Re: Help Making Admin Command - Warren - 10.10.2011

I have this

public OnPlayerCommandText(playerid, cmdtext[])
{
if(IsPlayerAdmin(playerid))if (!strcmp(cmdtext, "/weapons", true))
if (!strcmp(cmdtext, "/weapons", true)) // checks if player typed /weapons
{
if(!IsPlayerAdmin(playerid)) // if not an rcon admin
{
SendClientMessage(playerid, -1, "You must be RCON Admin to use that command!"); //send message
} else {
// blahblahblah


But it dont work it just makes the if(IsPlayerAdmin(playerid)) pointless


Re: Help Making Admin Command - GrimR - 10.10.2011

Use this inside of the strcmp:

pawn Код:
if (strcmp())
{
  if (!IsPlayerAdmin(playerid)) { return // message here }
}
The strcmp being your /weapon and if not RCON admin you just return SendClientMessage() that they are not RCON admin and it will exit the function so no more processing is done, hence why it is only one line.


Re: Help Making Admin Command - [HiC]TheKiller - 10.10.2011

Just do this

pawn Код:
if(!strcmp(cmdtext, "/weapons", true) && IsPlayerAdmin(playerid))
That way, the command won't be called if the player is not admin .


Re: Help Making Admin Command - GrimR - 10.10.2011

I think the OP wants to notify the user though, where the example I provided will do so with one line, no need for else or brackets on multiple lines.


Re: Help Making Admin Command - grand.Theft.Otto - 10.10.2011

pawn Код:
if (strcmp(cmdtext, "/weapons", true, 8))
{
    if(IsPlayerAdmin(playerid))
    {
        // weapon stuff here
        return 1;
    } else return SendClientMessage(playerid,-1,"You Must Be An RCON Administrator To Use This Command.");
}



Re: Help Making Admin Command - TheLazySloth - 10.10.2011

All of these will work, can we stop posting code now?