How to make sth. for one Name?
#1

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
Reply
#2

pawn Код:
if(!strcmp(PlayerName, "XCarBOn")) return Kick(playerid);
Reply
#3

Thanks very much.
Reply
#4

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.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)