SA-MP Forums Archive
If name is ### player get's acces to a 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: If name is ### player get's acces to a command. (/showthread.php?tid=319234)



If name is ### player get's acces to a command. - davelord - 18.02.2012

Title, basicly. I want a form, that, for example, if the player's name is Rodger_Dodger, he get's access to (a) command(s). Could anyone of you give me a example?


Re: If name is ### player get's acces to a command. - John Rockie - 18.02.2012

Try something like this
pawn Код:
new Pname[24];
  GetPlayerName(playerid, Pname, 24);
  if(strcmp(Pname, "NameHere", true) == 0)  //set the name here
  {
    //What you do, here.
    return 1;
  }
  return 1;
}



Re: If name is ### player get's acces to a command. - Twisted_Insane - 18.02.2012

Dude, I know what you want, but this wouldn't make any sense to put names around there! Why don't you just use a saving-system and save the adminlevel in it? Then, you could check with an enum whether player "X" has got permissions to perform this command or not...

pawn Код:
CMD:lol(playerid,params[])
{
   if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid,COLOR,"You are not authorized to use that command!"); //checks, if the player has got a high enough level, pAdmin is the enum-var which gets us the info
SendClientMessage(playerid,COLOR,"lol!");
return 1;
}



Re: If name is ### player get's acces to a command. - iPLEOMAX - 18.02.2012

pawn Код:
//Use this stock, paste it at the bottom of your script outside other callbacks.
stock IsPlayerName(playerid, const name[], bool:ignore_case=false)
{
    new playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername, sizeof playername);
    if(!strcmp(playername, name, ignore_case)) return true;
    return false;
}
Example usage:
pawn Код:
CMD:guy(playerid, params[])
{
    if(IsPlayerName(playerid, "Some_Guy"))
    {
   
        SendClientMessage(playerid, -1, "Hello some guy!");
   
    } else SendClientMessage(playerid, -1, "You're not some guy!");
   
    return true;
}