Jump to content

DxDraw


-.Paradox.-

Recommended Posts

Try this :

addEventHandler ( 'onPlayerJoin', root, 
    function ( ) 
        setElementData ( source, 'Rankicon', ':Class/Rank/rank_0.png' ); 
    end 
); 
  
addEventHandler ( 'onPlayerLogin', root, 
    function( _, account ) 
        local LV = tonumber( getAccountData( account, 'LV' ) ); 
        if ( LV and LV > 0 ) then 
            setElementData ( source, 'Rankicon', ':Class/Rank/rank_'..LV..'.png' ); 
        elseif ( LV == 50 or >= 50 )then 
            setElementData ( source, 'Rankicon', ':Class/Rank/rank_50.png' ); 
        else 
            setElementData ( source, 'Rankicon', ':Class/Rank/rank_0.png' ); 
        end 
    end 
); 

Link to comment
Not working too, also I reset my account xp and I change the element data and still nothing

I've already tried mine, so it should be working. It would be helpful if you could post all of the code.

If you don't feel too keen on doing it on the forums, you can go ahead and PM me. Also, if you have any error or warnings, post those too. :)

Link to comment

I can post it here, and i made new ranks images so i wont repeat them, anyway here is the code

Server

addEventHandler ( 'onPlayerJoin', root, 
    function ( ) 
        setElementData ( source, 'Rankimage', ':Class/Rank/rank_0.png' ); 
    end 
); 
  
addEventHandler ( 'onPlayerLogin', root, 
    function( _, account ) 
        local LV = tonumber( getAccountData( account, 'LV' ) ); 
        if ( LV and LV > 0 ) then 
            setElementData ( source, 'Rankimage', ':Class/Rank/rank_'..LV..'.png' ); 
        elseif ( LV == 50 )then 
            setElementData ( source, 'Rankimage', ':Class/Rank/rank_50.png' ); 
        else 
            setElementData ( source, 'Rankimage', ':Class/Rank/rank_0.png' ); 
        end 
    end 
); 

Client

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

Link to comment

The "if / elseif" is again a bit wrong.

elseif ( LV == 50 )then --- this will be executed if LV is nil , if LV is nil , you will compare nil with a number = error.

Secound you can avoid this case when LV it will be nil.

Also that the "if ( LV > 0 )" will handle every rank bk all LV's are bigger that 0 , so that LV == 50 will be never checked.

addEventHandler ( 'onPlayerLogin', root, 
    function( _, account ) 
        local LV = tonumber( getAccountData( account, 'LV' ) or 0 ); 
        if (LV >= 50 ) then 
            setElementData ( source, 'Rankimage', ':Class/Rank/rank_50.png' ); 
        elseif ( LV > 0 )then 
            setElementData ( source, 'Rankimage', ':Class/Rank/rank_'..LV..'.png' ); 
        else 
            setElementData ( source, 'Rankimage', ':Class/Rank/rank_0.png' ); 
        end 
    end 
); 

Link to comment

