Jump to content

Making Levels Show In Scoreboard help!


kewizzle

Recommended Posts

exports.scoreboard:addScoreboardColumn('Level') 
  
addEvent("onPlayerLevelUp",true) 
addEventHandler("onPlayerLevelUp",root, 
function (source) 
    givePlayerMoney(source,math.random(1000)) 
    addPlayerLevel(source) 
  
end) 
  
function addPlayerLevel(source) 
    local account = getPlayerAccount(source) 
    if isGuestAccount(account) then return end 
    local Level = getAccountData(account,"Level") 
    if not Level then setAccountData(account,"Level",0) end 
    setAccountData(account,"Level",tonumber(Level)+1) 
end 
  
addEventHandler("onPlayerLogin",root, 
function () 
    local account = getPlayerAccount(source) 
    if isGuestAccount(account) then return end 
    local Level = getAccountData(account,"Level") 
    if zombieKills then 
        setElementData(source,"Level",tostring(Level)) 
    else 
        setElementData(source,"Level",0)     
  
end 
end) 

All it does is show 0 in scoreboard i think i have the elements wrong but help me out here

i know it only shows 0 in the scoreboard cause of the login function

Link to comment

I FUCKING DID IT MYSELF :')

exports.scoreboard:addScoreboardColumn('level') 
  
addEvent("onPlayerlevelUp",true) 
addEventHandler("onPlayerlevelUp",root, 
function (source) 
    givePlayerMoney(source,math.random(1000)) 
    addPlayerlevel(source) 
  
end) 
  
function addPlayerlevel(source) 
    local account = getPlayerAccount(source) 
    if isGuestAccount(account) then return end 
    local level = tonumber ( getElementData ( player, "level" ) or 0 ) 
    if not level then setAccountData(account,"level",0) end 
    setAccountData(account,"level",tonumber(level)+1) 
end 
  
addEventHandler("onPlayerLogin",root, 
function () 
    local account = getPlayerAccount(source) 
    if isGuestAccount(account) then return end 
    local level = tonumber ( getElementData ( player, "level" ) or 0 ) 
    if level then 
        setElementData(source,"level",tostring(level)) 
    else 
        setElementData(source,"level",0)     
  
end 
end) 
  

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