SkatCh Posted June 25, 2014 Share Posted June 25, 2014 guys please i need some help here : example : jobsLocation = { {job = "Police Officer", x = 249.6259765625,y = 67.8125,z = 1002.9, r = 67, g = 156, b = 255, int = 6 , dim = 1 , team = "Police Force", skin = {280, 281, 282, 283, 284, 288}, jobEvent = "policeTaken", maxWL = 0, description =" bla bla bla bla bla"}, function ceateJobLocations() for index, val in pairs(jobsLocation) do marker = createMarker(val.x, val.y, val.z-0.5, "cylinder", 1.5, val.r, val.g, val.b, 255) name[marker] = val.job setElementDimension (marker , val.dim ) setElementInterior (marker , val.int) addEventHandler("onMarkerHit", marker, enteredMarker) end end addEventHandler("onResourceStart", resourceRoot, ceateJobLocations) warnings : "setElementinterior " [Excepted number at argument 2 , got nil ] and the same warnig with setElementDimension , so please how can i fix it . Link to comment
aintaro Posted June 25, 2014 Share Posted June 25, 2014 Try different name then int when declaring it in the array Link to comment
SkatCh Posted June 25, 2014 Author Share Posted June 25, 2014 i don't undrestand you can you post an example . Link to comment
Anubhav Posted June 25, 2014 Share Posted June 25, 2014 function ceateJobLocations() for index, val in pairs(jobsLocation) do marker = createMarker(val.x, val.y, val.z-0.5, "cylinder", 1.5, val.r, val.g, val.b, 255) name[marker] = val.job setElementDimension (marker , val.dimen ) setElementInterior (marker , val.inter) addEventHandler("onMarkerHit", marker, enteredMarker) end end addEventHandler("onResourceStart", resourceRoot, ceateJobLocations) jobsLocation = { {job = "Police Officer", x = 249.6259765625,y = 67.8125,z = 1002.9, r = 67, g = 156, b = 255, inter = 6 , dimen = 1 , team = "Police Force", skin = {280, 281, 282, 283, 284, 288}, jobEvent = "policeTaken", maxWL = 0, description =" bla bla bla bla bla"}, Link to comment
SkatCh Posted June 25, 2014 Author Share Posted June 25, 2014 lol :fp: , can any other one help me . Link to comment
Et-win Posted June 25, 2014 Share Posted June 25, 2014 function ceateJobLocations() for index, val in pairs(jobsLocation) do marker = createMarker(val.x, val.y, val.z-0.5, "cylinder", 1.5, val.r, val.g, val.b, 255) name[marker] = val.job setElementDimension (marker , val[1][8] ) setElementInterior (marker , val[1][9]) addEventHandler("onMarkerHit", marker, enteredMarker) end end addEventHandler("onResourceStart", resourceRoot, ceateJobLocations) Link to comment
Moderators IIYAMA Posted June 25, 2014 Moderators Share Posted June 25, 2014 There is only 1 way to find out. Which a scripter should first do, before posting his code here on the forum. ALSO KNOWN AS DEBUGGING jobsLocation = { {job = "Police Officer", x = 249.6259765625,y = 67.8125,z = 1002.9, r = 67, g = 156, b = 255, interior = 6 , dimension = 1 , team = "Police Force", skin = {280, 281, 282, 283, 284, 288}, jobEvent = "policeTaken", maxWL = 0, description =" bla bla bla bla bla"} } function ceateJobLocations() for index, val in pairs(jobsLocation) do local marker = createMarker(val.x, val.y, val.z-0.5, "cylinder", 1.5, val.r, val.g, val.b, 255) if marker then name[marker] = val.job local dimension = tonumber(val.dimension) if dimension then setElementDimension (marker, dimension ) else outputDebugString("Failed to set dimension, variable is nil/false. Table index: " .. index .. " .") end local interior = tonumber(val.interior) if interior then setElementInterior (marker, interior) else outputDebugString("Failed to set interior, variable is nil/false. Table index: " .. index .. " .") end addEventHandler("onMarkerHit", marker, enteredMarker) else outputDebugString("Failed to create marker. Table index: " .. index .. " .") end end end addEventHandler("onResourceStart", resourceRoot, ceateJobLocations) Link to comment
Et-win Posted June 25, 2014 Share Posted June 25, 2014 May I ask why 'tonumber' if the number is already given in the table? Link to comment
Moderators IIYAMA Posted June 25, 2014 Moderators Share Posted June 25, 2014 You never know, because I have the feeling he has more items inside his table then he is showing us at the moment. He may have defined one with a string or even a userdata. If you want to know what is going wrong, you have to keep open all options and possibility's. Link to comment
Et-win Posted June 25, 2014 Share Posted June 25, 2014 You never know, because I have the feeling he has more items inside his table then he is showing us at the moment.He may have defined one with a string or even a userdata. If you want to know what is going wrong, you have to keep open all options and possibility's. +1 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