Multiple uses of /set
#1

I want to make a /set command where the admin can set the health, armour ect but in one command. How can I got about making it?
Reply
#2

pawn Код:
if(strcmp(cmd, "/sethp", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /sethp [playerid/PartOfName] [health]");
            new playa;
            new health;
            playa = ReturnUser(tmp);
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /sethp [playerid/PartOfName] [health]");
            health = strvalEx(tmp);
            if(PlayerInfo[playerid][pAdmin] >= 4)
            {
                if(IsPlayerConnected(playa))
                {
                    if(playa != INVALID_PLAYER_ID)
                    {
                        SetPlayerHealth(playa, health);
                        format(string, sizeof(string), "   You have set %s's health to %d !",PlayerName(playa),health);
                        SendClientMessage(playerid, COLOR_GREY, string);
                    }
                }
            }
            else SendClientMessage(playerid, COLOR_GRAD1, "   You are not authorized to use that command !");
        }
        return 1;
    }
    if(strcmp(cmd, "/setarmor", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setarmor [playerid/PartOfName] [armor]");
            new playa;
            new armor;
            playa = ReturnUser(tmp);
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /sethp [playerid/PartOfName] [armor]");
            armor = strvalEx(tmp);
            if(PlayerInfo[playerid][pAdmin] >= 4)
            {
                if(IsPlayerConnected(playa))
                {
                    if(playa != INVALID_PLAYER_ID)
                    {
                        GetPlayerName(playa, giveplayer, sizeof(giveplayer));
                        SetPlayerArmour(playa, armor);
                        format(string, sizeof(string), "   You have set %s's armor to %d !", giveplayer,armor);
                        SendClientMessage(playerid, COLOR_GREY, string);
                    }
                }
            }
            else SendClientMessage(playerid, COLOR_GRAD1, "   You are not authorized to use that command !");
        }
        return 1;
    }
Reply
#3

Set for him self, for all players or just 1 player?
Reply
#4

For a selected player and WoodPecker that's not what I mean.
Reply
#5

pawn Код:
COMMAND:sethp(playerid, cmdtext[])
{
    new Target,Amount;
    if(!sscanf(cmdtext,"ui", Target, Amount))
    {
        if(Target == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, " Invalid playerid");
        if(Amount < 0 || Amount > 100) return SendClientMessage(playerid, -1, "Amount 0 - 100");
        SetPlayerHealth(Target, Amount);
        SendClientMessage(playerid, -1, "You healed someone");
    } else return SendClientMessage(playerid, -1, "Usage: /sethp [playerid] [health]");
    return 1;
}
This should give you an idea of how to make one. Requires ZCMD & Sscanf2
Reply


Forum Jump:


Users browsing this thread: