Jump to content

dx drawing functions


MAB

Recommended Posts

Hi i need your help with a dx drawing functions... i am making a dx speedometer but this my first time to deal with dx and gui stuff so i looked to the drawing functions i didn't find anything in the rectangle that makes my able to write in that rectangle

dxDrawText...do u use that to write on the rectangle? what about progress bars? how u make them inside the rectangle??

I NEED AN EXAMPLE NOT TO TELL ME WHAT FUNCTION TO USE

also the rectangles ain't getting destroyed when the player leaves the vehicle

code:

function draw () 
nitro = dxDrawRectangle(929, 619, 170, 33, tocolor(57, 59, 50, 100), false) 
fuel = dxDrawRectangle(929, 576, 170, 33, tocolor(57, 59, 50, 100), false) 
speed = dxDrawRectangle(929, 533, 170, 33, tocolor(57, 59, 50, 100), false) 
lock = dxDrawRectangle(929, 490, 170, 33, tocolor(57, 59, 50, 100), false) 
engine = dxDrawRectangle(929, 447, 170, 33, tocolor(57, 59, 50, 100), false) 
light = dxDrawRectangle(929, 404, 170, 33, tocolor(57, 59, 50, 100), false) 
end 
  
function event ()    
addEventHandler("onClientRender", root, draw) 
end 
addEventHandler("onClientPlayerVehicleEnter",getRootElement(),event) 
  
function destroy () 
destroyElement(nitro) 
destroyElement(fuel) 
destroyElement(speed) 
destroyElement(lock) 
destroyElement(engine) 
destroyElement(light) 
end 
addEventHandler("onClientPlayerVehicleExit",getRootElement(),destroy) 

Link to comment

Yes, almost everyone uses dxDrawText to write texts. As for editboxes, you can either use a real editbox, or draw another rectangle and an editbox upfront it, and set editbox's alpha to 0, that way you can write there. I personally never use progress-bars as some math can solve anything.

and destroyElements aren't used for dx things, you have to use removeEventHandler as said above.

function destroy () 
 removeEventHandler ("onClientRender", root, draw) 
end 
addEventHandler("onClientPlayerVehicleExit",getRootElement(),destroy) 

Link to comment

try this

function draw () 
local theVehicle = getPedOccupiedVehicle ( getLocalPlayer() ) 
    if ( theVehicle ) then 
        dxDrawRectangle(929, 619, 170, 33, tocolor(57, 59, 50, 100), false) 
        dxDrawRectangle(929, 576, 170, 33, tocolor(57, 59, 50, 100), false) 
        dxDrawRectangle(929, 533, 170, 33, tocolor(57, 59, 50, 100), false) 
        dxDrawRectangle(929, 490, 170, 33, tocolor(57, 59, 50, 100), false) 
        dxDrawRectangle(929, 447, 170, 33, tocolor(57, 59, 50, 100), false) 
        dxDrawRectangle(929, 404, 170, 33, tocolor(57, 59, 50, 100), false) 
    end 
end 
addEventHandler("onClientRender", root, draw) 

Link to comment
try this
function draw () 
local theVehicle = getPedOccupiedVehicle ( getLocalPlayer() ) 
    if ( theVehicle ) then 
        dxDrawRectangle(929, 619, 170, 33, tocolor(57, 59, 50, 100), false) 
        dxDrawRectangle(929, 576, 170, 33, tocolor(57, 59, 50, 100), false) 
        dxDrawRectangle(929, 533, 170, 33, tocolor(57, 59, 50, 100), false) 
        dxDrawRectangle(929, 490, 170, 33, tocolor(57, 59, 50, 100), false) 
        dxDrawRectangle(929, 447, 170, 33, tocolor(57, 59, 50, 100), false) 
        dxDrawRectangle(929, 404, 170, 33, tocolor(57, 59, 50, 100), false) 
    end 
end 
addEventHandler("onClientRender", root, draw) 

This will just show rectangle not the health or the other things

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