Jump to content

farmscript "onClientVehicleCollision" dont work on plants


123neri123

Recommended Posts

  
    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

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

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