How can I do it?
#1

Hello,

I want to do if the name of player is "Magnum" so he can do this command.

Thank you
Reply
#2

Use these functions
GetPlayerName
strcmp
Reply
#3

Can you give me example please?
Reply
#4

pawn Код:
CMD:blah(playerid, params[])
{
     new playername[MAX_PLAYER_NAME];
     GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
     if(strcmp("Magnum", playername, 1)) return SendClientMessage(playerid, -1, "You're not magnum");
     //your code...
}
Very simple example, use wiki.
https://sampwiki.blast.hk/wiki/Strcmp

EDIT: Forgot something in GetPlayerName, my bad
Reply
#5

Quote:
Originally Posted by CentyPoo
Посмотреть сообщение
pawn Код:
CMD:blah(playerid, params[])
{
     new playername[MAX_PLAYER_NAME];
     GetPlayerName(playerid, playername);
     if(strcmp("Magnum", playername, 1)) return SendClientMessage(playerid, -1, "You're not magnum");
     //your code...
}
Very simple example, use wiki.
https://sampwiki.blast.hk/wiki/Strcmp
warning 213: tag mismatch
Reply
#6

CentyPoo, you forgot the 'len' in GetPlayerName (That's why the warning is coming (see post above me)).
pawn Код:
CMD:blah(playerid, params[])
{
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    if (strcmp("Magnum", pName)) return SendClientMessage(playerid, 0xAFAFAFAA, "* You aren't allowed to use this command.");
    //The rest of your command here ;)
}
Reply
#7

Quote:
Originally Posted by ******
Посмотреть сообщение
You are better off using a registration system - anyone can change their name to anything in SA-MP.
Don't worry, I know what I do.
Thank you!
Reply
#8

Quote:
Originally Posted by ******
Посмотреть сообщение
You are better off using a registration system - anyone can change their name to anything in SA-MP.
He can also, just make a login system which has it desired password in the script when that name joins :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)