SA-MP Forums Archive
How can I do it? - 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: How can I do it? (/showthread.php?tid=384099)



How can I do it? - GuyYahood1 - 10.10.2012

Hello,

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

Thank you


Re: How can I do it? - [HK]Ryder[AN] - 10.10.2012

Use these functions
GetPlayerName
strcmp


Re: How can I do it? - GuyYahood1 - 10.10.2012

Can you give me example please?


Re: How can I do it? - CentyPoo - 10.10.2012

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


Re: How can I do it? - GuyYahood1 - 10.10.2012

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


Re: How can I do it? - Kwarde - 10.10.2012

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



Re: How can I do it? - GuyYahood1 - 10.10.2012

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!


Re: How can I do it? - CrazyChoco - 10.10.2012

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