TrickyTommy Posted November 5, 2017 Share Posted November 5, 2017 (edited) Hi. I am making an interior system, alongside with a siren-system. I noticed, that whenever want to destroy (only just one siren), the other sirens, in other cars stop as well. The problem's description: I spawn 2 vehicles, and sound a siren in them, i sit into one of the 2 active sirening vehicles, and i stop the siren of the car i am sitting in, but the siren stops in the 2nd car too. And i want to make an interior system, already made it's tables, but after i get all the interior entrances from the database, with for k, v and i want to spawn a marker for each interior's entrance, but if i would do it like local interiorEntrance = createMarker (database results) and whenever i want to use it, it will not work correctly, because of the 30 interiors i made so far variable name is the same. This would be a solution, but it does not work."INT:"..interiorID.."" = createMarker (...) How should i fix it? Edited November 5, 2017 by TrickyTommy Link to comment
Moderators IIYAMA Posted November 5, 2017 Moderators Share Posted November 5, 2017 (edited) siren-system Not enough context to help you with this. For the interior. Use createElement and set it's children. local newElement = createElement("interiorEntrance", "interiorEntrance:" .. interiorID) for i=1, 30 do local marker = createMarker (...) setElementParent(marker, newElement) end destroyElement(newElement) -- will also destroy it's children. Syntax createElement: element createElement ( string elementType, [ string elementID = nil ] ) Edited November 5, 2017 by IIYAMA 1 Link to comment
idarrr Posted November 6, 2017 Share Posted November 6, 2017 Using table and set the key based on it's id. entrance = {} -- then add to table so you can get it later entrance[interiorID] = createMarker() -- simply get marker using theMarker = entrance[id] Link to comment
pa3ck Posted November 6, 2017 Share Posted November 6, 2017 If you're using the default MTA siren system, there are no siren objects that you need to reference in order to remove them from a vehicle. You just do: removeVehicleSirens(source) If you have your own objects that you attach, you can use the same concept idarrr suggested: local sirens = {} addCommandHandler("addsirens", function(p) local veh = getPedOccupiedVehicle(p) local obj1 = createObject(..) local obj2 = createObject(..) attachElements(obj1, veh) attachElements(obj2, veh) sirens[veh] = { obj1, obj2 } end) addCommandHandler("removesirens", function(p) local veh = getPedOccupiedVehicle(p) if sirens[veh] then for k, obj in ipairs(sirens[veh]) do destroyElement(obj) end sirens[veh] = null end end) 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