Jump to content

help with scoreboard columns


MontiVante

Recommended Posts

I have a problem when starting the resource, the scoreboard does not work the columns I get this error.

ERROR: scoreboard/export.lua:257: call: failed to call 'scoreboard:scoreboardAddColumn' [string "?"]

ERROR: scoreboard/export.lua:258: call: failed to call 'scoreboard:scoreboardAddColumn' [string "?"]

ERROR: scoreboard/export.lua:259: call: failed to call 'scoreboard:scoreboardAddColumn' [string "?"]

ERROR: scoreboard/export.lua:260: call: failed to call 'scoreboard:scoreboardAddColumn' [string "?"]

ERROR: scoreboard/export.lua:261: call: failed to call 'scoreboard:scoreboardAddColumn' [string "?"]

I have no doubt as to how to solve the error, I ask for help, thank you.


----#################################################################################################################---------------------
---- ID de país
function onPlayerJoinToServer()
    if source then
        findIDForPlayer(source)
        local country = call(getResourceFromName("admin"),"getPlayerCountry",source)
        if country then
            setElementData(source,"country",country)
        else
            setElementData(source,"country","N/A")
        end
    end
end
addEventHandler("onPlayerJoin",getRootElement(),onPlayerJoinToServer)


function findIDForPlayer(thePlayer)
    if thePlayer and not getElementData(thePlayer,"ID") then
        local i = 0
        local players = getElementsByType("player")
        repeat 
            local foundID = false
            i = i + 1
            for _,player in pairs(players) do
                if player ~= thePlayer then
                    local playerID = tonumber(getElementData(player,"ID"))
                    if playerID == i then
                        foundID = true
                        break
                    end
                end
            end
        until not foundID
        setElementData(thePlayer,"ID",i)
    end
end

function onServerIDStart()
    for i,thePlayer in pairs(getElementsByType("player")) do
        findIDForPlayer(thePlayer)
        local country = call(getResourceFromName("admin"),"getPlayerCountry",source)
        if country then
            setElementData(source,"country",country)
        else
            setElementData(source,"country","N/A")
        end
    end
end
addEventHandler("onResourceStart",resourceRoot,onServerIDStart)


----#################################################################################################################---------------------
---Veículo

setTimer ( function ( )
  local players = getElementsByType "player"

    for k, v in ipairs ( players ) do
        if ( isPedInVehicle(v) ) then
           local vehicle =  getPedOccupiedVehicle(v)
          local carname = getVehicleName(vehicle)
        setElementData ( v, "Veículo", tostring(carname) ) -- The element data must be exactly the same as the scoreboard column
               else
        setElementData ( v, "Veículo", "A Pie")
      end
    end

end, 2500, 0 )
----#################################################################################################################---------------------
---- Money

  function updatePlayersMoney ( ) 
        for index, player in ipairs ( getElementsByType "player" ) do 
            setElementData ( player, "Money", getPlayerMoney ( player ) ) 
        end 
    end 
    setTimer ( updatePlayersMoney, 2500, 0 ) 

----#################################################################################################################---------------------

addEventHandler ( "onResourceStart" , resourceRoot ,
    function ( )
        for index , player in ipairs ( getElementsByType ( "player" ) ) do
            local pAccount = getPlayerAccount ( player )
            if not isGuestAccount ( pAccount ) then
                local minutes = getAccountData ( pAccount , "Online.minutes" )
                if minutes then
                    local hours = getAccountData ( pAccount , "Online.hours" )
                    if # tostring ( minutes ) == 1 then
                        minutes = "0" .. minutes
                    end
                    if # tostring ( hours ) == 1 then
                        hours = "0" .. hours
                    end
                    setElementData ( player , "PlayTime" , hours .. " H: " .. minutes .. " M" )
                    local timer = setTimer ( actualizarJugadorOn , 60000 , 1 , player )
                    setElementData ( player , "Online.timer" , timer )
                else
                    setAccountData ( pAccount , "Online.minutes" , 0 )
     
              setAccountData ( pAccount , "Online.hours" , 0 )
                    setElementData ( player , "PlayTime" , "0 H : 0 M" )
                    local timer = setTimer ( actualizarJugadorOn , 60000 , 1 , player )
                    setElementData ( player , "Online.timer" , timer )
                end
            else
                setElementData ( player , "PlayTime" , "N/A" )
            end
        end
    end
)
 
addEventHandler ( "onResourceStop" , resourceRoot ,
    function ( )
        for index , player in ipairs ( getElementsByType ( "player" ) ) do
            local pAccount = getPlayerAccount ( player )
            if not isGuestAccount ( pAccount ) then
                local timer = getElementData ( player , "Online.timer" )
                if isTimer ( timer ) then
                    killTimer ( timer )
                end
            end
        end
    end
)
 
