Potato_Tomato420 Posted August 26, 2019 Share Posted August 26, 2019 I have created a vehicle spawn script but when 2 players walk into the marker the same time. It causes the vehicle's to spawn in each other en eventually explode. Is there some way i could prevent this situation from happening? Link to comment
DNL291 Posted August 26, 2019 Share Posted August 26, 2019 I suppose your code is server side, you have to store the vehicle in a table for each player. Showing your code would be better. Link to comment
Potato_Tomato420 Posted August 28, 2019 Author Share Posted August 28, 2019 Yes it is server side, I want to prevent a ambulance (416) to spawn inside the marker if a other player or vehicle is inside the marker. How could I prevent this? Spoiler medicVehicleSpanwer = createMarker (1179.71, -1338.31, 13.00, "cylinder", 2, 255, 255, 255, 120) local vehicleTable = {} function giveAmbulance(hitElement, matchingDimension) if (getElementType (hitElement) == "player" and getTeamName(getPlayerTeam(hitElement)) == "Paramedic") then local theVehicle = getPedOccupiedVehicle (hitElement) if not theVehicle then local jobVehicle = vehicleTable[hitElement] if jobVehicle then if isElement(jobVehicle) then destroyElement(jobVehicle) end vehicleTable[hitElement] = nil end jobVehicle = createVehicle (416, 1179.71, -1338.31, 14.00, 0, 0, 270) setElementData (jobVehicle, "fuel", 100) warpPedIntoVehicle (hitElement, jobVehicle) vehicleTable[hitElement] = jobVehicle end end end addEventHandler ("onMarkerHit", medicVehicleSpanwer, giveAmbulance) addEventHandler("onPlayerQuit", root, function () local jobVehicle = vehicleTable[source] if jobVehicle then if isElement(jobVehicle) then destroyElement(jobVehicle) end vehicleTable[source]= nil end end) Link to comment
Moderators IIYAMA Posted August 28, 2019 Moderators Share Posted August 28, 2019 (edited) 13 minutes ago, Potato_Tomato420 said: How could I prevent this? 1. You can get the colshape of a marker. https://wiki.multitheftauto.com/wiki/GetElementColShape 2. Get the elements of a specific type and check if there are none. https://wiki.multitheftauto.com/wiki/GetElementsWithinColShape local colshape = getElementColShape ( marker ) local players = getElementsWithinColShape ( colshape, "player" ) local vehicles = getElementsWithinColShape ( colshape, "vehicle" ) if #vehicles == 0 and #players == 0 then end Note: you might also need to check if the elements are not in the same dimension + interior, if you make use of those. Edited August 28, 2019 by IIYAMA 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