Jump to content

Can't find the problem


Protagonist95

Recommended Posts

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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...