Help Making Admin Command
#1

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

add if(IsPlayerAdmin(playerid))
in front of it.
Reply
#3

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

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
}
}
Reply
#5

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
Reply
#6

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.
Reply
#7

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 .
Reply
#8

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.
Reply
#9

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.");
}
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)