Jump to content

Oxygen Bar


-.Paradox.-

Recommended Posts

Posted

Hello guys, i made an oxygen level bar but not working, here is my code

  
addEventHandler("onClientRender", root, 
  
    function() 
  
    local oxygen = math.floor(getPedOxygenLevel ( getLocalPlayer() )) 
    if oxygen < 1000 then 
    oxygen = oxygen / 2 
    end 
        dxDrawRectangle(900, 94, 266, 20, tocolor(0, 0, 0, 255), true) 
  
        dxDrawRectangle(901, 95, 264*(oxygen/10), 18, tocolor(8, 154, 246, 255), true) 
  
    end 
  
) 

As you can see the oxygen is the sky-blue color bar and thats the bug

mta_screen_2013_12_26_11_58_20.jpg

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted
addEventHandler("onClientRender", root, 
function() 
    local oxygen = getPedOxygenLevel(localPlayer) 
    if (isElementInWater(localPlayer)) then 
        dxDrawRectangle(900, 94, 266, 20, tocolor(0, 0, 0, 255), true) 
        dxDrawRectangle(901, 95, 264*(oxygen/1000), 18, tocolor(8, 154, 246, 255), true) 
    end 
end) 

Omerta Roleplay

Posted

Still the same problem

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted
x,y = guiGetScreenSize() 
local r = x/1000 
  
addEventHandler("onClientRender", root, 
  
    function() 
  
    local oxygen = math.floor(getPedOxygenLevel ( getLocalPlayer() )) 
    if oxygen < 1000 then 
    oxygen = oxygen / 2 
    end 
        dxDrawRectangle(900, 94, 266, 20, tocolor(0, 0, 0, 255), true) 
  
        dxDrawRectangle(901, 95, oxygen*r*(1.3/264), 18, tocolor(8, 154, 246, 255), true) 
  
    end 
  
) 

rsilex.png.0e6ad382b3fdc3cbe6390e3e847572c9.png
Posted
x,y = guiGetScreenSize() 
local r = x/1000 
  
addEventHandler("onClientRender", root, 
  
    function() 
  
    local oxygen = math.floor(getPedOxygenLevel ( getLocalPlayer() )) 
    if oxygen < 1000 then 
    oxygen = oxygen / 2 
    end 
        dxDrawRectangle(900, 94, 266, 20, tocolor(0, 0, 0, 255), true) 
  
        dxDrawRectangle(901, 95, oxygen*r*(1.3/264), 18, tocolor(8, 154, 246, 255), true) 
  
    end 
  
) 

and what should "r" be?

  
addEventHandler("onClientRender", root, 
function() 
    if (isElementInWater(localPlayer)) then 
        local oxygen = getPedOxygenLevel(localPlayer) 
        dxDrawRectangle(900, 94, 266, 20, tocolor(0, 0, 0, 255), true) 
        dxDrawRectangle(901, 95, 264*(oxygen/getPedStat (localPlayer, 225)), 18, tocolor(8, 154, 246, 255), true) 
    end 
end) 
  

Try this one.

Posted

Not working but now just showing a black rectangle

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted
addEventHandler("onClientRender", root, 
  
    function() 
  
   local oxygen = math.floor (getPedOxygenLevel ( localPlayer ))  
   if  oxygen < 1000 or isElementInWater(getLocalPlayer())   then 
        dxDrawRectangle(900, 94, 266, 20, tocolor(0, 0, 0, 255), true) 
  
        dxDrawRectangle(901, 95, 264*(oxygen/100), 18, tocolor(8, 154, 246, 255), true) 
  
    end)  

USC Informations

Head Staff & Owner Of USC.

Youtube Channel : My Channel

350x20_FFFFFF_FFFFFF_A89999_080404.png

 

Posted
addEventHandler("onClientRender", root, 
  
    function() 
  
   local oxygen = math.floor (getPedOxygenLevel ( localPlayer ))  
   if  oxygen < 1000 or isElementInWater(getLocalPlayer())   then 
        dxDrawRectangle(900, 94, 266, 20, tocolor(0, 0, 0, 255), true) 
  
        dxDrawRectangle(901, 95, 264*(oxygen/100), 18, tocolor(8, 154, 246, 255), true) 
  
    end)  

Is missing 'end' to close the if statement.

Please do not PM me with scripting related question nor support, use the forums instead.

Posted
addEventHandler("onClientRender", root, 
  
    function() 
  
   local oxygen = math.floor (getPedOxygenLevel ( localPlayer )) 
   if  oxygen < 1000 or isElementInWater(getLocalPlayer())   then 
        dxDrawRectangle(900, 94, 266, 20, tocolor(0, 0, 0, 255), true) 
  
        dxDrawRectangle(901, 95, 264*(oxygen/100), 18, tocolor(8, 154, 246, 255), true) 
  
    end 
    end) 

sorry i forget it

USC Informations

Head Staff & Owner Of USC.

Youtube Channel : My Channel

350x20_FFFFFF_FFFFFF_A89999_080404.png

 

Posted
local ratio = 1000 -- Not sure, but please write here the maximum oxygen, whether its 10 100 or 1000. 
local oxygen = math.floor(getPedOxygenLevel(getLocalPlayer())/ratio) 
dxDrawRectangle(900, 94, 266, 20, tocolor(0, 0, 0, 255), true) 
dxDrawRectangle(901, 95, 264*(oxygen), 18, tocolor(8, 154, 246, 255), true) 

Posted

Still the same anyway my max oxygen level is 250 I guess it would help

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted
addEventHandler('onClientRender', root, 
    function () 
        local oxygenLevel = math.ceil(getPedOxygenLevel(getLocalPlayer())) 
        local maxOxygenLevel = 1000 + 1.5 * getPedStat(getLocalPlayer(), 225) 
  
        if oxygenLevel < maxOxygenLevel or isElementInWater(getLocalPlayer()) then 
            dxDrawRectangle(900, 94, 266, 20, tocolor(0, 0, 0, 255), true) 
            dxDrawRectangle(901, 95, math.floor(264 / maxOxygenLevel * oxygenLevel), 18, tocolor(8, 154, 246, 255), true) 
        end 
    end 
) 

Posted (edited)

it's simple and easy :3

addEventHandler("onClientRender", root, 
    function() 
    local oxygen = string.format( "%.0f", (getPedOxygenLevel ( localPlayer ) ) ) -- i remake it to it give correct value of oxygen without decimals i mean like 1.0000147 
    dxDrawRectangle(900, 94, 266, 20, tocolor(0, 0, 0, 255), true) 
    dxDrawRectangle(901, 95, (oxygen/2.5)*26.5, 18, tocolor(8, 154, 246, 255), true) 
    end 
) 

Edited by Guest

Giving a Fuck? Nope, That isn't in My Skill Set

castie11.png

Posted

Still the same :( i tried both codes

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

Idk,By the way i used /crun getPedOxygenLevel(localPlayer) and it output that my max oxygen is 250

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted
Idk,By the way i used /crun getPedOxygenLevel(localPlayer) and it output that my max oxygen is 250

in MTA wiki says oxygen: the amount of oxygen you want to set on the ped. Native values are from 0 to 1000 (At the maximum value of UNDERWATER_STAMINA full oxygen level is 2500. Higher values do not appear in the HUD). but if it's 250 them copy my code again and test

But Correct setPlayerOxygen to 1000 them replace in my code the 2.5 to 10

Giving a Fuck? Nope, That isn't in My Skill Set

castie11.png

Posted

Still not working :S

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted
addEventHandler("onClientRender", root,function() 
    local oxygen = math.floor(getPedOxygenLevel ( localPlayer )) 
    --dxDrawText (tostring(oxygen), 100, 500 ) 
    dxDrawRectangle(900, 94, 266, 20, tocolor(0, 0, 0, 255), true) 
    dxDrawRectangle(901, 95, 264*(oxygen/1000), 18, tocolor(8, 154, 246, 255), true) 
    end 
) 

It works properly for me?

P.S; your code isn't working for every screen resolution.

Sometimes I dream about cheese

Posted

I fixed it thanks a lot guys

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

I just set all the players stamina stats to 0

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

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