Peti930 Posted March 26, 2018 Share Posted March 26, 2018 Helo! I have a script with i spawn spikes but i only can delete with restart the script! Anyone can make me a function with delete all of the spikes have spawned by anyone? with this command: delspikes addCommandHandler("rendorspike", function(player) if (player) then local x, y, z = getElementPosition(player) local spike = createObject(2892,x+2,y+2,z-0.6) local x2, y2, z2 = getElementPosition(spike) local blow = createColSphere(x2, y2, z2, 3) addEventHandler("onColShapeHit",blow,function (player) if player and getElementType(player) == "player" then if isPedInVehicle(player) then local pveh = getPedOccupiedVehicle(player) setVehicleWheelStates(pveh,1,1,1,1) end end end) end end) Link to comment
Dimos7 Posted March 26, 2018 Share Posted March 26, 2018 (edited) addCommandHandler("delpikes", function() for _, object in ipairs(getElementsByType("object") do if getElementModel(object) == 2892 then destroyElement(object) end end end, false, false) try this Edited March 26, 2018 by Dimos7 Link to comment
Peti930 Posted March 26, 2018 Author Share Posted March 26, 2018 (edited) Seeing in debugscript 3: ERROR: Loading script failed: spikedel/server.lua:2:')' expected near 'do" Im passed it, only you forgot an ")", thanks! Uhm i have a problem, if i use /delspikes its deleting the object but if you go to this area where your car rubber was off its get off again Can you make a scrpit with i use command /delspikes and its restarts the "spike" resource? Because this is a small script and cant be "NETWROK TROUBLE" Edited March 26, 2018 by Peti930 Link to comment
Dimos7 Posted March 26, 2018 Share Posted March 26, 2018 why restart it addCommandHandler("delpikes", function() for _, object in ipairs(getElementsByType("object")) do if getElementModel(object) == 2892 then destroyElement(object) end end end, false, false) Link to comment
MIKI785 Posted March 27, 2018 Share Posted March 27, 2018 Deleting the object won't do it as there is a colshape that does the actual work. I would do something like this: addCommandHandler("rendorspike", function(player) if (player) then local x, y, z = getElementPosition(player) local spike = createObject(2892,x+2,y+2,z-0.6) local x2, y2, z2 = getElementPosition(spike) local blow = createColSphere(x2, y2, z2, 3) setElementData(blow, "blowObject", spike, false) end end) addEventHandler("onColShapeHit", root, function (player) --Do it for all colshapes if not getElementData(source, "blowObject") then return end --Not a 'blow' colshape; don't care.. if player and getElementType(player) == "player" then if isPedInVehicle(player) then local pveh = getPedOccupiedVehicle(player) setVehicleWheelStates(pveh,1,1,1,1) end end end) addCommandHandler("delspikes", function (player) for i, element in pairs(getElementsByType("colshape")) do if getElementData(element, "blowObject") then --is a 'blow' colshape destroyElement(getElementData(element, "blowObject")) --Object has to be destroyed first destroyElement(element) --Destroy the colshape itself end end end) Didn't try it but you should get the idea. 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