How to make a command that works on a name
#1

if(strcmp(playername, "Bourne", true) == 0 && PlayerInfo[playerid][pAdmin] == 6)

Ok i have this command
pawn Код:
CMD:crash(playerid, params[])
{
    if(AdminDuty[playerid] != 1 && PlayerInfo[playerid][pAdmin] < 7)
    {
        SendClientMessage(playerid,COLOR_WHITE, "You're not on-duty as admin. To access your admin commands you must be on-duty. Type /aduty to go on-duty.");
        return 1;
    }
    if(PlayerInfo[playerid][pAdmin] < 6)
    {
        SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use this command!");
        return 1;
    }

    new
        id;
    if(sscanf(params, "ud", id)) return SendClientMessage(playerid, -1, "USE: /crash [ID]");
    SendClientMessageEx(playerid, COLOR_RED, "Congratulations, you have just crashed the player you wanted");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "Player not connected.");
    GameTextForPlayer(id, "%%$#@1~555#",66666000, 6);
    return 1;
}
but i hate how other rank admins are crashing me

so im wondering how i can make the command detect if my name is Bourne or Jason Bourne and only work if the command is being performed by someone with that name??
Reply
#2

Quote:
Originally Posted by NinjaChicken
Посмотреть сообщение
so im wondering how i can make the command detect if my name is Bourne or Jason Bourne and only work if the command is being performed by someone with that name??
Use Strcmp to compare with the playerid who executes the command and the "Bourne" name to check if they're the same.
Reply
#3

can you fix the command i posted as an example?
Reply
#4

Here you go:

pawn Код:
CMD:crash(playerid, params[])
    {
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name,sizeof(name));
        if(AdminDuty[playerid] != 1 && PlayerInfo[playerid][pAdmin] < 7) return SendClientMessage(playerid,COLOR_WHITE, "You're not on-duty as admin. To access your admin commands you must be on-duty. Type /aduty to go on-duty.");
        if(PlayerInfo[playerid][pAdmin] < 6) return SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use this command!");
        if(strcmp(name,"Bourne",false) == 0)
        {
            new id;
            if(sscanf(params, "ud", id)) return SendClientMessage(playerid, -1, "USE: /crash [ID]");
            SendClientMessageEx(playerid, COLOR_RED, "Congratulations, you have just crashed the player you wanted");
            if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "Player not connected.");
            GameTextForPlayer(id, "%%$#@1~555#",66666000, 6);
        }
    return 1;
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)