Could Anyone help me with this?
#1

I'm having trouble with this, could anyone help me?
pawn Код:
new pname;
    GetPlayerName(playerid, pname, sizeof(pname));
    if(pname == runner) return SendClientMessage(playerid, COLOR_RED, "You are not the runner!");
Reply
#2

Use strcmp to compare strings...
Reply
#3

Try this, using strcmp like Viniborn suggested:

pawn Код:
if(!strcmp(pname, "runner"))
{
Reply
#4

Quote:
Originally Posted by Kindred
Посмотреть сообщение
Try this, using strcmp like Viniborn suggested:

pawn Код:
if(!strcmp(pname, "runner"))
{
Thx but the runner is defined I need to do like If Name1 = Name2 with both GetPlayerName
pawn Код:
GetPlayerName(playerid, runner, sizeof(runner));
Reply
#5

Then simply:

pawn Код:
if(strcmp(pname,runner) == 0)
{
    //player is runner
}
Reply
#6

Thx but it doesnt work
Here my codes I have a /start cmd and when this cmd is enabled, I want to prevent other players/admin from using /end.
pawn Код:
new runner[MAX_PLAYER_NAME];
pawn Код:
CMD:start(playerid, params[])
{
    if(!IsAdmin(playerid, 2)) return ErrorMsg(playerid);
    {
        if(Events == 0)
        {
            new string[254];
            format(string, sizeof(string), "%s has started!", eventname);
            SendClientMessageToAll(COLOR_GREY, string);
            GetPlayerName(playerid, runner, sizeof(runner));
                        Started = 1;
        }
    }
    return 1;
}
pawn Код:
CMD:end(playerid, params[])
{
    //Here I want to compare the runner who activated the Start command and the new player who tries to do /end.
/*GetPlayerName(playerid, pname, sizeof(pname));
        if(strcmp(pname,runner) == 0) return SendClientMessage(playerid, COLOR_RED, "You are not the runner!");*/

    if(!IsAdmin(playerid, 2)) return ErrorMsg(playerid);
    {
        new string[254];
        format(string, sizeof(string), "%s has ended! You can no longer join.", eventname);
        SendClientMessageToAll(COLOR_GREY, string);
                Started = 0;
    }
    return 1;
}
Reply
#7

pawn Код:
CMD:end(playerid, params[])
{
    new pname[24];
    GetPlayerName(playerid, pname, sizeof(pname));
    if(strcmp(pname,runner) != 0) // use != for "not the same"
        return SendClientMessage(playerid, COLOR_RED, "You are not the runner!");
    if(!IsAdmin(playerid, 2)) //if the player is not admin
        return ErrorMsg(playerid);
   
        new string[254];
        format(string, sizeof(string), "%s has ended! You can no longer join.", eventname);
        SendClientMessageToAll(COLOR_GREY, string);
        Started = 0;
   
    return 1;
}
Reply
#8

EDITED: THX MAN ITS WORKING I LOVE YOU SO MUCH LOL.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)