Jump to content

Need some scoreboard help


Bleidex

Recommended Posts

It gives "failed to call 'scoreboard:addScoreboardColumn' [string: ?]". How it should be fixed? :S

function showcountry ( ) 
    local country = ( exports.admin:getPlayerCountry ( source ) or "N/A" ) 
        setElementData ( source, "Country", country ) 
end 
addEventHandler ( "onPlayerJoin", getRootElement(), showcountry ) 
  
function playercash ( ) 
    local playerCash = getElementData ( source, "data.cash" ) 
    setElementData ( source, "Cash", playerCash ) 
end 
addEventHandler ( "onPlayerJoin", getRootElement(), playercash ) 
  
exports.scoreboard:addScoreboardColumn ( "Country" ) 
exports.scoreboard:addScoreboardColumn ( "Cash" ) 
      

Link to comment
exports.scoreboard:addScoreboardColumn("Country") 
exports.scoreboard:addScoreboardColumn("Cash") 
  
addEventHandler("onPlayerJoin", root, 
function() 
     setElementData(source, "Country", exports.admin:getPlayerCountry(source) or "N/A") 
end) 
  
addEventHandler("onPlayerSpawn", root, 
function() 
     setElementData(source, "Cash", getElementData(source, "data.cash") or 0) 
end) 

And Make Sure The Scoreboard is Running.

Edited by Guest
Link to comment
exports.scoreboard:addScoreboardColumn("Country") 
exports.scoreboard:addScoreboardColumn("Cash") 
  
function showCountry () 
     setElementData(source, "Country", exports.admin:getPlayerCountry(source)) 
 else 
     setElementData(source, "Country", "N/A") 
end 
end 
addEventHandler("onPlayerJoin", root, showCountry) 
  
function showMoney () 
     setElementData(source, "Cash", getElementData(source, "data.cash")) 
 else 
     setElementData(source, "Cash", "0") 
end 
end 
addEventHandler("onPlayerSpawn", root, showMoney) 

Untested, hope it works :D

Link to comment

Still doesn't work. Same error as on first message. Also i got error on way different script -

function fixVehicle ( theVehicle ) 
    playerAccount = getPlayerAccount ( source ) 
    playerCash = getAccountData ( playerAccount, "Cash" ) or "0" 
    playerAllowed = getElementData ( source, "data.repairBuyAllowed" ) or "true" 
    playerVehicle = getPedOccupiedVehicle ( player ) 
    if ( playerVehicle ~= nil ) then 
        if ( tonumber ( playerCash ) >= 1000 ) then 
            if ( playerAllowed ) = "true" then 
                fixVehicle ( playerVehicle ) 
                setElementData ( source, "data.repairBuyAllowed", "false" ) 
            else 
                outputChatBox ( "You may buy only one vehicle repair per map.", source, 255, 0, 0, true ) 
        else 
            outputChatBox ( "You need to have at least 1000$ to fix your vehicle", source, 255, 0, 0, true) 
    else 
        outputChatBox ( "You need to be in a vehicle to buy a repair", source, 255, 0, 0, true ) 
            end 
        end 
    end 
end 
addCommandHandler ( "buyrepair", fixVehicle ) 
addCommandHandler ( "br", fixVehicle ) 

Error on line 8 - 'then' expected near '='. Couldn't think out anything :S

Link to comment
  
    function fixVeh ( theVehicle ) 
        playerAccount = getPlayerAccount ( source ) 
        playerCash = getAccountData ( playerAccount, "Cash" ) or "0" 
        playerAllowed = getElementData ( source, "data.repairBuyAllowed" ) or "true" 
        playerVehicle = getPedOccupiedVehicle ( player ) 
        if ( playerVehicle ~= nil ) then 
            if ( tonumber ( playerCash ) >= 1000 ) then 
                if ( playerAllowed ) == "true" then 
                    fixVehicle ( playerVehicle ) 
                    setElementData ( source, "data.repairBuyAllowed", "false" ) 
                else 
                    outputChatBox ( "You may buy only one vehicle repair per map.", source, 255, 0, 0, true ) 
            else 
                outputChatBox ( "You need to have at least 1000$ to fix your vehicle", source, 255, 0, 0, true) 
        else 
            outputChatBox ( "You need to be in a vehicle to buy a repair", source, 255, 0, 0, true ) 
                end 
            end 
        end 
    end 
    addCommandHandler ( "buyrepair", fixVeh ) 
    addCommandHandler ( "br", fixVeh ) 
  

Link to comment
Guest Guest4401

I found 4 syntax errors and 6 MTA errors in the above code. If statements are not ended and player element is not the source when its attached to a command...

Try

function fixVeh ( player ) 
    playerAccount = getPlayerAccount ( player ) 
    playerCash = getAccountData ( playerAccount, "Cash" ) or 0 
    playerAllowed = getElementData ( player, "data.repairBuyAllowed" ) or "true" 
    playerVehicle = getPedOccupiedVehicle ( player ) 
    if ( playerVehicle ~= nil ) then 
        if ( tonumber ( playerCash ) >= 1000 ) then 
            if ( playerAllowed ) == "true" then 
                fixVehicle ( playerVehicle ) 
                setElementData ( player, "data.repairBuyAllowed", "false" ) 
            else 
                outputChatBox ( "You may buy only one vehicle repair per map.", player, 255, 0, 0, true ) 
            end 
        else 
            outputChatBox ( "You need to have at least 1000$ to fix your vehicle", player, 255, 0, 0, true) 
        end 
    else 
        outputChatBox ( "You need to be in a vehicle to buy a repair", player, 255, 0, 0, true ) 
    end 
end 
addCommandHandler ( "buyrepair", fixVeh ) 
addCommandHandler ( "br", fixVeh ) 

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