SA-MP Forums Archive
Command only made for someone with a specify name - 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: Command only made for someone with a specify name (/showthread.php?tid=280363)



Command only made for someone with a specify name - davelord - 31.08.2011

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.'


Re: Command only made for someone with a specify name - PrawkC - 31.08.2011

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


Re: Command only made for someone with a specify name - Amel_PAtomAXx - 31.08.2011

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;
    }



Re: Command only made for someone with a specify name - Mustang GT - 31.08.2011

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



Re: Command only made for someone with a specify name - davelord - 31.08.2011

Thanks guys