Try to change your exp system to this:

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", 1) 
        elseif tonumber(H) == 400 then 
        setElementData(killer, "Level", 2) 
        elseif tonumber(H) == 600 then 
        setElementData(killer, "Level", 3) 
        elseif tonumber(H) == 800 then 
        setElementData(killer, "Level", 4) 
        elseif tonumber(H) == 1000 then 
        setElementData(killer, "Level", 5) 
        elseif tonumber(H) == 1200 then 
        setElementData(killer, "Level", 6) 
        elseif tonumber(H) == 1400 then 
        setElementData(killer, "Level", 7) 
        elseif tonumber(H) == 1600 then 
        setElementData(killer, "Level", -- s8) -->
        elseif tonumber(H) == 1800 then 
        setElementData(killer, "Level", 9) 
        elseif tonumber(H) == 2000 then 
        setElementData(killer, "Level", 10) 
        elseif tonumber(H) == 2200 then 
        setElementData(killer, "Level", 11) 
        elseif tonumber(H) == 2400 then 
        setElementData(killer, "Level", 12) 
        elseif tonumber(H) == 2600 then 
        setElementData(killer, "Level", 13) 
        elseif tonumber(H) == 2800 then 
        setElementData(killer, "Level", 14) 
        elseif tonumber(H) == 4000 then 
        setElementData(killer, "Level", 15) 
        elseif tonumber(H) == 4200 then 
        setElementData(killer, "Level", 16) 
        elseif tonumber(H) == 4400 then 
        setElementData(killer, "Level", 17) 
        elseif tonumber(H) == 4600 then 
        setElementData(killer, "Level", 18) 
        elseif tonumber(H) == 4800 then 
        setElementData(killer, "Level", 19) 
        elseif tonumber(H) == 4900 then 
        setElementData(killer, "Level", 20) 
        elseif tonumber(H) == 7000 then 
        setElementData(killer, "Level", 21) 
        elseif tonumber(H) == 9000 then 
        setElementData(killer, "Level", 22) 
        elseif tonumber(H) == 10000 then 
        setElementData(killer, "Level", 23) 
        elseif tonumber(H) == 12000 then 
        setElementData(killer, "Level", 24) 
        elseif tonumber(H) == 13000 then 
        setElementData(killer, "Level", 25) 
        elseif tonumber(H) == 14000 then 
        setElementData(killer, "Level", 26) 
        elseif tonumber(H) == 15000 then 
        setElementData(killer, "Level", 27) 
        elseif tonumber(H) == 16000 then 
        setElementData(killer, "Level", 28) 
        elseif tonumber(H) == 17000 then 
        setElementData(killer, "Level", 29) 
        elseif tonumber(H) == 20000 then 
        setElementData(killer, "Level", 30) 
        elseif tonumber(H) == 22000 then 
        setElementData(killer, "Level", 31) 
        elseif tonumber(H) == 24000 then 
        setElementData(killer, "Level", 32) 
        elseif tonumber(H) == 26000 then 
        setElementData(killer, "Level", 33) 
        elseif tonumber(H) == 28000 then 
        setElementData(killer, "Level", 34) 
        elseif tonumber(H) == 30000 then 
        setElementData(killer, "Level", 35) 
        elseif tonumber(H) == 32000 then 
        setElementData(killer, "Level", 36) 
        elseif tonumber(H) == 34000 then 
        setElementData(killer, "Level", 37) 
        elseif tonumber(H) == 36000 then 
        setElementData(killer, "Level", 38) 
        elseif tonumber(H) == 38000 then 
        setElementData(killer, "Level", 39) 
        elseif tonumber(H) == 40000 then 
        setElementData(killer, "Level", 40) 
        elseif tonumber(H) == 42000 then 
        setElementData(killer, "Level", 41) 
        elseif tonumber(H) == 44000 then 
        setElementData(killer, "Level", 42) 
        elseif tonumber(H) == 46000 then 
        setElementData(killer, "Level", 43) 
        elseif tonumber(H) == 48000 then 
        setElementData(killer, "Level", 44) 
        elseif tonumber(H) == 50000 then 
        setElementData(killer, "Level", 45) 
        elseif tonumber(H) == 52000 then 
        setElementData(killer, "Level", 46) 
        elseif tonumber(H) == 54000 then 
        setElementData(killer, "Level", 47) 
        elseif tonumber(H) == 56000 then 
        setElementData(killer, "Level", 48) 
        elseif tonumber(H) == 58000 then 
        setElementData(killer, "Level", 49) 
        elseif tonumber(H) == 60000 then 
        setElementData(killer, "Level", 50) 
        end 
    end 
end 
addEventHandler( "onZombieWasted", getRootElement(), win) 
  
function onLogin (_,account) 
    setElementData(source, "Level", getAccountData(account, "LV") or "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 
) 

Link to comment

As I see you're doing it wrong. I'm saying this because I've made something similar to this, Just tell me what exactly do you want and I'll make it by tomorrow. I'm on from my mobile but anyways setElementData and getElementData works like This:

local LV = "5" 
setElementData ( player, "XP", LV ) 
if tonumber ( getElementData ( player, "XP" ) ) == "5" or 5 then 
  
-- THEN I ROCK. 

also first you need to get the players account in order to get his account data.

  
account = getPlayerAccount(source) 
getAccountData(account,"money") 

-- HERE

Tested and it works 100 %.

addEventHandler ( "onPlayerJoin", root, 
    function ( ) 
        setElementData( source,  "LV", false) 
        setElementData( source,  "LV", "3") 
        setElementData ( source, "Rankicon", false ) 
    end 
) 
  
addEventHandler ( "onPlayerLogin", root, 
    function ( _, acc ) 
        local LV = tonumber (getElementData( source, "LV")) 
        if LV == 0 then 
        -- if LV is equal to 0 then -- 
            setElementData ( source, "Rankicon", ":Class\\Rank\\rank_0.png" ) 
        elseif LV > 0 and LV < 2 then 
        -- means LV is greater than 0 and lesser than 2 so its 1. 
            setElementData ( source, "Rankicon", ":Class\\Rank\\rank_1.png" ) 
        elseif LV > 1 and LV < 3 then 
             setElementData ( source, "Rankicon", ":Class\Rank\\rank_2.png" ) 
    -- now here if LV is greater than 1 and lesser than 3 then its 2  
    -- so its simple math and I think you can do other thing by yourself 
     -- Use setElementData, getAccountData sucks.  
        elseif LV > 2 and LV < 4 then 
        -- so here its 3. 
            setElementData ( source, "Rankicon", ":Class\\Rank\\rank_3.png" ) 
    end 
    end 
) 

Link to comment

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