123neri123 Posted August 18, 2016 Share Posted August 18, 2016 i making farm script, when i prees key its create plant object on my position and i need to get the combine and go on that when its ready , but i cant do that because onClientVehicleCollision dont recognizing plants , you have another solution for me? Link to comment
Wumbaloo Posted August 18, 2016 Share Posted August 18, 2016 make colshape on your plants? And then use onColShapeHit ? Link to comment
123neri123 Posted August 18, 2016 Author Share Posted August 18, 2016 function plant() if canPlant == true and plants > 0 then plants = plants - 1 local x, y, z = getElementPosition ( localPlayer ) local rx, ry, rz = getElementRotation ( localPlayer ) tempCol[1] = createColCuboid ( x, y, z - 5, 10.0, 10.0, 10.0 ) planetObject[1] = createObject ( 804 , x, y, z, rx, 0, 0 ) num = num + 1 else if canPlant == true then outputChatBox ("you dont have plants") else outputChatBox ("you dont have tractor") end end end function takeWeed(theElement) outputChatBox (getElementModel(theElement)) if ( theElement == tempCol[1] ) then outputChatBox ("work") end end addEventHandler("onClientColShapeHit",getRootElement(),takeWeed) still dont work , its recognize id 162 but i need that line "theElement == tempCol[1]" because i need to know who to remove (which object) Link to comment
Wumbaloo Posted August 19, 2016 Share Posted August 19, 2016 Like that ? I don't know if I understand you. local plants = {} function plant() if canPlant == true then local x, y, z = getElementPosition ( localPlayer ) local rx, ry, rz = getElementRotation ( localPlayer ) tempCol = createColCuboid ( x, y, z - 5, 10.0, 10.0, 10.0 ) planetObject = createObject ( 804 , x, y, z, rx, 0, 0 ) setElementData(planetObject, "colcuboid", tempCol, false) else if canPlant == true then outputChatBox ("you dont have plants") else outputChatBox ("you dont have tractor") end end end function takeWeed(theElement) for key, value in pairs(plants) do if value == theElement then outputChatBox ("work") -- if isElement(theElement) then -- destroyElement(theElement) -- end table.remove(plants, key, value) break end end end addEventHandler("onClientColShapeHit",getRootElement(),takeWeed) 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