Protagonist95 Posted December 10, 2016 Share Posted December 10, 2016 So heres a bit of code that i wrote: function onColEnter ( thePlayer ) local item = getElementsWithinColShape ( source, "object" ) if getElementsWithinColShape ( source, "player" ) then for index,key in ipairs(item) do outputChatBox ( tostring(getElementModel(key)) ) end setElementData(thePlayer,"inLoot",true) outputChatBox ( tostring(getElementData(thePlayer,"inLoot")) ) end end addEventHandler ("onColShapeHit", getRootElement(), onColEnter) The problem is that when I start resource it spamms through whole objects outputing results that must be only when i hit colshape. Picture Link to comment
Protagonist95 Posted December 10, 2016 Author Share Posted December 10, 2016 21 minutes ago, Protagonist95 said: So heres a bit of code that i wrote: function onColEnter ( thePlayer ) local item = getElementsWithinColShape ( source, "object" ) if getElementsWithinColShape ( source, "player" ) then for index,key in ipairs(item) do outputChatBox ( tostring(getElementModel(key)) ) end setElementData(thePlayer,"inLoot",true) outputChatBox ( tostring(getElementData(thePlayer,"inLoot")) ) end end addEventHandler ("onColShapeHit", getRootElement(), onColEnter) The problem is that when I start resource it spamms through whole objects outputing results that must be only when i hit colshape. Picture Ok,so what i didn't know that players are allways in world collision(lets call it that way),so i added ElementData to mine ones,works great now. Link to comment
Mr.Loki Posted December 10, 2016 Share Posted December 10, 2016 (edited) Quote This event is triggered when a physical element hits a colshape. You should check to see if "thePlayer" is actually a player by using getElementType Edited December 10, 2016 by loki2143 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