SA-MP Forums Archive
zcmd help - 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: zcmd help (/showthread.php?tid=363099)



zcmd help - zQrba. - 26.07.2012

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


Re: zcmd help - Cxnnor - 26.07.2012

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.


Re: zcmd help - zQrba. - 26.07.2012

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


Re: zcmd help - zQrba. - 26.07.2012

HELP


Re: zcmd help - MicroD - 26.07.2012

What you exactly want? Explain better.


Re: zcmd help - maramizo - 26.07.2012

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



Re: zcmd help - Kindred - 26.07.2012

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