zcmd help
#1

how to /set health [amount] random parameters help please.
Reply
#2

pawn Code:
CMD:sethealth(playerid, params[])
{
    new user, health;
    if(!sscanf(params, "ui", user, health))
    {
        if(user != INVALID_PLAYER_ID)
        {
            SetPlayerHealth(user, health);
        }
        else return SendClientMessage(playerid, red, "SERVER: Invalid ID.");
    }
    else return SendClientMessage(playerid, white, "USAGE: /sethealth [ID] [AMMOUNT]");
    return 1;
}
NOTE: You need zcmd and sscanf.
Reply
#3

Quote:
Originally Posted by Cxnnor
View Post
pawn Code:
CMD:sethealth(playerid, params[])
{
    new user, health;
    if(!sscanf(params, "ui", user, health))
    {
        if(user != INVALID_PLAYER_ID)
        {
            SetPlayerHealth(user, health);
        }
        else return SendClientMessage(playerid, red, "SERVER: Invalid ID.");
    }
    else return SendClientMessage(playerid, white, "USAGE: /sethealth [ID] [AMMOUNT]");
    return 1;
}
NOTE: You need zcmd and sscanf.
amıa kodmun slagi /set [health] [amount] diyorum please
Reply
#4

HELP
Reply
#5

What you exactly want? Explain better.
Reply
#6

pawn Code:
CMD:setplayerhealth(playerid,params[])
{
     new gid;
     if(sscanf(params,"u",gid)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE:/setplayerhealth [PlayerID]");
     if(!IsPlayerConnected(gid)) return SendClientMessage(playerid, COLOR_WHITE,"Player ID given is not connected.");
     new Float:rand = random(100);
     SetPlayerHealth(gid, rand);
     new str[128], name[MAX_PLAYER_NAME];
     GetPlayerName(gid, name, MAX_PLAYER_NAME);
     format(str, 128, "You have set %s's health to %f", name, rand);
     return SendClientMessage(playerid, COLOR_WHITE, str);
}
Reply
#7

If you want something such as /set [optionhere] [playerid] [amount], you could do something like this (untested, just an example):

pawn Code:
CMD:set(playerid,params[])
{
    new option[24], targetid, Float:parameter;
    if(sscanf(params, "s[24]", option))
    {
        SendClientMessage(playerid, -1, "Usage: /set [option]");
        SendClientMessage(playerid, -1, "Available Options: Health, Armour");
        return 1;
    }
    if(!strcmp(option, "Health", true))
    {
        if(sscanf(params, "s[24]uf", option, targetid, parameter)) return SendClientMessage(playerid, -1, "Usage: /set health [playerid/partofname] [amount]");
        SetPlayerHealth(targetid, parameter);
    }
    if(!strcmp(option, "Armour", true))
    {
        if(sscanf(params, "s[24]uf", option, targetid, parameter)) return SendClientMessage(playerid, -1, "Usage: /set armour [playerid/partofname] [amount]");
        SetPlayerArmour(targetid, parameter);
    }
    else return SendClientMessage(playerid, -1, "Invalid option!");
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)