Jump to content

dxDraw


-.Paradox.-

Recommended Posts

Posted

Hey guys, i made a XP/Level System, and i want to make an image for every level, like example if player is Level 1 then draw "lvl_1.png" image near the XP/Level hud text,

i know how to use dxDrawImage, but the problem is the rank icon, my Level system is based on setElementData("Level"), setElementData("XP"), setAccountData(theAccount, "LV", getElementData(thePlayer, "Level")), setAccountData (theAccount, "EXP", getElementData(thePlayer, "XP"))

And maybe an image would help,

Capture.png

Thanks for help have a great day

Those are my codes;

That's my XP/Level script

function win(killer, weapon, bodypart) 
    if (killer and getElementType(killer) == "player" and killer ~= source) then 
        local H = getElementData(killer, "XP") or 0 
        local S = getElementData(killer, "Level") 
        local killer1 = getPlayerName(killer) 
        local noob = getPlayerName(source) 
        local X = 5 
        setElementData(killer, "XP", tonumber(H)+X) 
        local H = tonumber(H) + X 
        if tonumber(H) == 100 then 
        setElementData(killer, "Level", "LV 1") 
        elseif tonumber(H) == 400 then 
        setElementData(killer, "Level", "LV 2") 
        elseif tonumber(H) == 600 then 
        setElementData(killer, "Level", "LV 3") 
        elseif tonumber(H) == 800 then 
        setElementData(killer, "Level", "LV 4") 
        elseif tonumber(H) == 1000 then 
        setElementData(killer, "Level", "LV 5") 
        elseif tonumber(H) == 1200 then 
        setElementData(killer, "Level", "LV 6") 
        elseif tonumber(H) == 1400 then 
        setElementData(killer, "Level", "LV 7") 
        elseif tonumber(H) == 1600 then 
        setElementData(killer, "Level", "LV 8") 
        elseif tonumber(H) == 1800 then 
        setElementData(killer, "Level", "LV 9") 
        elseif tonumber(H) == 2000 then 
        setElementData(killer, "Level", "LV 10") 
        end 
    end 
end 
addEventHandler( "onZombieWasted", getRootElement(), win) 
  
function onLogin (_,account) 
    setElementData(source, "Level", getAccountData(account, "LV") or "LV 0") 
    setElementData(source, "XP", getAccountData(account, "EXP") or "0") 
end 
addEventHandler ("onPlayerLogin", root, onLogin) 
  
function saveData(thePlayer, theAccount) 
local theAccount = getPlayerAccount(source) 
    if (theAccount and not isGuestAccount(theAccount)) then 
        setAccountData (theAccount, "LV", getElementData(thePlayer, "Level")) 
        setAccountData (theAccount, "EXP", getElementData(thePlayer, "XP")) 
    end 
end 
  
addEventHandler ("onPlayerQuit", root, function () saveData(source, getPlayerAccount(source)) end) 
addEventHandler ("onPlayerLogout", root, function (prev) saveData(source, prev) end) 
  
  
addCommandHandler ( "setxp", 
    function ( thePlayer, _, who, XP ) 
        local XP = tonumber ( XP ) or 0 
        local ThePlayer = getPlayerFromName ( who ) 
        if ( ThePlayer ) then 
           setElementData( ThePlayer,"XP",XP ) 
        end 
    end 
) 

That's what i tried to draw a rank icon

CLIENT:

addEventHandler ( "onClientRender", root, 
    function ( ) 
        local Rankicon = getElementData ( localPlayer, "rank.icon" ) 
        if ( Rankicon and fileExists ( rank ) ) then 
           dxDrawImage(1173, 265, 36, 41, Rankicon, 0, 0, 0, tocolor(255, 255, 255, 255), true) 
        end 
    end 
) 

SERVER:

addEventHandler ( "onPlayerJoin", root, 
    function ( ) 
        setElementData ( source, "rank.icon",":Ranks\\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, "rank.icon", ":Ranks\\rank\\rank_0.png" ) 
        elseif (LV == 1) then 
            setElementData ( source, "rank.icon", ":Ranks\\rank\\rank_1.png" ) 
        elseif (LV == 2) then 
            setElementData ( source, "rank.icon", ":Ranks\\rank\\rank_2.png" ) 
        elseif (LV == 3) then 
            setElementData ( source, "rank.icon", ":Ranks\\rank\\rank_3.png" ) 
        elseif (LV == 4) then 
            setElementData ( source, "rank.icon", ":Ranks\\rank\\rank_4.png" ) 
        elseif (LV == 5) then 
            setElementData ( source, "rank.icon", ":Ranks\\rank\\rank_5.png" ) 
        elseif (LV == 6) then 
            setElementData ( source, "rank.icon", ":Ranks\\rank\\rank_6.png" ) 
        elseif (LV == 7) then 
            setElementData ( source, "rank.icon", ":Ranks\\rank\\rank_7.png" ) 
        elseif (LV == 8 ) then 
            setElementData ( source, "rank.icon", ":Ranks\\rank\\rank_8.png" ) 
        elseif (LV == 9) then 
            setElementData ( source, "rank.icon", ":Ranks\\rank\\rank_9.png" ) 
        elseif (LV == 10) then 
            setElementData ( source, "rank.icon", ":Ranks\\rank\\rank_10.png" ) 
        else 
            setElementData ( source, "rank.icon", ":Ranks\\rank\\rank_0.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

Your last code is no sense. Look.

local lvl = getElementData(localPlayer, "Level") 
dxDrawImage(x, y, width, height, ":Ranks/rank/rank_"..lvl..".png") 

If you have 13 lvl, it will draw image rank_13.png.

Posted (edited)

Exactly, that's what i want, let me try it

Edited by Guest

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

My XP/Level script is working fine.

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

Thanks @WhoAmI i didn't think about you're solution,

Here are some pics

lol.png

lol1.png

lol2.png

lol3.png

lol4.png

And @WASSIm. My code has no errors and working fine, i won't use you're script.

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