Author Topic: [Request] How to increase a Single ammount of health?  (Read 977 times)

0 Members and 1 Guest are viewing this topic.

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
[Request] How to increase a Single ammount of health?
« on: August 22, 2010, 11:53:31 am »
I basically want to increase a player's health in a single ammount..

Like..

IncreaseHealth(1,0.23);
/\ Would increase player 1's health in 0.23.

I've tried DoDamage(), but it's an Integer value, not a Single.

Help, please! :D
www.soldatx.com.br - The brazilian Soldat community.

DarkCrusade

  • Guest
Re: [Request] How to increase a Single ammount of health?
« Reply #1 on: August 22, 2010, 02:28:12 pm »
Could you state what you want a bit better? Because "Would increase player 1's health in 0.23" makes no sense at all :3

Offline Serial K!ller

  • Camper
  • ***
  • Posts: 408
    • Soldat Mods Archive
Re: [Request] How to increase a Single ammount of health?
« Reply #2 on: August 22, 2010, 02:38:39 pm »
 DoDamage() is with an Integer value because soldat handles the health as an integer so you can only increase it with 1.

Offline croat1gamer

  • Veteran
  • *****
  • Posts: 1327
  • OMG CHANGING AVATAR!!! ^ω^
Re: [Request] How to increase a Single ammount of health?
« Reply #3 on: August 22, 2010, 04:13:59 pm »
I think he means it as a percentage.
Not sure tho.
Last year, I dreamt I was pissing at a restroom, but I missed the urinal and my penis exploded.

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: [Request] How to increase a Single ammount of health?
« Reply #4 on: August 23, 2010, 02:03:49 am »
If he means percentage:

player[1].hp_percent := 123;

function OnPlayerDamage(victim, shooter: byte; dmg: integer): integer;
begin
 Result := dmg * 100 div player[victim].hp_percent;
end;

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
Re: [Request] How to increase a Single ammount of health?
« Reply #5 on: August 23, 2010, 05:03:33 am »
God.

I'm only saying that if I want to increase a Single ammount, not an Integer one, how would I do it?

It's not percentage. I'm sorry if I couldn't explain myself very well.

What I want is basically to increase a Single ammount, not-related to percentage.
It's basically that. Just adding health with Single values.

@Serial K!ller, thanks a lot. I just kind of hope you are wrong :P
www.soldatx.com.br - The brazilian Soldat community.

Offline Falcon`

  • Flagrunner
  • ****
  • Posts: 792
  • A wanted lagger
Re: [Request] How to increase a Single ammount of health?
« Reply #6 on: August 23, 2010, 06:27:09 am »
I didn't check if this compile, treat it as pseudo-code.

Code: (pascal) [Select]
type
tPlayer = record
Health, MaxhHalth: single;
ScriptHandleHealth: boolean;
end;

var
Player: array [1..32] of tPlayer;
MaxHealth: byte;


procedure SetSpecialHealth(ID: byte; maxhealth: single); //maxhealth = 100 is "Normal Health"
begin
Player[ID].ScriptHandleHealth := true;
Player[ID].maxhealth := maxhealth;
end;

procedure SampleChangeHealth(ID: byte; health: single);
begin
Player[ID].health := health;
DoDamage(ID, 1); //apply changes
end;

procedure SampleIncreaseHealth(ID: byte; health: single); //health can be negative
begin
Player[ID].health := Player[ID].health + health;
DoDamage(ID, 1); //apply changes
end;

procedure ActivateServer();
begin
if Command('/realistic') then MaxHealth := 65
else MaxHealth := 150;
end;

function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;
begin
Result := Damage;
if Player[Victim].ScriptHandleHealth then begin
Player[Victim].Health := Player[Victim].Health - Damage*100/MaxHealth;
Result := round(GetPlayerStat(Victim, 'health') - Player[Victim].Health*MaxHealth/Player[Victim].MaxHealth);
end;
end;

procedure OnPlayerKill(Killer, Victim: byte;Weapon: byte);
begin
Player[Victim].ScripHandleHealth := false;
Player[Victim].MaxHealth := 100;
end;

about this "Apply changes": if you won't do this, nothing special happen, script will still work properly. They just cause that your changes that your changes are sent to soldat so players can see them
« Last Edit: August 23, 2010, 06:42:49 am by FalconPL »
If you're not paying for something, you're not the customer; you're the product being sold.
- Andrew Lewis

Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.