How to check a players name
#1

Well, I was wondering how can I make a script check a players name and allow them to do something.

Ex:
A player wants to get into a certain car but there name has to start with an "a" to get into this particular car.

What I want to do is something like this but I has to do with a gang area, I got the door to it working for admins only at the moment but I want it to work with people that have [g00n] for the tag of their name. How can I set it up to do this.

~Thanks
Reply
#2

GetPlayerName.
Reply
#3

Thank you. I couldn't figure it out before. I must have over-looked it before.

EDIT: Alright, How can I make it check to see if a player has [g00n] in their name?
Reply
#4

strfind.
Reply
#5

ooookkkk...Alittle better explanation would be appreciated.


Like how do I set it up:

strfind(GetPlayerName(playerid), "[g00n]", true, 1);


Is that right?
Reply
#6

pawn Код:
if(strfind(namevariable,"[g00n]",true)==-1)
{
  //code
}
else SendClientMessage(playerid,color,"You are not a g00n member.");
Reply
#7

Could I do it like this?

Код:
if(strfind(GetPlayerName(i, name, sizeof(name)), "[g00n]", true)==-1))
{
  //code
}
Reply
#8

no.
Reply
#9

Quote:
Originally Posted by SilentHuntR
no.
There's a very unhelpful theme to your spam posts...

GetPlayerName does not directly return the players name, you have to save it to a string.

pawn Код:
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
That saves the players name to the array "name". Now you have to do the strfind business:

pawn Код:
if(strfind(name, "[g00n]", true) == -1)
{
//Code if g00n is in name
}
Note you may wish to change the true depending on whether you want it to be case sensitive, eg: G00n or g00n or G00N.

True = not case sensitive
False = Case Sensitive
(I Think)
Reply
#10

Thanks Weirdosport! I got it working now!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)