Finding Part of Playername - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Finding Part of Playername (
/showthread.php?tid=167119)
Finding Part of Playername -
Mike_Peterson - 11.08.2010
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
Re: Finding Part of Playername -
Sascha - 11.08.2010
Код:
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:
Re: Finding Part of Playername -
Hiddos - 11.08.2010
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
Re: Finding Part of Playername -
Mike_Peterson - 11.08.2010
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...
Re: Finding Part of Playername -
Mike_Peterson - 11.08.2010
both dont work for me :/
Re: Finding Part of Playername -
Mike_Peterson - 11.08.2010
Bumpiedo
Re: Finding Part of Playername -
0ne - 11.08.2010
Ummh, search? there was alot of threads about this.
Re: Finding Part of Playername -
Mike_Peterson - 14.08.2010
Quote:
Originally Posted by 0ne
Ummh, search? there was alot of threads about this.
|
You think i havent done that?
Bump