kevin11 Posted June 15, 2010 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)
50p Posted June 16, 2010 Posted June 16, 2010 Your code will kill you only if you're in vehicle. Indent your code!! It's hard to read! - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
TheRealCow Posted June 16, 2010 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 Server Name: mR|Team Clan Race Server Server IP: 84.82.81.225:22004
dzek (varez) Posted June 16, 2010 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) Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
dzek (varez) Posted June 16, 2010 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 Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
kevin11 Posted June 16, 2010 Author 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?
50p Posted June 16, 2010 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. - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
dzek (varez) Posted June 16, 2010 Posted June 16, 2010 oh, i forgot that timesToExecute isnt optional (defaulting to 0) Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
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