Jump to content

[Question] health


Stranger

Recommended Posts

hello,

i have a problem or maybe bug ? i don't know

that if i used:

setElementHealth (player, getElementHealth (player) - 30) 

it's work

but if his health and his health has reached 30, his health is filled automatically,

i don't know if this is a bug or something like that.

Link to comment
  
local msec = 1000 -- Type mili - seconds here how much you whant. 
local hpC = getElementHealth (player) -- get players health 
local upmSec = 5000 -- type mili - seconds here of how much time you want take it make it u;. 
local up = 35 -- the hp should be up must be here 
function nameIt(player) -- function 
if hpC  < 30 then -- checking players hp if 30 down then it will continue 
setTimer(setElementHealth,upmSec,3,player,up) -- it set its hp 
     end 
end 
setTimer(nameIt,msec,0) 
  

If you meant the script then here.

else--

If you meant the bug then you are talking about the health getting refiled automatically? Then post it at bugs section.

Link to comment
1- you must make it -300 because full health is 1000

2- here is what you have to do

  
health = getElementHealth(player) 
if health =< 300 then 
killPed(player) 
else setElementHealth(player,health - 300) 
end 
  

Lol? See at the wiki setElementHealth example. Why there is -20 not -200?

Link to comment

you didn't understand me, i mean every time i hit him he loss 30 until he die, and

i just wanna make it fast, i mean i want when i hit him

not loss 5 or whatever he use ,

i just wanna make it if i hit him

he loss 30 until he die

but i have this problem

that if the player close to die his health refilled,

i want it if he close to die , his health not refilled,

just keep going down,

i wish that you understand what i meant.

Link to comment

no there is not a code that refilling the health, i'm sure, and the code i know there is no problem with it:

addEventHandler ("onPlayerDamage", root, 
function (attacker, weapon, bodypart) 
if attacker then 
health = getElementHealth (source) 
setElementHealth (source, health - 30) 
end 
end) 

Link to comment
  • Moderators
you didn't understand me, i mean every time i hit him he loss 30 until he die, and

i just wanna make it fast, i mean i want when i hit him

not loss 5 or whatever he use ,

i just wanna make it if i hit him

he loss 30 until he die

but i have this problem

that if the player close to die his health refilled,

i want it if he close to die , his health not refilled,

just keep going down,

i wish that you understand what i meant.

This is how you solve that problem.

local healthLoss = 30 
addCommandHandler("kill", 
function() 
  
    local health = getElementHealth(localPlayer) 
    if healh =< healthLoss then 
        setElementHealth(localPlayer,0) 
    else 
        setElementHealth(localPlayer,healh-healthLoss) 
    end 
end) 
  
  
  

Health gets refilled because you can't have negative health for players.

Link to comment

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...