Bishop_G Posted August 31, 2023 Share Posted August 31, 2023 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
βurak Posted September 1, 2023 Share Posted September 1, 2023 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 1 Link to comment
DiSaMe Posted September 1, 2023 Share Posted September 1, 2023 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. 2 Link to comment
Bishop_G Posted September 1, 2023 Author Share Posted September 1, 2023 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
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