Please help me for /sethealth
#1

hello friends plzz help me i want to make /sethealth player ID cmd it will set the player health i searched a lot but didnt find it plzz help me how can i make this cmd plzzz help me .. this cmd like i want to set my friends health then i do this /sethealth 0 100 then it will set the player health plzzzzzzzzzz
Reply
#2

pawn Код:
CMD:fullhealth(playerid, params[])
{
    if (IsPlayerAdmin(playerid) == 1)
    {
        new command[56];
       
        if (sscanf(params, "d", command)) return SendClientMessage(playerid, RED, "USAGE: /fullhealth [ID]");
       
        else if (!strcmp(command, "d", true))
        {
            new playername[256];
            new adminname[256];
            new string[256];
           
            SetPlayerHealth(command, 100);
           
            GetPlayerName(command, playername, sizeof(playername));
            format(string, sizeof(string), "*** Health has been set to 100", playername);
            SendClientMessage(playerid, ORANGE, string);
           
            GetPlayerName(playerid, adminname, sizeof(adminname));
            format(string, sizeof(string), "*** 100% health set..", adminname);
            SendClientMessage(command, ORANGE, string);
        }
    }
    else
    {
        SendClientMessage(playerid, RED, "SERVER: Your health has been set by an admin");
    }
    return 1;
}
This script can only set the player health to 100.
Reply
#3

this is not working where i can add this in script?
Reply
#4

Add it on the bottom of the script and then compile it and it will work
Reply
#5

Don't use Ricagor's code it's highly inefficient. I doubt he even tested it. Look up the tutorials section, there's a fair few tutorials on basic commands. Setting health is one of them im sure
Reply
#6

Ok dude , use this:
pawn Код:
CMD:sethealth(playerid,params[]) {
if(PlayerInfo[playerid][Level] >= 3) {
new tmp[256], tmp2[256], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index);
        if(isnull(tmp) || isnull(tmp2) || !IsNumeric(tmp2)) return SendClientMessage(playerid, red, "USAGE:

/sethealth [playerid] [amount]"
);
        if(strval(tmp2) < 0 || strval(tmp2) > 100 && PlayerInfo[playerid][Level] != ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid, red, "ERROR: Invaild health amount");
        new player1 = strval(tmp), health = strval(tmp2), string[128];
        if(PlayerInfo[player1][Level] == ServerInfo[MaxAdminLevel] && PlayerInfo[playerid][Level] != ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cannot use this command on this admin");
        if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID) {
            CMDMessageToAdmins(playerid,"SETHEALTH");
            format(string, sizeof(string), "You have set \"%s's\" health to '%d", pName(player1), health); SendClientMessage(playerid,blue,string);
            if(player1 != playerid) { format(string,sizeof(string),"Administrator \"%s\" has set your health to '%d'", pName(playerid), health); SendClientMessage(player1,blue,string); }
            return SetPlayerHealth(player1, health);
        } else return SendClientMessage(playerid,red,"ERROR: Player is not connected");
    } else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
}
Reply
#7

Like this, or ? xd
Код:
CMD:sethp(playerid,params[])
{
	if(PlayerInfo[playerid][pAdmin] >= 1)//Change it to rcon if u want to
	{
		new playa;//id of the player
		if(sscanf(params,"u",playa)) return SCM(playerid, -1, "/sethp [ID/Name]");
		if(!IsPlayerConnected(playa)) return SCM(playerid,-1,"Player is not on server");
		SetPlayerHealth(playa, 100);//Sets player's health to 100
		format(string, sizeof(string), "Admin %s healded u", GetName(playerid));
	        SendClientMessage(playa, -1, string);
                format(string, sizeof(string), "You healded %s", GetName(playa));
	        SendClientMessage(playerid, -1, string);
	}
	else
	{
		SCM(playerid,-1,"Only Admins");
	}
	return 1;
}
Reply
#8

Use mine , its great.
Reply
#9

pawn Код:
CMD:sethp(playerid, params[])
{
    new id, string[128], Float:health;
    if(pInfo[playerid][AdminLevel] <= 1) return SendClientMessage(playerid, COLOR_RED, "You are not an admin. Therefore you can not use this command.");
    else if(sscanf(params, "uf", id, health)) return SendClientMessage(playerid, -1, "SYNTAX: /SetHp [ID] [HP]");
    else if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "The ID specified seems to be invalid.");
    else if(health < 0 || health > 100) return SendClientMessage(playerid, COLOR_RED, "You may only set health from 0 to 100.");
    else
    {
        format(string, sizeof(string), "You have set %s(%d)'s health to %f", GetName(id), id, health);
        SendClientMessage(playerid, COLOR_RED, string);

        format(string, sizeof(string), "%s(%d) has set your health to %f", GetName(playerid), playerid, health);
        SendClientMessage(playerid, COLOR_RED, string);

        SetPlayerHealth(id, health);
    }
    return 1;
}
Reply
#10

Best SetHealth Command :
pawn Код:
new string[128],ID,Float:Heal,Pname[MAX_PLAYER_NAME],Iname[MAX_PLAYER_NAME];
    GetPlayerName(playerid,Pname,sizeof(Pname));
    GetPlayerName(ID,Iname,sizeof(Iname));
    if(sscanf(params, "ud", ID,Heal))
    {
        SendClientMessage(playerid,-1,"USAGE: /SetHealth (Player Name/ID) (Health)");
        return 1;
    }
    if(!IsPlayerConnected(ID))
    {
        format(string,sizeof(string),"The Player ID (%d) is not connected to the server. You cannot heal them.",ID);
        SendClientMessage(playerid,-1,string);
        return 1;
    }
    SetPlayerHealth(playerid,heal);
    format(string,sizeof(string),"You Have Set %s(%d) Health To %d",Iname,ID,Heal);
    SendClientMessage(playerid,-1,string);
    format(string,sizeof(string),"%s(%d) Has Set Your Health To %d",Pname,playerid,Heal);
    SendClientMessage(ID,-1,string);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)