Jump to content

Zombie Rank images.


-Blaze-

Recommended Posts

hello people ,

so, yesterday i made a zombie rank script that shows images in the scoreboard according to the players rank.

The images get's drawn in the scoreboard, but the the image is always the same (1.png). Even though i rank up , the image stays the same. Could someone help?

exports.scoreboard:addScoreboardColumn('Zombie kills') 
  
addEvent("onZombieWasted",true) 
addEventHandler("onZombieWasted",root, 
function (killer) 
    givePlayerMoney(killer,20) 
    addPlayerZombieKills(killer) 
  
end) 
  
  
function addPlayerZombieKills(killer) 
    local account = getPlayerAccount(killer) 
    if isGuestAccount(account) then return end 
    local zombieKills = getAccountData(account,"Zombie kills") 
    if not zombieKills then setAccountData(account,"Zombie kills",0) end 
    setAccountData(account,"Zombie kills",tonumber(zombieKills)+1) 
end 
  
  
addEventHandler("onPlayerLogin",root, 
function () 
    local account = getPlayerAccount(source) 
    if isGuestAccount(account) then return end 
    local zombieKills = getAccountData(account,"Zombie kills") 
    if zombieKills then 
        setElementData(source,"Zombie kills",tostring(zombieKills)) 
    else 
        setElementData(source,"Zombie kills",0)     
  
end 
end) 
  
------------------------------------------------------------------------------------------------------------------ 
  
  
addEventHandler("onPlayerSpawn",root, 
function() 
    local account = getPlayerAccount(source) 
    local zombiekills = getAccountData(account,"Zombie kills") or 0 
if (zombiekills >= 0) and (zombiekills <= 4) then 
setAccountData ( account, "icon", ":myranks/img/1.png" ) 
elseif (zombiekills >= 5) and (zombiekills <= 99) then 
setAccountData ( account, "icon", ":myranks/img/2.png" ) 
elseif (zombiekills >= 100) and (zombiekills <= 249) then 
setAccountData ( account, "icon", ":myranks/img/3.png" ) 
elseif (zombiekills >= 250) and (zombiekills <= 499) then 
setAccountData ( account, "icon", ":myranks/img/4.png" ) 
elseif (zombiekills >= 500) and (zombiekills <= 999) then 
setAccountData ( account, "icon", ":myranks/img/5.png" ) 
elseif (zombiekills >= 1000) and (zombiekills <= 1499) then 
setAccountData ( account, "icon", ":myranks/img/6.png" ) 
elseif (zombiekills >= 1500) and (zombiekills <= 1999) then 
setAccountData ( account, "icon", ":myranks/img/7.png" ) 
elseif (zombiekills >= 2000) and (zombiekills <= 2999) then 
setAccountData ( account, "icon", ":myranks/img/8.png" ) 
elseif (zombiekills >= 3000) and (zombiekills <= 3999) then 
setAccountData ( account, "icon", ":myranks/img/9.png" ) 
elseif (zombiekills >= 4000) and (zombiekills <= 4999) then 
setAccountData ( account, "icon", ":myranks/img/10.png" ) 
elseif (zombiekills >= 5000) and (zombiekills <= 5999) then 
setAccountData ( account, "icon", ":myranks/img/11.png" ) 
elseif (zombiekills >= 5000) and (zombiekills <= 5999) then 
setAccountData ( account, "icon", ":myranks/img/12.png" ) 
elseif (zombiekills >= 6000) and (zombiekills <= 6999) then 
setAccountData ( account, "icon", ":myranks/img/13.png" ) 
elseif (zombiekills >= 7000) and (zombiekills <= 7999) then 
setAccountData ( account, "icon", ":myranks/img/14.png" ) 
elseif (zombiekills >= 8000) and (zombiekills <= 8999) then 
setAccountData ( account, "icon", ":myranks/img/15.png" ) 
elseif (zombiekills >= 9000) and (zombiekills <= 10000000) then 
setAccountData ( account, "icon", ":myranks/img/16.png" ) 
end 
end 
) 

--Server Two--

  
exports.scoreboard:addScoreboardColumn("Rank",getRootElement(),1,40,"Rank") 
function scoreLevel () 
     local account = getPlayerAccount(source) 
     local icon = tonumber(getAccountData(account,"Icon")) or "1" 
    if isGuestAccount ( account ) then 
       setElementData(source, "Rank",":myranks/img/1.png") 
   else 
        setElementData(source, "Rank", ":myranks/img/"..tostring(icon)..".png" )                                       
    end 
end 
  
addEventHandler("onPlayerSpawn", getRootElement(), scoreLevel) 
  
  
  
  
  

Link to comment

Server side 2 script should be:

  
exports.scoreboard:addScoreboardColumn("Rank",getRootElement(),1,40,"Rank") 
function scoreLevel () 
     local account = getPlayerAccount(source) 
     local icon = tonumber(getAccountData(account,"icon")) or "1" 
    if isGuestAccount ( account ) then 
       setElementData(source, "Rank",":myranks/img/1.png") 
   else 
        setElementData(source, "Rank", ":myranks/img/"..tostring(icon)..".png" )                                       
    end 
end 
  
addEventHandler("onPlayerSpawn", getRootElement(), scoreLevel) 

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