Need Help with setting the constant Player Health
#1

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?
Reply
#2

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;
}
Reply
#3

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;
}
Reply
#4

Areax; you never even set the value entered into hp as the target's hp :P
pawn Код:
SetPlayerHealth(id,amount);
Also;
pawn Код:
if(IsPlayerAdmin(id))
That will only continue if the target is logged into Rcon.
Reply
#5

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?
Reply
#6

What was wrong with mine?

You have to be logged into RCON to use the command.

EDIT: Log into RCON and it will work.
Reply
#7

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.
Reply
#8

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;
pawn Код:
if(IsPlayerAdmin(id))
That will only continue if the target is logged into Rcon.
Ups, my bad :P
Reply
#9

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.
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)