villr Posted September 20, 2012 Posted September 20, 2012 (edited) Hello, how can i define how many objects i get from this code? local objects = 0 addEvent( "seeIfThereisCrates", true ) addEventHandler( "seeIfThereisCrates", getLocalPlayer(), function (player) for i,elem in ipairs(getElementsByType("object")) do if getElementModel(elem) == 2912 then local objects = elem+1 outputChatBox("client:".. objects) Itested that and didnt work It always tell me 1. EDIT: And dont think i didnt use ends and things like that because its not in the code LOL. Edited September 20, 2012 by Guest
TAPL Posted September 20, 2012 Posted September 20, 2012 addEvent("seeIfThereisCrates", true) addEventHandler("seeIfThereisCrates", root, function (player) local objects = 0 for i,elem in ipairs(getElementsByType("object")) do if getElementModel(elem) == 2912 then local objects = objects + 1 end end outputChatBox("client: "..objects) end)
Guest Guest4401 Posted September 20, 2012 Posted September 20, 2012 addEvent("seeIfThereisCrates", true) addEventHandler("seeIfThereisCrates", root, function (player) local objects = 0 for i,elem in ipairs(getElementsByType("object")) do if getElementModel(elem) == 2912 then objects = objects + 1 end end outputChatBox("client: "..objects) end )
villr Posted September 20, 2012 Author Posted September 20, 2012 addEvent("seeIfThereisCrates", true) addEventHandler("seeIfThereisCrates", root, function (player) local objects = 0 for i,elem in ipairs(getElementsByType("object")) do if getElementModel(elem) == 2912 then objects = objects + 1 end end outputChatBox("client: "..objects) end ) Thanks!
Guest Guest4401 Posted September 20, 2012 Posted September 20, 2012 and my code not work? lol local o = 0 for i = 1,5 do o = o + 1 end print(o) --> 5 local o = 0 for i = 1,5 do local o = o + 1 end print(o) --> 0
TAPL Posted September 20, 2012 Posted September 20, 2012 and my code not work? lol local o = 0 for i = 1,5 do o = o + 1 end print(o) --> 5 local o = 0 for i = 1,5 do local o = o + 1 end print(o) --> 0 really? i have tested my code and it work, all you have did is making it global while this not needed since he will not use it outside the function.
Guest Guest4401 Posted September 20, 2012 Posted September 20, 2012 all you have did is making it global while this not needed It is needed.
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