Jump to content

[HELP] Zombie EXP thing


KraZ

Recommended Posts

There are no errors and im not sure what is wrong so I was wondering if someone could help me.

addEvent ( "onZombieWasted", true ) 
function addEXP() 
local playerAccount = getPlayerAccount ( source ) 
    if ( playerAccount ) and not isGuestAccount ( playerAccount ) then 
        if ( attacker ) and ( attacker ~= source ) then  
            givePlayerMoney(7, source) 
            local experiance = getAccountData ( playerAccount, "levels.exp" ) 
            if ( experiance ) then 
                experiance = experiance + 1 
                setAccountData(playerAccount, "levels.exp", experiance) 
                triggerClientEvent ( "expDisplay", getRootElement()) 
            end 
        end 
    end        
end 
addEventHandler( "onZombieWasted", getRootElement(), addEXP) 
  
function LevelUP( source ) 
local playerAccount = getPlayerAccount ( source ) 
    if ( playerAccount ) and not isGuestAccount ( playerAccount ) then 
        local levels = getAccountData ( playerAccount, "levels.level" ) 
        local experiance = getAccountData ( playerAccount, "levels.exp" ) 
        if ( experiance == 300 ) then 
            levels = levels + 1 
            outputChatBox ( "Congratulations To" ..getPlayerName(playerAccount)" He Is Now Level:" ..getAccountData ( playerAccount, "levels.level" ), 0,255,0 ) 
            experiance = 0 
            setAccountData(playerAccount, "levels.level" ) 
            setAccountData(playerAccount, "levels.exp" ) 
            triggerClientEvent ( "lvlUPSound", getRootElement()) 
        end 
    end 
end 

Link to comment

Try this code for Zombie Wasted Event:

addEvent ( "onZombieWasted", true ) 
function addEXP(killer) 
    if (killer and killer ~= source) then 
        local playerAccount = getPlayerAccount ( killer ) 
        if ( playerAccount ) and not isGuestAccount ( playerAccount ) then 
            givePlayerMoney(7, killer) 
            local experiance = getAccountData ( playerAccount, "levels.exp" ) 
            if ( experiance ) then 
                experiance = experiance + 1 
                setAccountData(playerAccount, "levels.exp", experiance) 
                triggerClientEvent ( killer, "expDisplay", killer ) 
            else 
                setAccountData(playerAccount, "levels.exp", 1) 
                triggerClientEvent ( killer, "expDisplay", killer ) 
            end 
        end    
    end      
end 
addEventHandler( "onZombieWasted", getRootElement(), addEXP) 

P.S. i can't find where u trigger LevelUP function.

Link to comment
exports.scoreboard:addScoreboardColumn('Zombie kills') 
  
addEvent("onZombieWasted",true) 
addEventHandler("onZombieWasted",root, 
function (killer) 
    givePlayerMoney(killer,100) 
    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 

I used this in my old script, but it works only for the DXscoreboard.

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