Adding names
#3

1) You can do something like this to get player name and add [Admin] to the front of it.

pawn Код:
if(PlayerInfo[playerid][pAdmin] >= 1) //Change to your admin variable
{
    new pname[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid, pname, sizeof(pname));
    format(string, sizeof(string), "[Admin] %s", pname);
    SetPlayerName(playerid, string);
}
This simply states you create two variables, string and pname. pname receives the players name, then formats it into a string after the [Admin] name in front of it. Then it simply sets the name to the string.

Untested, but it's worth a shot.

Not quite sure how to do the second thing.

You could try to use strfind.

pawn Код:
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
if(strfind(pname, "[Admin]", true) != -1)
{
    if(!PlayerInfo[playerid][pAdmin] >= 1) //Again,change to your admin variable
    {
        Kick(playerid);
        SendClientMessage(playerid, -1, "Please remove the [Admin] in your name, as you are not an admin");
        return 1;
    }
}
Never used something like this but if not correct, this would check the pname for [Admin] in it and would return with a kick and a sendclientmessage if he isn't an admin. If he is, it would continue.

EDIT: Beat me to it, Realcop T.T
Reply


Messages In This Thread
Adding names - by BleverCastard - 25.04.2012, 21:06
Re: Adding names - by Scenario - 25.04.2012, 21:19
Re: Adding names - by Kindred - 25.04.2012, 21:21
Re: Adding names - by Jonny5 - 25.04.2012, 21:21
Re: Adding names - by ReneG - 25.04.2012, 21:24
Re: Adding names - by Jonny5 - 25.04.2012, 21:27
Re: Adding names - by BleverCastard - 25.04.2012, 21:32
Re: Adding names - by Elysian` - 25.04.2012, 21:34
Re: Adding names - by BleverCastard - 25.04.2012, 21:36
Re: Adding names - by Jonny5 - 25.04.2012, 21:47

Forum Jump:


Users browsing this thread: 1 Guest(s)