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,
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
)