Jump to content

ScoreBoardProblem


Snaik

Recommended Posts

Alright, take a look at this zombie kill/death counter :

exports.scoreboard:addScoreboardColumn('Zombie kills') 
exports.scoreboard:addScoreboardColumn('Zombie deaths')  
  
addEvent("onZombieWasted",true) 
addEventHandler("onZombieWasted",root, 
function (killer) 
    addPlayerZombieKills(killer) 
    givePlayerMoney(killer,25) 
     
end) 
  
  
function deathsByZombies(ammo,killer,weapon,bodypart) 
    if (killer) then 
    if (getElementData(killer, "zombie") == true) then 
            addPlayerZombieDeaths(source) 
            outputChatBox("Oh no, a zombie killed you..",source,255,0,0) 
        end 
    end 
end 
addEventHandler("onPlayerWasted",getRootElement(),deathsByZombies) 
  
  
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 
    local zombieDeaths = getAccountData(account,"Zombie deaths") 
    if zombieDeaths then 
        setElementData(source,"Zombie deaths",tostring(zombieDeaths)) 
    else 
        setElementData(source,"Zombie deaths",0)  
end 
end) 
  
  
  
function addPlayerZombieDeaths(source) 
    local account = getPlayerAccount(source) 
    if isGuestAccount(account) then return end 
    local zombieDeaths = getAccountData(account,"Zombie deaths") 
    if not zombieDeaths then setAccountData(account,"Zombie deaths",0) end 
    setAccountData(account,"Zombie deaths",tonumber(zombieDeaths)+1) 
end 
  
addEventHandler( "onZombieWasted", getRootElement(), 
function (killer) 
killerName = getPlayerName(killer) 
weapon = getPedWeapon(killer) 
wr, wg, wb = getPlayerNametagColor(killer) 
exports.killmessages:outputMessage ( {killerName,{"padding",width=3},{"icon",id=weapon or 0},{"padding",width=3},{"color",r=162,g=2,b=2},"Zombie"},getRootElement(),wr,wg,wb ) 
end) 
  

The problem is when i get killed by a zombie , the scorboard "zombie death"(killed by a zombie) doesn't show up that i got killed by a zombie, but it does when i reLogin.

Any help :mrgreen: ?

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