If name is ### player get's acces to a command.
#1

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?
Reply
#2

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;
}
Reply
#3

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;
}
Reply
#4

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


Forum Jump:


Users browsing this thread: 1 Guest(s)