Finding Part of Playername
#1

Is there a way to find a part of a username of a player?
I got a few skins in ClassSelection (forexample:259) and i want that only [PStudios] Members they can wear..
I've tried figure it out myself with strfind but i never used strfind but im kinda sure thats the way...
can someone help me out?

If someone doesnt wears the [PStudios] Tag i want that they go back to ClassSelection...
If someone does wears the [PStudios] Tag i want text coming up "Welcome [PStudios] Member"
Ofcourse im not a newb in that stuff, just the part with the strfind.. please help
Reply
#2

Код:
new found[MAX_PLAYER_NAME];

public OnPlayerConnect(playerid){
found[playerid] = 0;
return 1;

public OnPlayerClassSelection(playerid, classid){
found[playerid] = 0;
if(classid == [id] || classid == [id2]){       //the id of the class for which you want to have this (if you don't need the second id just delete the "||classid == [id2]" and ofc leave the "[]" away:P...(remember that the clases start with 0
new pname[MAX_PLAYER_NAME], string[256];
format(string, sizeof(string), "%s", pname);
if(strfind(string, "[PStudio]", true) != -1){
found[playerid] = 1;
SendClientMessage(playerid, YOURCOLOR, "You may spawn");
return 1;
}else{
found[playerid] = 0;
SendClientMessage(playerid, YOURCOLOR, "You may not spawn");
return 1;
}
}else{
found[playerid] = 1;
return 1;
}

public OnPlayerRequestSpawn(playerid){
if(found[playerid] == 0){
SendClientMessage(playerid, color, "Spawn denied!");
return 0;
}else{
return 1;
}
return 1;
}
I hope it works:
Reply
#3

pawn Код:
stock FindName(name[])
{
  new pName[MAX_PLAYER_NAME], id = -1;
  for(new i; i < MAX_PLAYERS; i++)
  {
    if(!IsPlayerConnected(i)) continue;
    GetPlayerName(i, pName, sizeof pName);
    if(strfind(pName, name, true) != -1)
    {
      if(id != -1) id = -2;
      else id = i;
    }
  }
  return i;
}
Returns the ID of the player when found, returns -1 when the player IS NOT found and returns -2 when MORE THEN ONE player is found.

Unsure if it works though
Reply
#4

Quote:
Originally Posted by Hiddos
Посмотреть сообщение
pawn Код:
stock FindName(name[])
{
  new pName[MAX_PLAYER_NAME], id = -1;
  for(new i; i < MAX_PLAYERS; i++)
  {
    if(!IsPlayerConnected(i)) continue;
    GetPlayerName(i, pName, sizeof pName);
    if(strfind(pName, name, true) != -1)
    {
      if(id != -1) id = -2;
      else id = i;
    }
  }
  return i;
}
Returns the ID of the player when found, returns -1 when the player IS NOT found and returns -2 when MORE THEN ONE player is found.

Unsure if it works though
uhhm, i dont get it... where do i put which skin is for members only? so ID 259.. where i put that?
this only seems to be to find the name...
Reply
#5

both dont work for me :/
Reply
#6

Bumpiedo
Reply
#7

Ummh, search? there was alot of threads about this.
Reply
#8

Quote:
Originally Posted by 0ne
Посмотреть сообщение
Ummh, search? there was alot of threads about this.
You think i havent done that?

Bump
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)