addEventHandler ( "onPlayerLogin" , root ,
    function ( _ , pAccount )
        local minutes = getAccountData ( pAccount , "Online.minutes" )
        if minutes then
            local hours = getAccountData ( pAccount , "Online.hours" )
            if # tostring ( minutes ) == 1 then
                minutes = "0" .. minutes
            end
            if # tostring ( hours ) == 1 then
                hours = "0" .. hours
            end
            setElementData ( source , "PlayTime" , hours .. " H : " .. minutes .. " M" )
            local timer = setTimer ( actualizarJugadorOn , 60000 , 1 , source )
            setElementData ( source , "Online.timer" , timer )
        else
            setAccountData ( pAccount , "Online.minutes" , 0 )
            setAccountData ( pAccount , "Online.hours" , 0 )
            setElementData ( source , "PlayTime" , "00 H : 00 M" )
            local timer = setTimer ( actualizarJugadorOn , 60000 , 1 , source )
            setElementData ( source , "Online.timer" , timer )
        end
    end
)
 
addEventHandler ( "onPlayerLogout" , root ,
    function ( pAccount )
        local timer = getElementData ( source , "Online.timer" )
        if isTimer ( timer ) then
            killTimer ( timer )
        end
    end
)
 
addEventHandler ( "onPlayerJoin" , root ,
    function ( )
        setElementData ( source , "PlayTime" , "N/A" )
    end
)
 
addEventHandler ( "onPlayerQuit" , root ,
    function ( )
        local pAccount = getPlayerAccount ( source )
        if not isGuestAccount ( pAccount ) then
            local timer = getElementData ( source , "Online.timer" )
            if isTimer ( timer ) then
                killTimer ( timer )
            end
        end
    end
)
 
function actualizarJugadorOn ( player )
    local pAccount = getPlayerAccount ( player )
    local minutes = getAccountData ( pAccount , "Online.minutes" )
    local hours = getAccountData ( pAccount , "Online.hours" )
    minutes = tostring ( tonumber ( minutes ) + 1 )
    if minutes == "60" then
        hours = tostring ( tonumber ( hours ) + 1 )
        minutes = "00"
    end
    setAccountData ( pAccount , "Online.minutes" , tonumber ( minutes ) )
    setAccountData ( pAccount , "Online.hours" , tonumber ( hours ) )
    if # tostring ( minutes ) == 1 then minutes = "0" .. minutes end
    if # tostring ( hours ) == 1 then hours = "0" .. hours end
    setElementData ( player , "PlayTime" , hours .. " H : " .. minutes .. " M" )
    local timer = setTimer ( actualizarJugadorOn , 60000 , 1 , player )
    setElementData ( player , "Online.timer" , timer )
end
----#################################################################################################################---------------------

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

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)
----#################################################################################################################---------------------

addEvent ( "onBotWasted", true ) 
addEventHandler ( "onBotWasted", root, 
    function ( killer ) 
        addPlayerBossKills ( killer ) 
   end 
)
  
function addPlayerBossKills ( killer ) 
    local account = getPlayerAccount ( killer ) 
    if isGuestAccount ( account ) then 
       return 
    end 
  
   local BossKills = tonumber ( getAccountData ( account, "Boss kills" ) ) or 0 
    setAccountData ( account, "Boss kills", tonumber ( BossKills ) + 1 ) 
   setElementData ( killer, "Boss kills", tonumber ( BossKills ) + 1 ) 
end 
  
addEventHandler ( "onPlayerLogin", root, 
    function ( _, account ) 
        local BossKills = tonumber ( getAccountData ( account, "Boss kills" ) ) or 0 
        setElementData ( source, "Boss kills", BossKills ) 
    end 
) 
----#################################################################################################################---------------------
exports["scoreboard"]:scoreboardAddColumn ( "Zombie kills", root, 50, "Z.kill",5)
exports["scoreboard"]:scoreboardAddColumn ( "Boss kills", root, 29,"B.Kill",6)
exports["scoreboard"]:scoreboardAddColumn ( "Money", root, 50, "Dinero",8)
exports["scoreboard"]:scoreboardAddColumn ( "PlayTime", root, 70, "Horas",3)
exports["scoreboard"]:scoreboardAddColumn ( "Veículo", root, 60, "Vehiculo",8)

 

Link to post

"scoreboard" is an old resource, check to see if scoreboard even exists in your resource folder. The new one is dxscoreboard, same syntax I guess.

Also, I would advise you to remove your code and just leave the exports, as far as I could see your code should work fine. Just the exports that aren't being called properly. Syntax looks correct, no typos spotted either.

If you do have the old scoreboard, try updating to dxscoreboard and running the code again, let me know if there's any errors.

Link to post

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