How to make sth. for one Name? - 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: How to make sth. for one Name? (
/showthread.php?tid=136491)
How to make sth. for one Name? -
XCarBOn - 25.03.2010
Hello,
how to make a command just for one player, for his name?
I mean sth. like that:
Код:
if (Name = Playername)
I tried to define the Name with GetPlayerName, etc. but i don't get the solution. Please help!
Thx,
XCarBOn
Re: How to make sth. for one Name? -
woot - 25.03.2010
pawn Код:
if(!strcmp(PlayerName, "XCarBOn")) return Kick(playerid);
Re: How to make sth. for one Name? -
XCarBOn - 25.03.2010
Thanks very much.
Re: How to make sth. for one Name? -
Joe_ - 25.03.2010
pawn Код:
Name(playerid)
{
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
return pname;
}
Now you can use it like this
pawn Код:
if(strcmp(Name(playerid), "Joe_", true))
{
//stuff
}
Hope this helps.
OR you can use an enum.
pawn Код:
enum stuff
{
name[MAX_PLAYER_NAME]
};
new st00f[MAX_PLAYERS][stuff];
public OnPlayerConnect(playerid)
{
new n[MAX_PLAYER_NAME]; GetPlayerName(playerid, n, MAX_PLAYER_NAME);
st00f[playerid][name] = n;
return 1;
}
I preferably use the enum methord, but I change MAX_PLAYERS to my own value, otherwise your script will have to loop through 500.