Bleidex Posted November 10, 2012 Posted November 10, 2012 It gives "failed to call 'scoreboard:addScoreboardColumn' [string: ?]". How it should be fixed? 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" )
TAPL Posted November 10, 2012 Posted November 10, 2012 (edited) 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 November 10, 2012 by Guest
Bleidex Posted November 10, 2012 Author Posted November 10, 2012 Doesn't work still - ')' expected in 6th line to clone '(' from 4th one. Can't find where's the error
Baseplate Posted November 10, 2012 Posted November 10, 2012 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
TAPL Posted November 10, 2012 Posted November 10, 2012 Doesn't work still - ')' expected in 6th line to clone '(' from 4th one. Can't find where's the error i forgot function() Copy the code again. @Samer, Your code won't work, because there no IF statement in your code.
Bleidex Posted November 10, 2012 Author Posted November 10, 2012 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
GTX Posted November 10, 2012 Posted November 10, 2012 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 )
Guest Guest4401 Posted November 10, 2012 Posted November 10, 2012 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 )
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now