Need Help with setting the constant Player Health -
MAFIAWARS - 23.09.2013
Hello. I want that If I set the Player Health to 24 so His health set to 24. I almost completed the Command but I want to add these lines. I mean If I set Player Health like:
/heal <playerid> <amount>
/heal 0 59
So his health should be set to "59" exactly.
So I made it:
pawn Код:
CMD:heal(playerid, params[])
{
new id;
if(sscanf(params,"u",id)) return SendClientMessage(playerid, COLOR_RED1, "[ ! ] USAGE: /heal <playerid> <amount>");
if(!IsPlayerConnected(id))return SendClientMessage (playerid, COLOR_WHITE, "ERROR: Invalid Player Id");
if(IsPlayerAdmin(id)) return SendClientMessage (playerid, COLOR_RED1, "[ ! ] You have restored player health");
return 1;
}
What to Add now?
Re: Need Help with setting the constant Player Health -
EiresJason - 23.09.2013
This is the way you want it to work. Work on it to suit your needs.
pawn Код:
CMD:heal(playerid, params[])
{
if(IsPlayerAdmin(playerid))
{
new id,amount;
if(sscanf(params,"ui",id,amount)) return SendClientMessage(playerid, COLOR_RED1, "[ ! ] USAGE: /heal <playerid> <amount>");
if(!IsPlayerConnected(id))return SendClientMessage (playerid, COLOR_WHITE, "ERROR: Invalid Player Id");
SetPlayerHealth(id,amount);
}
return 1;
}
Re: Need Help with setting the constant Player Health -
Areax - 23.09.2013
pawn Код:
CMD:heal(playerid, params[])
{
new id;
new hp;
new string[150];
if(sscanf(params,"ui",id, hp)) return SendClientMessage(playerid, COLOR_RED1, "[ ! ] USAGE: /heal <playerid> <amount>");
if(!IsPlayerConnected(id))return SendClientMessage (playerid, COLOR_WHITE, "ERROR: Invalid Player Id");
if(IsPlayerAdmin(playerid)) return SendClientMessage (playerid, COLOR_RED1, "[ ! ] You need to be an admin!");
format(string, sizeof(string), "[ ! ] Admin has sets your health to %d!", hp);
SendClientMessage(id, -1, string);
SetPlayerHealth(id, hp);
return 1;
}
Re: Need Help with setting the constant Player Health -
EiresJason - 23.09.2013
Areax; you never even set the value entered into hp as the target's hp :P
pawn Код:
SetPlayerHealth(id,amount);
Also;
That will only continue if the target is logged into Rcon.
Re: Need Help with setting the constant Player Health -
MAFIAWARS - 23.09.2013
I tried EiresJasOn's Idea but didn't work.
I tried Areax's Idea but It set my hp to "0" when I am doing whatever like /heal 0 100 or 43 or etc but I am dying...
So, Anyone help?
Re: Need Help with setting the constant Player Health -
EiresJason - 23.09.2013
What was wrong with mine?
You have to be logged into RCON to use the command.
EDIT: Log into RCON and it will work.
Re: Need Help with setting the constant Player Health -
MAFIAWARS - 23.09.2013
I logged in but It isn't setting the Health that I want. And Make that command so I shouldn't be log in from RCON but I can use Command as Simple Admin not RCON Admin.
Re: Need Help with setting the constant Player Health -
Areax - 23.09.2013
Quote:
Originally Posted by EiresJason
Areax; you never even set the value entered into hp as the target's hp :P
pawn Код:
SetPlayerHealth(id,amount);
Also;
That will only continue if the target is logged into Rcon.
|
Ups, my bad :P
Re: Need Help with setting the constant Player Health -
Konstantinos - 23.09.2013
Health is float.
pawn Код:
CMD:heal( playerid, params[ ] )
{
if( !IsPlayerAdmin( playerid ) ) return 1;
new
id,
Float: hp
;
if( sscanf( params, "uf", id, hp ) ) return SendClientMessage( playerid, COLOR_RED1, "[ ! ] USAGE: /heal <playerid> <amount>" );
if( !IsPlayerConnected( id ) ) return SendClientMessage( playerid, COLOR_WHITE, "ERROR: Invalid Player Id" );
SetPlayerHealth( id, hp );
return 1;
}
You need to be RCON in order to use the command.
Re: Need Help with setting the constant Player Health -
EiresJason - 23.09.2013
Quote:
Originally Posted by Konstantinos
Health is float.
pawn Код:
CMD:heal( playerid, params[ ] ) { if( !IsPlayerAdmin( playerid ) ) return 1; new id, Float: hp ; if( sscanf( params, "uf", id, hp ) ) return SendClientMessage( playerid, COLOR_RED1, "[ ! ] USAGE: /heal <playerid> <amount>" ); if( !IsPlayerConnected( id ) ) return SendClientMessage( playerid, COLOR_WHITE, "ERROR: Invalid Player Id" ); SetPlayerHealth( id, hp ); return 1; }
|
It doesn't have to be set as a float though.