Jump to content

DxDrawImage


-.Paradox.-

Recommended Posts

Posted

okay so i made this script, this suppose to set an image for a specified level like example:

if player lvl is 1 then draw lvl_1.png etc and the porblem is it wont draw the image icon and there is nothing in debug so here is my code

Server side

addEventHandler ( "onPlayerJoin", root, 
    function ( ) 
        setElementData ( source, "Rankicon",":Class\Rank\rank_0.png" ) 
    end 
) 
  
addEventHandler ( "onPlayerLogin", root, 
    function ( _, acc ) 
        local accName = getAccountName ( acc ) 
        local LV = getAccountData(acc, "LV") 
        if (LV >= 0) then 
            setElementData ( source, "Rankicon", ":Class\Rank\rank_0.png" ) 
        elseif (LV >= 1) then 
            setElementData ( source, "Rankicon", ":Class\Rank\rank_1.png" ) 
        elseif (LV >= 2) then 
            setElementData ( source, "Rankicon", ":Class\Rank\rank_2.png" ) 
        elseif (LV >= 3) then 
            setElementData ( source, "Rankicon", ":Class\Rank\rank_3.png" ) 
        elseif (LV >= 4) then 
            setElementData ( source, "Rankicon", ":Class\Rank\rank_4.png" ) 
        elseif (LV >= 5) then 
            setElementData ( source, "Rankicon", ":Class\Rank\rank_5.png" ) 
        elseif (LV >= 6) then 
            setElementData ( source, "Rankicon", ":Class\Rank\rank_6.png" ) 
        elseif (LV >= 7) then 
            setElementData ( source, "Rankicon", ":Class\Rank\rank_7.png" ) 
        elseif (LV >= -- s8) --> then 
            setElementData ( source, "Rankicon", ":Class\Rank\rank_8.png" ) 
        elseif (LV >= 9) then 
            setElementData ( source, "Rankicon", ":Class\Rank\rank_9.png" ) 
        elseif (LV >= 10) then 
            setElementData ( source, "Rankicon", ":Class\Rank\rank_10.png" ) 
        elseif (LV >= 11) then 
            setElementData ( source, "Rankicon", ":Class\Rank\rank_11.png" ) 
        elseif (LV >= 12) then 
            setElementData ( source, "Rankicon", ":Class\Rank\rank_12.png" ) 
        elseif (LV >= 13) then 
            setElementData ( source, "Rankicon", ":Class\Rank\rank_13.png" ) 
        elseif (LV >= 14) then 
            setElementData ( source, "Rankicon", ":Class\Rank\rank_14.png" ) 
        elseif (LV >= 15) then 
            setElementData ( source, "Rankicon", ":Class\Rank\rank_15.png" ) 
        elseif (LV >= 16) then 
            setElementData ( source, "Rankicon", ":Class\Rank\rank_16.png" ) 
        elseif (LV >= 17) then 
            setElementData ( source, "Rankicon", ":Class\Rank\rank_17.png" ) 
        elseif (LV >= 18) then 
            setElementData ( source, "Rankicon", ":Class\Rank\rank_18.png" ) 
        elseif (LV >= 19) then 
            setElementData ( source, "Rankicon", ":Class\Rank\rank_19.png" ) 
        elseif (LV >= 20) then 
            setElementData ( source, "Rankicon", ":Class\Rank\rank_20.png" ) 
        elseif (LV >= 21) then 
            setElementData ( source, "Rankicon", ":Class\Rank\rank_21.png" ) 
        elseif (LV >= 22) then 
            setElementData ( source, "Rankicon", ":Class\Rank\rank_22.png" ) 
        elseif (LV >= 23) then 
            setElementData ( source, "Rankicon", ":Class\Rank\rank_23.png" ) 
        elseif (LV >= 24) then 
            setElementData ( source, "Rankicon", ":Class\Rank\rank_24.png" ) 
        elseif (LV >= 25) then 
            setElementData ( source, "Rankicon", ":Class\Rank\rank_25.png" ) 
        elseif (LV >= 26) then 
            setElementData ( source, "Rankicon", ":Class\Rank\rank_26.png" ) 
        elseif (LV >= 27) then 
            setElementData ( source, "Rankicon", ":Class\Rank\rank_27.png" ) 
        elseif (LV >= 28) then 
            setElementData ( source, "Rankicon", ":Class\Rank\rank_28.png" ) 
        elseif (LV >= 29) then 
            setElementData ( source, "Rankicon", ":Class\Rank\rank_29.png" ) 
        elseif (LV >= 30) then 
            setElementData ( source, "Rankicon", ":Class\Rank\rank_30.png" ) 
        else 
            setElementData ( source, "Rankicon", ":Class\Rank\rank_0.png" ) 
        end 
    end 
) 

Client side

addEventHandler("onClientRender", root, 
    function() 
    local Rankicon = getElementData(localPlayer,"Rankicon") 
    local Level = getElementData(localPlayer,"Level") 
    if Level and fileExists ( ":Class/Rank/rank_"..Rankicon..".png" ) then 
    size = dxGetFontHeight((0.7/1366)*sWidth, "bankgothic") 
    dxDrawImage((557/1024)*sWidth, (745/768)*sHeight, size, size, (":Class/Rank/rank_"..Rankicon..".png") 
    end 
    end 
) 
  

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

Maybe because you are using the path wrong? in element data you are storing everything, path included, and then in dxDrawImage/fileExists you are adding the path again ( along with the saved path ), do you get what I mean?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

But how i must define the location path?

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

You already did, but in that script, you are doing it twice, and wrong.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

So is there anyway to fix it?

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 (edited)

You could edit the server side code like this:

setElementData ( source, "Rankicon", "_0.png" ) 

OR

Edit the client side like this:

if Level and fileExists ( Rankicon ) then 
dxDrawImage((557/1024)*sWidth, (745/768)*sHeight, size, size, Rankicon) 

Edited by Guest
Posted
addEventHandler ( "onClientRender", root, 
    function ( ) 
        local Rankicon = getElementData ( localPlayer, "Rankicon" ) 
        if ( Rankicon and fileExists ( Rankicon ) ) then 
            local size = dxGetFontHeight ( ( 0.7 / 1366 ) * sWidth, "bankgothic" ) 
            dxDrawImage ( ( 557 / 1024 ) * sWidth, ( 745 / 768 ) * sHeight, size, size, Rankicon ) 
        end 
    end 
) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

dxDrawImage"Can't Load File"

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

That's strange, since according to fileExists function, the file exists.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
That's strange, since according to fileExists function, the file exists.

Maybe fileOpen has to be used before-hand? I haven't really worked with those functions before, so just throwing a suggestion out there :P

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

Posted

No, that's not required.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

It doesn't make a difference, as far as I know.

Edit: No, I was wrong, you can't use "\" instead of "/", but you can use "\\".

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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