Jump to content

[HELP] killwater


boro

Recommended Posts

Hi All i tree make new script , when player is in water then slap player health -5% all time when is stil in water, but this not work , please help check my lua code.

SERVER:

function HotWaterHandler() 
   for i,player in ipairs(getElementsByType("player")) do 
  
      if player then 
     if isElementInWater(player) then 
        slapPedHealth(player, -5) 
     end 
      end 
   end 
end 
  
addEventHandler("onResourceStart", getRootElement(),  
        function() 
           setTimer(HotWaterHandler, 5000, 0) 
        end) 
  

Link to comment
Try
setTimer ( function ( ) 
    if isElementInWater ( localPlayer ) then 
        setElementHealth ( localPlayer, getElementHealth ( localPlayer ) - 5 ) 
    end 
end, 5000, 0 ) 

That's nothing what he wants.

1) Your code is client-side

2) You are triggering it to the local player as it's client-side

--

Maybe this code will help you.

Server-side

setTimer(function() 
    for i,v in ipairs(getElementsByType("player")) do 
        if isElementInWater(v) then 
            setElementHealth(v, getElementHealth(v)-5) 
        end 
    end 
end, 5000, 0) 

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