Jump to content

[Realease] Thirst,Hunger damage script


bombajack

Recommended Posts

I put before the recent query script that can do it, so that the players get harmed when he was thirsty or hungry.
Thanks to the community, one member advised me and wrote skript.I test it and it works!
 
Original script by user @W4lly
 
- in init.sqf put a line with  [] execVM "myName.sqf"; 
- create file with name u want example  myName.sqf and put in mission folder....
- need to be filtered for BE  script.txt line 48 setDamage   add    !="player setDamage _damage;"  !="player setDamage 1;"
 
myName.sqf
while {
    true
}
do {
    
    _damage = damage player;
	
    if(EPOCH_playerHunger < 100) then{
       _damage = _damage + 0.1;
	   if(_damage >= 1 )exitWith { player setDamage 1;};
       player setDamage _damage;
    }else{
	  EPOCH_playerHunger = EPOCH_playerHunger - 50;
	};
	if(EPOCH_playerThirst < 100) then{
       _damage = _damage + 0.1;
	   if(_damage >= 1 )exitWith { player setDamage 1;};
       player setDamage _damage;
    }else{
	  EPOCH_playerThirst = EPOCH_playerThirst - 25;
	};   
    sleep 300;
};

if u want increase speed reduce sleep....

if you want increase damage reduce   _damage + 0.1; //10% damage

if you want modify from what values need you start damage, reduce  -  if(EPOCH_playerHunger < 100) then{  

 

@W4lly thanks for help again. ;)

 

Link to comment
Share on other sites

Im tired and blind.

Nice turnover from idea to script man!

Ok the If statements are returning erros.

It doesn't know what EPOCH_playerHunger and EPOCH_playerThirst are.

So make these variables

_hunger = Epoch_PlayerHunger;

_thirst = Epoch_PlayerThrist;

I have a variation of this working in a function with a script init to check every 5 minutes.

This is the script

while {true} do { 

	_hunger = EPOCH_playerHunger;
	_thirst = EPOCH_playerThirst;
	if(_hunger < 100) then	{call dpReal_Health;}	else	{EPOCH_playerHunger = EPOCH_playerHunger - 50;};
	if(_thirst < 100) then	{call dpReal_Health;}	else	{EPOCH_playerThirst = EPOCH_playerThirst - 25;};
	sleep 300;
};
You can fill in your current damage stuff in place of "call dpReal_Health;"

I am running a function that does the damage and then rechecks the hunger and health for replenishment every few seconds and will continue to damage the player until they have ate or drank.

I need to do some more testing to make sure the function works properly but the above change in your code should work well in the meantime

Link to comment
Share on other sites

So in other words, try using this:

while {
    true
}
do {
    _hunger = EPOCH_playerHunger;
    _thirst = EPOCH_playerThirst;
    _damage = damage player;
	
    if(_hunger < 100) then{
       _damage = _damage + 0.1;
	   if(_damage >= 1 )exitWith { player setDamage 1;};
       player setDamage _damage;
    }else{
	  EPOCH_playerHunger = EPOCH_playerHunger - 50;
	};
	if(_thirst < 100) then{
       _damage = _damage + 0.1;
	   if(_damage >= 1 )exitWith { player setDamage 1;};
       player setDamage _damage;
    }else{
	  EPOCH_playerThirst = EPOCH_playerThirst - 25;
	};   
    sleep 300;
};
Link to comment
Share on other sites

Made some more changes

while {
    true
}
do {
    _hunger = EPOCH_playerHunger;
    _thirst = EPOCH_playerThirst;
    _pdamage = damage player;
	
    if(_hunger < 100) then{
       _damage = _pdamage + 0.1;
	   if(_damage >= 1 )exitWith { player setDamage 1;};
       player setDamage _damage;
    }else{
	  EPOCH_playerHunger = EPOCH_playerHunger - 50;
	};
	if(_thirst < 100) then{
       _damage = _pdamage + 0.1;
	   if(_damage >= 1 )exitWith { player setDamage 1;};
       player setDamage _damage;
    }else{
	  EPOCH_playerThirst = EPOCH_playerThirst - 25;
	};   
    sleep 300;
};
Link to comment
Share on other sites

Thank you for sharing!

I think I hijacked the thread....

The original idea was bombajacks and then wally helped him out with some code.

I have only made a couple of adjustements as well as took it a step further on my server.

I am in testing phase with it but will release it when its finished

Link to comment
Share on other sites

  • 1 month later...

Made some more changes

while {
    true
}
do {
    _hunger = EPOCH_playerHunger;
    _thirst = EPOCH_playerThirst;
    _pdamage = damage player;
	
    if(_hunger < 100) then{
       _damage = _pdamage + 0.1;
	   if(_damage >= 1 )exitWith { player setDamage 1;};
       player setDamage _damage;
    }else{
	  EPOCH_playerHunger = EPOCH_playerHunger - 50;
	};
	if(_thirst < 100) then{
       _damage = _pdamage + 0.1;
	   if(_damage >= 1 )exitWith { player setDamage 1;};
       player setDamage _damage;
    }else{
	  EPOCH_playerThirst = EPOCH_playerThirst - 25;
	};   
    sleep 300;
};

Thanks. Been looking for something like this.. Is it possible to let the player know he is taking damage? A message that pops up saying something like "You are losing health! You must eat soon!" I was also wondering if there was a way to speed up the amount of time it takes for hunger and thirst to decrease.

Link to comment
Share on other sites

Thanks. Been looking for something like this.. Is it possible to let the player know he is taking damage? A message that pops up saying something like "You are losing health! You must eat soon!" I was also wondering if there was a way to speed up the amount of time it takes for hunger and thirst to decrease.

You might want to check out my release for real health system

I have been testing an enhanced version of this I name epoch realism which incorporates damage array and environmental aspects but needs a few tweaks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...