Soren Posted October 12, 2011 Share Posted October 12, 2011 Hi all this is mi first post and i want to make a toxic water script so when you touch the water you die if anyone know the answer tell me please Link to comment
arezu Posted October 12, 2011 Share Posted October 12, 2011 -- client sided addEventHandler("onClientRender", getRootElement(), function() if(isElementInWater(getLocalPlayer()))then triggerServerEvent("onPlayerHitWater", getLocalPlayer()) end end) -- smoke effect (not tested) addEvent("onPlayerHitToxicWater", true) addEventHandler("onPlayerHitToxicWater", getRootElement(), function() local posX, posY, posZ = getElementPosition(source) fxAddTyreBurst(posX, posY, posZ, 0, 0, 3) end) -- server sided addEvent("onPlayerHitWater", true) addEventHandler("onPlayerHitWater", getRootElement(), function() if(isPedDead(source))then return end killPed(source) triggerClientEvent("onPlayerHitToxicWater", source) end) Link to comment
AGENT_STEELMEAT Posted October 13, 2011 Share Posted October 13, 2011 Slightly better: --[[ CLIENTSIDE ]] --This function has many uses for clientside triggering of player exit/enter events. local isInWater = isElementInWater(localPlayer) addEvent("onClientPlayerExitWater", false); addEvent("onClientPlayerEnterWater", false); local function proccessWaterStates() local currentState = isElementInWater(localPlayer) if isInWater ~= currentState then if isInWater and not currentState then triggerEvent("onClientPlayerExitWater", localPlayer) else triggerEvent("onClientPlayerEnterWater", localPlayer) end end isInWater = currentState end addEventHandler("onClientRender", root, proccessWaterStates) --This stuff is relevant to the 'toxic water' stuff, and makes use of the code above setWaterColor(0, 255, 0) local function playerEnterToxicWater() local posX, posY, posZ = getElementPosition(source) fxAddTyreBurst(posX, posY, posZ, posX, posY, getWaterLevel(posX, posY, posZ)) triggerServerEvent("onPlayerHitToxicWater", localPlayer) end addEventHandler("onClientPlayerEnterWater", root, playerEnterToxicWater) --[[ SERVERSIDE ]] addEvent("onPlayerHitToxicWater", true) local function toxicWaterDeath() if client ~= source then return end if not isPedDead(source) then if isPedInVehicle(source) then blowVehicle(getPedOccupiedVehicle(source), true) else killPed(source) end end end addEventHandler("onPlayerHitToxicWater", root, toxicWaterDeath) You can put the processWaterStates function in it's own client-side script for use in many parts of a gamemode. Tested, should work MINUS the fxAddTyreBurst. That function seems to not be working. 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