boro Posted November 23, 2012 Share Posted November 23, 2012 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
abu5lf Posted November 23, 2012 Share Posted November 23, 2012 Try setTimer ( function ( ) if isElementInWater ( localPlayer ) then setElementHealth ( localPlayer, getElementHealth ( localPlayer ) - 5 ) end end, 5000, 0 ) Link to comment
myonlake Posted November 23, 2012 Share Posted November 23, 2012 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
myonlake Posted November 23, 2012 Share Posted November 23, 2012 boro said: Big THX myonlake You're welcome, but 3ɑsн8 ɑʟsнɾq's code is good as well, but the thing is, as you want to keep it server-side, then keep it server-side. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now