Jump to content

Oxygen


Matevsz

Recommended Posts

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

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