-.Paradox.- Posted October 1, 2013 Share Posted October 1, 2013 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 Link to comment
Castillo Posted October 1, 2013 Share Posted October 1, 2013 How are you saving the level? Link to comment
-.Paradox.- Posted October 2, 2013 Author Share Posted October 2, 2013 Can't understand It's the XP system that you helped me with Link to comment
Mefisto_PL Posted October 2, 2013 Share Posted October 2, 2013 He ask about HOW are you saving it. Using setElementData or MySQL or another way ? Link to comment
.:HyPeX:. Posted October 2, 2013 Share Posted October 2, 2013 He ask about HOW are you saving it. Using setElementData or MySQL or another way ? Searching user's post.. found this viewtopic.php?f=91&t=63362&p=617760#p617760 we should suppose he is using elementData then. Link to comment
Mefisto_PL Posted October 2, 2013 Share Posted October 2, 2013 But I won't search his posts for help him, he should write what he's using. Link to comment
myonlake Posted October 2, 2013 Share Posted October 2, 2013 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 ) Link to comment
-.Paradox.- Posted October 3, 2013 Author Share Posted October 3, 2013 @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 Link to comment
myonlake Posted October 3, 2013 Share Posted October 3, 2013 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. Link to comment
-.Paradox.- Posted October 3, 2013 Author Share Posted October 3, 2013 Thanks a lot but where I can write the name of image like example "experience/ranks/lvl_"..Level..".png" Link to comment
myonlake Posted October 3, 2013 Share Posted October 3, 2013 In the fifth argument of dxDrawImage, change "images" to "experience/ranks/lvl_". Link to comment
-.Paradox.- Posted October 3, 2013 Author Share Posted October 3, 2013 Ok thanks and can I use LV instead of Lvl because that's what I'm using and thanks Link to comment
myonlake Posted October 4, 2013 Share Posted October 4, 2013 Sure, the main point being that you understand what the code does. You're welcome. Link to comment
-.Paradox.- Posted October 7, 2013 Author Share Posted October 7, 2013 I need one more thing, the image of levels are lvl_1.png lvl_2.png ........... lvl_23.png Were i have to define the name of the png file? Link to comment
myonlake Posted October 7, 2013 Share Posted October 7, 2013 Quote In the fifth argument of dxDrawImage, change "images" to "experience/ranks/lvl_". Link to comment
-.Paradox.- Posted October 7, 2013 Author Share Posted October 7, 2013 Ok thanks and sorry i tought it's wrong that why i asked. Link to comment
-.Paradox.- Posted October 9, 2013 Author Share Posted October 9, 2013 Won't work there is an error in debug dxDrawImage[Can't load] Link to comment
myonlake Posted October 9, 2013 Share Posted October 9, 2013 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. Link to comment
-.Paradox.- Posted October 9, 2013 Author Share Posted October 9, 2013 Actually there is another error in guiGetScreenSize Link to comment
myonlake Posted October 9, 2013 Share Posted October 9, 2013 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. Link to comment
-.Paradox.- Posted October 9, 2013 Author Share Posted October 9, 2013 I'm using LV and name of the images are lvl_1.png etc Link to comment
myonlake Posted October 9, 2013 Share Posted October 9, 2013 If the element data value is "LV1", "LV2"... then you have to change the string.gsub's second argument to match "LV" or so. 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