Jump to content

Rank System


Recommended Posts

Posted

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

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

not working.

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

To Visit Us

Press Here: mtasa://5.9.206.180:22002

b648040241b8f01.png

0d0a7bb38ca13e5.png

Posted
call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Rank") 

And

exports.scoreboard:addScoreboardColumn('Rank') 

Will not make any difference.

Please do not PM me with scripting related question nor support, use the forums instead.

Posted
But the 1st one is make the code easier for beginner scripter.

I did not mean it. Both will do the same thing and it's not the problem.

Please do not PM me with scripting related question nor support, use the forums instead.

Posted (edited)

@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

Please do not PM me with scripting related question nor support, use the forums instead.

Posted

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 ) 

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