Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local stickyEnabled = false
- local me = getLocalPlayer()
- local testMode
- local oldMad=10010101099023980
- function findRotation(x1,y1,x2,y2)
- local t = -math.deg(math.atan2(x2-x1,y2-y1))
- if t < 0 then t = t + 360 end;
- return t;
- end
- function isNumberBetweenPoints(number, pointa, pointb)
- return (number>pointa) and (number<pointb)
- end
- function isVehicleOnSteepSurface(veh)
- local x,y,z = getElementPosition(veh)
- local steepSurface,_,_,_,_,normalx,normaly,normalz=processLineOfSight(x,y,z+1,z,y,z-10,true,false,false,true,false,false,false,false,veh) --i suppose u know what to put in the veh arugments? yes i do =D
- if steepSurface then
- steepSurface = getDistanceBetweenPoints2D(normalx,normaly,0,0)>normalz
- else
- steepSurface = true
- end
- return steepSurface
- end
- function onRender()
- local veh = getPedOccupiedVehicle(me)
- if not veh then
- removeEventHandler("onClientRender",root,onRender)
- stickyEnabled = false
- outputChatBox("[VEH] Sticky wheels turned to: "..tostring(stickyEnabled))
- return
- end
- local vehicleIsSurfaced, gX,gY,gZ = isSurfaced(veh)
- local steepSurface = isVehicleOnSteepSurface(veh)
- if testMode ~= vehicleIsSurfaced then
- testMode = vehicleIsSurfaced
- outputDebugString("Is vehicle on a surface? : "..tostring(testMode))
- end
- if oldMad ~= steepSurface then
- oldMad = steepSurface
- outputDebugString("If on surface, is it steep? : "..tostring(oldMad))
- end
- if vehicleIsSurfaced and steepSurface then
- setVehicleGravity(veh, gX,gY,gZ)
- else
- setVehicleGravity(veh,0,0,-1)
- end
- end
- function getPositionBelowElement(element)
- local matrix = getElementMatrix (element)
- local offX = 0 * matrix[1][1] + 0 * matrix[2][1] - 1 * matrix[3][1] + matrix[4][1]
- local offY = 0 * matrix[1][2] + 0 * matrix[2][2] - 1 * matrix[3][2] + matrix[4][2]
- local offZ = 0 * matrix[1][3] + 0 * matrix[2][3] - 1 * matrix[3][3] + matrix[4][3]
- return offX,offY,offZ
- end
- function isSurfaced(element)
- local x,y,z = getElementPosition(element)
- local bX,bY,bZ = getPositionBelowElement(element)
- local nX,nY,nZ = bX-x,bY-y,bZ-z
- local isSurface, sX, sY, sZ, surfaceObj = processLineOfSight(x, y, z, bX,bY,bZ, true, false, false, true, false)
- return isSurface, nX,nY,nZ
- end
- function stopSticky()
- if stickyEnabled then
- removeEventHandler("onClientRender",root,onRender)
- veh = getPedOccupiedVehicle(me)
- if veh then
- setVehicleGravity(veh,0,0,-1)
- end
- else
- addEventHandler("onClientRender",root,onRender)
- end
- stickyEnabled = not stickyEnabled
- outputChatBox("[VEH] Sticky wheels turned to: "..tostring(stickyEnabled))
- end
- addCommandHandler("sticky",stopSticky)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement