kevin11 Posted June 15, 2010 Share Posted June 15, 2010 well i dont know how to make this but this is my idea when someone jumps into the water he get instant kill can anyone help with this function HotWaterHandler() for i,player in ipairs(getElementsByType("player")) do vehicle = getPedOccupiedVehicle(player) if vehicle then if isElementInWater(vehicle) then local x, y, z = getElementPosition(player) createExplosion (x, y, z, 4, player) -- 4: Car explosion killPlayer(player) setElementHealth(getLocalPlayer, 0) end end end end addEventHandler("onResourceStart", getRootElement(), function() setTimer(HotWaterHandler, 1000, 0) end) Link to comment
50p Posted June 16, 2010 Share Posted June 16, 2010 Your code will kill you only if you're in vehicle. Indent your code!! It's hard to read! Link to comment
TheRealCow Posted June 16, 2010 Share Posted June 16, 2010 killPlayer(player) setElementHealth(getLocalPlayer, 0) is is necessary and why u get local player ? function hotWater ( player ) setTimer ( hotWater, 1000, 1 ) if isElementInWater(player) then vehicle = getPedOccupiedVehicle(player) if vehicle then local x, y, z = getElementPosition(player) createExplosion (x, y, z, 4, player) killPlayer ( player ) else end else killPlayer ( player ) end end addEventHandler ( "onResourceStart", getRootElement(), hotWater ) no idea does it work Link to comment
dzek (varez) Posted June 16, 2010 Share Posted June 16, 2010 -- client setTimer(function() local veh = getPedOccupiedVehicle(getLocalPlayer()) if (veh) then if (isElementInWater(veh)) then triggerServerEvent("killMe", getLocalPlayer()) end elseif (isElementInWater(getLocalPlayer())) then triggerServerEvent("killMe", getLocalPlayer()) end end, 500) -- server addEvent("killMe", true) addEventHandler("killMe", getRootElement(), function() killPed(source) end) Link to comment
kevin11 Posted June 16, 2010 Author Share Posted June 16, 2010 ty varez u helped me alot i get it now Link to comment
dzek (varez) Posted June 16, 2010 Share Posted June 16, 2010 only thing you "get" is the 100% made by me script.. Im pretty sure you still dont get the idea about programming Link to comment
kevin11 Posted June 16, 2010 Author Share Posted June 16, 2010 only thing you "get" is the 100% made by me script..Im pretty sure you still dont get the idea about programming well... i dont get this addEventHandler("killMe", getRootElement(), function() killPed(source) end) why is the funtion there? Link to comment
50p Posted June 16, 2010 Share Posted June 16, 2010 Because his function is anonymous. If I was doing it client-side, I'd do it with onClientRender rather than a timer. Besides, his setTimer is missing one more argument. His function will also trigger server event multiple times while you're in water. If you don't spawn straight away after being dead, the script will trigger server event again and will keep killing you... Use it if it works for you the way you wanted. Link to comment
dzek (varez) Posted June 16, 2010 Share Posted June 16, 2010 oh, i forgot that timesToExecute isnt optional (defaulting to 0) 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