Cmd for name
#1

How to make the command working only for Name of player not his level
Like if my name is : "What", i can use the command
If my name : "Hot" , i can't use the command

I remember it was something like "equalname" in it but i forget
So can you help?
Reply
#2

mssed up, fuck this.
Reply
#3

Pretty much the same ..
Код:
        new tname[MAX_PLAYER_NAME];
        GetPlayerName(playerid, tname, sizeof(tname));
        if(strcmp(tname,"NAME HERE", true) == 0)
        {
            // CODE
	}
Reply
#4

@BigGroter: This will not work.

@Kudoz: The 'true' in your strcmp means that any name (let's imagine his name is ''Hot'') of those works:
hOt, hOT, HOT, hot, hoT, HoT, ...

pawn Код:
new p_Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, p_Name, sizeof(p_Name));
if(!strcmp(p_Name, "Hot"))
{
    //Here you put your command.
}
else return SendClientMessage(playerid, 0xFF0000FF, "ERROR: Only ''Hot'' can use this command. Sorry.");
Reply
#5

Thanks guys
Lets say that i will add command to admin spiceal chat for 2 names how i do ?? 2 names and /a Command for admin chat!
Reply
#6

I suppose that is what you want:

Put it at OnPlayerCommandText:
pawn Код:
if(!strcmp("/a", cmdtext, true, 2))
{
    if(strlen(cmdtext[2]) && cmdtext[2] == ' ')
    {
        new p_Name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, p_Name, sizeof(p_Name));
        if(!strcmp(p_Name, "Hot") || !strcmp(p_Name, "Cold"))
        {
            if(!strlen(cmdtext[3]) || cmdtext[3] == ' ')
            {
                new emsg[120];
                format(emsg, 120, "Usage: /update 0-%d", Update_Nr);
                return SendClientMessage(playerid, 0xFF0000FF, emsg);
            }
            new msg[144];
            format(msg, sizeof(msg), "[ADMIN] %s: %s", p_Name, cmdtext[3]);
            for(new i=0; i<MAX_PLAYERS; i++)
            {
                if(IsPlayerConnected(i))
                {
                    new i_Name[MAX_PLAYER_NAME];
                    GetPlayerName(i, i_Name, sizeof(i_Name));
                    if(!strcmp(i_Name, "Hot") || !strcmp(i_Name, "Cold"))
                    {
                         SendClientMessage(i, 0xFF0000FF, msg);
                    }
                }
            }
        }
        else return SendClientMessage(playerid, 0xFF0000FF, "ERROR: Only ''Hot'' and ''Cold'' can use this command. Sorry.");
    }
}
I didn't test it, tell me if there are any mistakes/errors/bugs.


[Yes, I used strcmp and command processor, because (s)he seems new, learning with strcmp is good, I did that too.]
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)