maffius97 Posted August 28, 2016 Share Posted August 28, 2016 I have spike stripe script below. All vehicles have sphere (vehCol) attached to vehicle. I want to break all tires in the vehicle when vehCol hit blow or blow2 or blow3 or blow4. How can I do it? addCommandHandler("sting", function(player) if (player) then local x,y,z = getElementPosition(player) local xr,yr,zr = getElementRotation(player) px, py, pz = getElementPosition(player) prot = getPedRotation(player) local offsetRot = math.rad(prot+90) local vx = px + 5 * math.cos(offsetRot) local vy = py + 5 * math.sin(offsetRot) local vx2 = px + 2 * math.cos(offsetRot) local vy2 = py + 2 * math.sin(offsetRot) local vx3 = px + 3 * math.cos(offsetRot) local vy3 = py + 3 * math.sin(offsetRot) local vx4 = px + 4 * math.cos(offsetRot) local vy4 = py + 4 * math.sin(offsetRot) local vz = pz + 2 local vrot = prot+180 spike = createObject(2892,vx,vy,z-0.95,0,0,vrot) setObjectScale(spike,0.7) local x2, y2, z2 = getElementPosition(spike) local blow = createColTube (x2, y2, z2-0.25, 0.75,1) local blow2 = createColTube (vx2, vy2, z2-0.25, 0.75,1) local blow3 = createColTube (vx3, vy3, z2-0.25, 0.75,1) local blow4 = createColTube (vx4, vy4, z2-0.25, 0.75,1) addEventHandler("onColShapeHit",blow, wylaczKola) addEventHandler("onColShapeHit",blow2,wylaczKola) addEventHandler("onColShapeHit",blow3,wylaczKola) addEventHandler("onColShapeHit",blow4,wylaczKola) end end) function wylaczKola (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 Link to comment
aka Blue Posted August 28, 2016 Share Posted August 28, 2016 ¿Why are you making two posts? Try this: local spike = { } local blows = { } addCommandHandler("sting", function(player) if (player) then local x,y,z = getElementPosition(player) local xr,yr,zr = getElementRotation(player) px, py, pz = getElementPosition(player) prot = getPedRotation(player) local offsetRot = math.rad(prot+90) local vx = px + 5 * math.cos(offsetRot) local vy = py + 5 * math.sin(offsetRot) local vx2 = px + 2 * math.cos(offsetRot) local vy2 = py + 2 * math.sin(offsetRot) local vx3 = px + 3 * math.cos(offsetRot) local vy3 = py + 3 * math.sin(offsetRot) local vx4 = px + 4 * math.cos(offsetRot) local vy4 = py + 4 * math.sin(offsetRot) local vz = pz + 2 local vrot = prot+180 spike[player] = createObject(2892,vx,vy,z-0.95,0,0,vrot) setObjectScale(spike,0.7) local x2, y2, z2 = getElementPosition(spike) local blows[player] = {createColTube (x2, y2, z2-0.25, 0.9,2), createColTube (vx2, vy2, z2-0.25, 0.9,2), createColTube (vx3, vy3, z2-0.25, 0.9,2), createColTube (vx4, vy4, z2-0.25, 0.9,2) } addEventHandler("onColShapeHit",blows[player], wylaczKola) end end) function wylaczKola (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 Link to comment
maffius97 Posted August 28, 2016 Author Share Posted August 28, 2016 Dude, its not what I asked. Btw it doesnt work Link to comment
idarrr Posted August 28, 2016 Share Posted August 28, 2016 Read onColShapeHit This event is triggered when a physical element hits a colshape.NOTE: The hit won't be detected if the element that entered the colshape is a colshape. Link to comment
aka Blue Posted August 29, 2016 Share Posted August 29, 2016 ¿Vehicle col? ¿What? You can check if the entered element is a player in vehicle and destroy his wheels... 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