[Question] Is there a way to check...
#1

Is there a way to check if a Player have a certain name to use a Command?
pawn Код:
if (strcmp("/cctv", cmdtext, true) == 0)
    {
      PlayerMenu[playerid] = 0;
      TogglePlayerControllable(playerid, 0);
        ShowMenuForPlayer(CCTVMenu[0], playerid);
        return 1;
    }
Please help..
Reply
#2

You mean like GetPlayerName?
Reply
#3

Quote:

new Data[MAX_PLAYER_NAME];
GetPlayerName(playerid, Data, sizeof(Data));
if(strcmp(Data,"yournamehere",true))

Quote:

if (strcmp("/cctv", cmdtext, true) == 0)
{
new Data[MAX_PLAYER_NAME];
GetPlayerName(playerid, Data, sizeof(Data));
if(strcmp(Data,"yournamehere",true))[/
{
PlayerMenu[playerid] = 0;
TogglePlayerControllable(playerid, 0);
ShowMenuForPlayer(CCTVMenu[0], playerid);
return 1;
}
}

Untested* and I'm a newbie aswell, so don't flame me.
Reply
#4

pawn Код:
new n[24];
GetPlayerName(playerid, n, 24);
if (strcmp("/cctv", cmdtext, true) == 0)
{
  if(strcmp(n, "YourName", true) != 0)
    return SendClientMessage(playerid,0xFF6347AA, " You shouldn't use this command with your name.");  PlayerMenu[playerid] = 0;
  TogglePlayerControllable(playerid, 0);
  ShowMenuForPlayer(CCTVMenu[0], playerid);
  return 1;
}
Reply
#5

Quote:
Originally Posted by MenaceX^
pawn Код:
new n[24];
GetPlayerName(playerid, n, 24);
if (strcmp("/cctv", cmdtext, true) == 0)
{
  if(strcmp(pname, "YourName", true) != 0)
    return SendClientMessage(playerid,0xFF6347AA, " You shouldn't use this command with your name.");  PlayerMenu[playerid] = 0;
  TogglePlayerControllable(playerid, 0);
  ShowMenuForPlayer(CCTVMenu[0], playerid);
  return 1;
}
pname?
Reply
#6

oh ops :S. I allways use pname, this time I used n instead.
Reply
#7

Quote:
Originally Posted by MenaceX^
oh ops :S. I allways use pname, this time I used n instead.
hehe

Sparow use wiki more you will find there everything that you need. On every function and callback you have an explanation and usage example. You will learn better on your own and you will understand it better.
Reply
#8

Would my code work? (Just wondering :P)
Reply
#9

Quote:
Originally Posted by GTA_Rules
Would my code work? (Just wondering :P)
Test it :P
Reply
#10

Quote:
Originally Posted by GTA_Rules
Would my code work? (Just wondering :P)
If you don't sure about your code, you better keep them away. It's confused people that learn from it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)