Checking for specific player's name
#3

You create an array to hold the players name. You use strcmp to compare the strings.


pawn Код:
new name[MAX_PLAYER_NAME]; // create an array that holds enough space to store the player name
GetPlayerName(playerid, name, MAX_PLAYER_NAME); // get the player name
if(!strcmp(name, "John_Slapper", false)) // compare both strings to match each other, aka identical
{
    // do cmd
}
Notice the difference in "true" and "false" from the above reply? Well, if you have a registration system that is case sensitive, someone might be able to join your server with different casing, like: "john_slapper" and still be able to execute the command.

The boolean tells the script if it should ignore cases or not.
Reply


Messages In This Thread
Checking for specific player's name - by cosbraa - 09.06.2012, 08:11
Re: Checking for specific player's name - by [KHK]Khalid - 09.06.2012, 08:17
AW: Checking for specific player's name - by Extremo - 09.06.2012, 08:17
Re: Checking for specific player's name - by zombieking - 09.06.2012, 08:20
Re: Checking for specific player's name - by cosbraa - 09.06.2012, 10:14

Forum Jump:


Users browsing this thread: 3 Guest(s)