Jump to content

Help please


-.Paradox.-

Recommended Posts

Posted

Hello I want a little help,

I have a ranking system with levels and I want use if player level is 1 then draw an image "lvl_1.png" and if player level is 0 then draw "lvl_0.png" can somebody suggest to me what I could use for that and thanks

Posted

You have to use either GUI Static images or DirectX image drawings. Here is an example on how to draw an image with dxDrawImage. Make sure you have put the file in the images folder inside the resource and make sure the extension is right.

Client-side

local sx, sy = guiGetScreenSize() -- Get screen width and height 
local imageWidth, imageHeight = 100, 100 -- Define image width and height 
local imageExtension = "png" -- Define image extension (i.e. 'png', 'jpg', 'gif'...) 
local imageAlpha = 255 -- Define image transparency (alpha) 
local postGUI = true -- Define whether the image will be drawn on top of GUIs or beneath the GUIs 
  
-- Start rendering 
addEventHandler("onClientRender", root, 
 function() 
  local level = getElementData(localPlayer, "Level") -- Get the element data for the level 
  if (not level) then return end -- If player has no level element data -> return end 
  dxDrawImage((sx-imageWidth)/2, (sy-imageHeight)/2, imageWidth, imageHeight, "images/" .. string.gsub(level, "Lvl ", "") .. "." .. imageExtension, 0, 0, 0, tocolor(255, 255, 255, imageAlpha), postGUI) -- Draw the image 
 end 
) 

Posted
StevyDK said:
@Mefisto_PL I'm using setElementData

@myonlake thanks but I know how to draw images my problem is what I must use to create the script

Take a look at the code I posted. That's an example on how to make it work with your system, should work, but you have to do the rest yourself.

Posted

What's the full error. It should display the file path. Apparently there is no file in the path specified.

Also, make sure you've added the file into the meta.xml.

Posted

Apparently it's just a random error whenever the rendering process begins, but that's normal behavior as the image isn't loaded yet. You can add a fileExists() function there if you want, but the image should still display. I tested it myself and it works just fine.

Make sure the element data is similar to this: "Lvl 1", "Lvl 2" and so on, otherwise the gsub doesn't work.

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