Jump to content

Collision of vehicle and object


Bishop_G

Recommended Posts

setTimer(function()
	local pVeh = getPedOccupiedVehicle(localPlayer) -- Get the players vehicle
		for i,v in pairs(getElementsByType("object")) do
		if (isElement(v)) and (getElementType(v)=="object") and  (getElementModel(v)==1226) then
		if(pVeh) then 
			setElementCollidableWith(pVeh,v, false) 
				setElementCollidableWith(v,pVeh, false) 
end
end
end
end,
500, 0)

 

Hello!
These simple codes only work on an object I put in the Map Editor.
But I want it to be valid for all street lamps on the San Andreas map.
I want to prevent the car from hitting the street lamps. Can you help a little?
Link to comment
local lamppostList = {
	[1126] = true --enter lamp post ids
}

setTimer(
	function()
	local pVeh = getPedOccupiedVehicle(localPlayer) -- Get the players vehicle
	for i,v in pairs(getElementsByType("object", root, true)) do
	   if (isElement(v)) and (getElementType(v) == "object") and (lamppostList[getElementModel(v)]) then
	      if(pVeh) then 
			setElementCollidableWith(pVeh,v, false) 
			setElementCollidableWith(v,pVeh, false) 
          end
       end
    end
end,
500, 0)

can you try this

  • Like 1
Link to comment
1 hour ago, Burak5312 said:
local lamppostList = {
	[1126] = true --enter lamp post ids
}

setTimer(
	function()
	local pVeh = getPedOccupiedVehicle(localPlayer) -- Get the players vehicle
	for i,v in pairs(getElementsByType("object", root, true)) do
	   if (isElement(v)) and (getElementType(v) == "object") and (lamppostList[getElementModel(v)]) then
	      if(pVeh) then 
			setElementCollidableWith(pVeh,v, false) 
			setElementCollidableWith(v,pVeh, false) 
          end
       end
    end
end,
500, 0)

can you try this

 

I tried KANKA but it didn't work. DiSaMe is right. These functions don't work on objects that are not set with the map editor.

1 hour ago, DiSaMe said:

The world objects aren't MTA elements so you don't have the same level of control over them that you have over objects that you add. What you can do is removing the original objects with removeWorldModel and adding your own identical ones.

 

I will do it thanks

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