Matevsz Posted June 18, 2016 Share Posted June 18, 2016 Hi, I want to do a slow subtraction of oxygen in the water every 4 minutes, and when we enter the pickup is charged oxygen to the full LoadOxygen = createPickup(-1890.1999511719, 2145.1000976563, 1.7999999523163, 3, 2690, 2000) setTimer( function() for k,v in ipairs(getElementsByType("player")) do if getElementModel(v) ~= 97 or not isElementInWater(v) then return end local oxygen = getPedOxygenLevel(v) if isElementInWater(v) then setPedOxygenLevel(v, oxygen-1) end end end, 60000*4, 1) addEventHandler("onClientPickupHit", LoadOxygen, function(element) for k, v in ipairs(getElementsByType("player")) do if getElementModel(v) ~= 97 and not isElementInWater(v) then return end if element ~= getLocalPlayer() then return end setPedOxygenLevel(v, 100) end end ) Link to comment
Dimos7 Posted June 19, 2016 Share Posted June 19, 2016 (edited) LoadOxygen = createPickup(-1890.1999511719, 2145.1000976563, 1.7999999523163, 3, 2690, 2000) setTimer(function() for k, v in ipairs (getElementsByType("player")) do if getElementModel(v) ~= 97 or not isElementInWater(v) then return end local oxygen = getPedOxygenLevel(v) if isElementInWater(v) then setPedOxygenLevel(v, oxygen-1) end end end, 400000, 0) addEventHandler("onClientPickupHit", LoadOxygen, function(element) for k, v in ipairs(getElementsByType("player")) do if getElementModel(v) ~= 97 and not isElementInWater(v) then return end if element ~= localPlayer then return end setPedOxygenLevel(v, 100) end end ) Edited June 19, 2016 by Guest Link to comment
KariiiM Posted June 19, 2016 Share Posted June 19, 2016 @Dimos, this line will output an error, you added a comma after the function setTimer(function(), Link to comment
Matevsz Posted June 19, 2016 Author Share Posted June 19, 2016 LoadOxygen = createPickup(-1890.1999511719, 2145.1000976563, 1.7999999523163, 3, 2690, 2000) setTimer(function() for k, v in ipairs (getElementsByType("player")) do if getElementModel(v) ~= 97 or not isElementInWater(v) then return end local oxygen = getPedOxygenLevel(v) if isElementInWater(v) then setPedOxygenLevel(v, oxygen-1) end end end, 400000, 1) addEventHandler("onClientPickupHit", LoadOxygen, function(element) for k, v in ipairs(getElementsByType("player")) do if getElementModel(v) ~= 97 and not isElementInWater(v) then return end if element ~= localPlayer then return end setPedOxygenLevel(v, 100) end end ) unfortunately, after 4 minutes, do not want to subtract oxygen Link to comment
Matevsz Posted June 19, 2016 Author Share Posted June 19, 2016 local LoadOxygen = createPickup(-1890.1999511719, 2145.1000976563, 1.7999999523163, 3, 2690, 2000) local clothes = createPickup(-1886.7001953125, 2142.7001953125, 1.7999999523163, 3, 1275, 2000) function DiverJob(hitElement) local skin = getElementModel(localPlayer) if skin == 97 then local CurrentSkin = getElementData(localPlayer, "CurrentSkin") setElementModel(localPlayer, CurrentSkin) outputChatBox("Finished working diver.", localplayer) else setElementData(localPlayer, "CurrentSkin", skin, false) setElementModel(localPlayer, 97) outputChatBox("I started working diver", localplayer) end end addEventHandler("onClientPickupHit", clothes, DiverJob) setTimer(function() for k,v in ipairs(getElementsByType("player")) do if getElementModel(v) ~= 97 and isElementInWater(v) then return end local oxygen = getPedOxygenLevel(v) if isElementInWater(v) then setPedOxygenLevel(v, oxygen-1) end end end, 300000, 1) addEventHandler("onClientPickupHit", LoadOxygen, function(element) for k, v in ipairs(getElementsByType("player")) do if getElementModel(v) ~= 97 and not isElementInWater(v) then return end if element ~= localPlayer then return end setPedOxygenLevel(v, 100) end end ) This is my full code. After entering the water do not take oxygen every 4 minutes Link to comment
KariiiM Posted June 19, 2016 Share Posted June 19, 2016 local LoadOxygen = createPickup(-1890.1999511719, 2145.1000976563, 1.7999999523163, 3, 2690, 2000) local clothes = createPickup(-1886.7001953125, 2142.7001953125, 1.7999999523163, 3, 1275, 2000) function DiverJob(hitElement) local skin = getElementModel(localPlayer) if ( skin == 97 ) then local CurrentSkin = getElementData(localPlayer, "CurrentSkin") setElementModel(localPlayer, CurrentSkin) outputChatBox("Finished working diver.", localplayer) else setElementData(localPlayer, "CurrentSkin", skin, false) setElementModel(localPlayer, 97) outputChatBox("I started working diver", localplayer) end end addEventHandler("onClientPickupHit", clothes, DiverJob) setTimer(function() for k,v in ipairs(getElementsByType("player")) do if getElementModel(v) ~= 97 and isElementInWater(v) then return end local oxygen = getPedOxygenLevel(v) if isElementInWater(v) then setPedOxygenLevel(v, oxygen-1) end end end, 300000, 0) addEventHandler("onClientPickupHit", LoadOxygen, function(element) for k, v in ipairs(getElementsByType("player")) do if getElementModel(v) ~= 97 and not isElementInWater(v) then return end if element ~= localPlayer then return end setPedOxygenLevel(v, 100) end end ) Link to comment
Matevsz Posted June 19, 2016 Author Share Posted June 19, 2016 @ Edit for example, I typed setPedOxygenLevel(v, oxygen-50) and takes oxygen, but once the loading to full what is wrong? 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