SA-MP Forums Archive
Could Anyone help me with this? - 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)
+--- Thread: Could Anyone help me with this? (/showthread.php?tid=354863)



Could Anyone help me with this? - andrew2695 - 28.06.2012

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!");



Re: Could Anyone help me with this? - ViniBorn - 28.06.2012

Use strcmp to compare strings...


Re: Could Anyone help me with this? - Kindred - 28.06.2012

Try this, using strcmp like Viniborn suggested:

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



Re : Re: Could Anyone help me with this? - andrew2695 - 28.06.2012

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));



Re: Could Anyone help me with this? - mrcoolballs - 28.06.2012

Then simply:

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



Re : Could Anyone help me with this? - andrew2695 - 28.06.2012

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;
}



Re: Could Anyone help me with this? - mrcoolballs - 28.06.2012

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;
}



Re : Could Anyone help me with this? - andrew2695 - 28.06.2012

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