Jump to content

Zombie Kills Scoreboard


Recommended Posts

exports.scoreboard:addScoreboardColumn('Zombie Kills') 
  
addEvent("onZombieWasted",true) 
addEventHandler("onZombieWasted",root, 
function (killer) 
givePlayerMoney(killer, 10) 
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) 

Theres no problem in debug, but it does not update the scoreboard. Scoreboard is just updating when player reconnects. How can I update the zombie kills scoreboard just like in 5 secs.

Link to comment
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) 
    setElementData(killer, "Zombie Kills", tonumber(zombieKills)+1) 
end 

Link to comment

You must add setElementData when you kill a zombie example:

* Code

  
function addPlayerZombieKills(killer) 
     local account = getPlayerAccount(killer) 
        if isGuestAccount(account) then return end 
          local zombieKills = getAccountData(account,"Zombie Kills") or 0 
        setAccountData(account,"Zombie Kills",tonumber(zombieKills)+1) 
      setElementData(killer, "Zombie Kills", tonumber(zombieKills)+1) 
end 
  

* Scoreboard

scoreboardAddColumn("Zombie Kills", root, 55, "Kills") 

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