Jump to content

waterhit = death


kevin11

Recommended Posts

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 :oops:

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
killPlayer(player)
setElementHealth(getLocalPlayer, 0)

is is necessary

and why u get local player ? o.O

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 :mrgreen:

Link to comment
-- 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
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

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

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