Command only made for someone with a specify name
#1

Title.
Well, what I basicly want is a command, that only allows the guy with /THAT/ name to type the command
For example, if the guy's name is Carl_Johnson, he's able to type /cjskin and if he's not, he gets a message: 'You don't have acces to this command.'
Reply
#2

just add this in the top of your command ,
if(strcmp(name, "Carl_Johnson", true)) return SendClientMessage(playerid, -1, "You don't have access to this command!");

.. and 'name' would be the stored via GetPlayerName
Reply
#3

pawn Код:
if(strcmp(cmdtext, "/test", true) == 0)
    {
   
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    if(!strcmp(pName, "Carl_Johnson"))// if player name is Carl_Johnson
    {
   
    // code here
    }
    else
    {
    SendClientMessage(playerid,0xAFAFAFAA,"you are not carl_johnson!");
    }
    return 1;
    }
Reply
#4

pawn Код:
if(strcmp(name, "Carl_Johnson", true))
{
    GameTextForPlayer(playerid, "~r~You ~g~are ~r~not ~g~Shockey!", 2000, 3);
    return 1;
}
Reply
#5

Thanks guys
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)