Jump to content

Rank System


Recommended Posts

Hello all,i made this but don't want to work, here is the code:

exports.scoreboard:addScoreboardColumn('Rank') 
  
addEventHandler("onPlayerSpawn",root, 
function() 
    local account = getPlayerAccount(source) 
    local kills = getAccountData(account,"kills") 
if (kills >= 0) and (kills <= 4) then 
setElementData(source,"Rank","ranks/1.png") 
elseif (kills >= 5) and (kills <= 99) then 
setElementData(source,"Rank","ranks/2.png") 
elseif (kills >= 100) and (kills <= 249) then 
setElementData(source,"Rank","ranks/3.png") 
elseif (kills >= 250) and (kills <= 499) then 
setElementData(source,"Rank","ranks/4.png") 
elseif (kills >= 500) and (kills <= 999) then 
setElementData(source,"Rank","ranks/5.png") 
elseif (kills >= 1000) and (kills <= 1499) then 
setElementData(source,"Rank","ranks/6.png") 
elseif (kills >= 1500) and (kills <= 1999) then 
setElementData(source,"Rank","ranks/7.png") 
elseif (kills >= 2000) and (kills <= 2999) then 
setElementData(source,"Rank","ranks/8.png") 
elseif (kills >= 3000) and (kills <= 3999) then 
setElementData(source,"Rank","ranks/9.png") 
end 
end 
) 
  
addEventHandler("onPlayerSpawn",root, 
function () 
    local account = getPlayerAccount(source) 
    if isGuestAccount(account) then return end 
    local Rank = getAccountData(account,"Rank") 
    if Rank then 
        setElementData(source,"Rank", Rank) 
end 
end 
) 

and add to score board line

Rank = getElementData(source,"Rank") 
if Rank then 
setElementData(source,"Rank",":Script/Ranks/"..Rank..".png") 
end 
end 

Thanks....i hope somebody help

Link to comment
use
call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Rank") 

instead of

exports.scoreboard:addScoreboardColumn('Rank') 

As he said, try this.

call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Rank") 
  
addEventHandler("onPlayerSpawn",root, 
function() 
    local account = getPlayerAccount(source) 
    local kills = getAccountData(account,"kills") 
if (kills >= 0) and (kills <= 4) then 
setElementData(source,"Rank","ranks/1.png") 
elseif (kills >= 5) and (kills <= 99) then 
setElementData(source,"Rank","ranks/2.png") 
elseif (kills >= 100) and (kills <= 249) then 
setElementData(source,"Rank","ranks/3.png") 
elseif (kills >= 250) and (kills <= 499) then 
setElementData(source,"Rank","ranks/4.png") 
elseif (kills >= 500) and (kills <= 999) then 
setElementData(source,"Rank","ranks/5.png") 
elseif (kills >= 1000) and (kills <= 1499) then 
setElementData(source,"Rank","ranks/6.png") 
elseif (kills >= 1500) and (kills <= 1999) then 
setElementData(source,"Rank","ranks/7.png") 
elseif (kills >= 2000) and (kills <= 2999) then 
setElementData(source,"Rank","ranks/8.png") 
elseif (kills >= 3000) and (kills <= 3999) then 
setElementData(source,"Rank","ranks/9.png") 
end 
end 
) 
  
addEventHandler("onPlayerSpawn",root, 
function () 
    local account = getPlayerAccount(source) 
    if isGuestAccount(account) then return end 
    local Rank = getAccountData(account,"Rank") 
    if Rank then 
        setElementData(source,"Rank", Rank) 
end 
end 
) 

If it doesn't work, what is debug says?.

Link to comment

@StevyDK: Try this:

exports.scoreboard:addScoreboardColumn('Rank') 
  
addEventHandler("onPlayerLogin", root, 
function(_, account) 
    local kills = getAccountData(account, "kills") 
    if kills then 
        if (kills >= 0) and (kills <= 4) then 
            setElementData(source,"Rank","ranks/1.png") 
        elseif (kills >= 5) and (kills <= 99) then 
            setElementData(source,"Rank","ranks/2.png") 
        elseif (kills >= 100) and (kills <= 249) then 
            setElementData(source,"Rank","ranks/3.png") 
        elseif (kills >= 250) and (kills <= 499) then 
            setElementData(source,"Rank","ranks/4.png") 
        elseif (kills >= 500) and (kills <= 999) then 
            setElementData(source,"Rank","ranks/5.png") 
        elseif (kills >= 1000) and (kills <= 1499) then 
            setElementData(source,"Rank","ranks/6.png") 
        elseif (kills >= 1500) and (kills <= 1999) then 
            setElementData(source,"Rank","ranks/7.png") 
        elseif (kills >= 2000) and (kills <= 2999) then 
            setElementData(source,"Rank","ranks/8.png") 
        elseif (kills >= 3000) and (kills <= 3999) then 
            setElementData(source,"Rank","ranks/9.png") 
        end 
    end 
end) 
  

Edited by Guest
Link to comment

Gonna try....thanks all for youre help :)

but i want add column to scoreboard for it

elseif column.name == "Rank" then 
                            column.width = 20 
                            dxDrawImage( topX+theX, y+s(1), 16, 11, content, 0, 0, 0, cWhite, drawOverGUI ) 

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