jeremaniak Posted April 25, 2012 Share Posted April 25, 2012 I am getting a bad argument at my code line 5 getVehicleName exports [ "scoreboard" ]:addScoreboardColumn ( "Vehicle:", 3 ) function playersVehicle ( ) for index, vehicle in ipairs ( getElementsByType "vehicle" ) do setElementData ( vehicle, "vehicle", getVehicleName ( player ) ) end end setTimer ( playersVehicle, 2500, 0 ) Link to comment
Axel Posted April 25, 2012 Share Posted April 25, 2012 Maybe this: exports [ "scoreboard" ]:addScoreboardColumn ( "Vehicle:", 3 ) setTimer ( function ( ) for index, vehicle in ipairs ( getElementsByType "vehicle" ) do setElementData ( vehicle, "vehicle", getVehicleName ( vehicle ) ) end end, 2500, 0 ) Link to comment
jeremaniak Posted April 25, 2012 Author Share Posted April 25, 2012 It doesn't work and no errors in debugscript 3 Link to comment
Booo Posted April 25, 2012 Share Posted April 25, 2012 (edited) I am getting a bad argument at my code line 5 getVehicleName exports [ "scoreboard" ]:addScoreboardColumn ( "Vehicle:", 3 ) function playersVehicle ( ) for index, vehicle in ipairs ( getElementsByType "vehicle" ) do setElementData ( vehicle, "vehicle", getVehicleName ( player ) ) end end setTimer ( playersVehicle, 2500, 0 ) addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() exports.scoreboard:addScoreboardColumn("Vehicle") setElementData ( source, "Vehicle", "on foot") end ) function playersVehicle ( ) 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, "Vehicle", tostring(carname) ) else setElementData ( v, "Vehicle", "on foot") end end end setTimer ( playersVehicle, 2500, 0 ) Edited April 25, 2012 by Guest Link to comment
jeremaniak Posted April 25, 2012 Author Share Posted April 25, 2012 I added it on server side but it still doesn't work with your code Link to comment
Axel Posted April 25, 2012 Share Posted April 25, 2012 Boo, that will only show Hunter (at least this does in my local..) Anyways i fixed it: addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() exports [ "scoreboard" ]:addScoreboardColumn ( "Vehicle:", 3 ) end ) 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, "Vehicle:", tostring(carname) ) -- The element data must be exactly the same as the scoreboard column else setElementData ( v, "Vehicle:", "On foot") end end end, 2500, 0 ) (tested) Link to comment
jeremaniak Posted April 25, 2012 Author Share Posted April 25, 2012 Still won't work WARNING: Loading script failed: scoreboardveh\server.lua:7: '(' expected near 'playersVehicle' Link to comment
jeremaniak Posted April 25, 2012 Author Share Posted April 25, 2012 TY, it's working.!! Link to comment
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