57 lines
2.1 KiB
Lua
57 lines
2.1 KiB
Lua
----------------------------
|
|
--Anti magnet script exploit
|
|
--by Greenlander
|
|
----------------------------
|
|
local debug = true -- visualize the line of sight which detects objects in game
|
|
local blowTime = 5000 -- in milliseconds - Sets the time after which player vehicle gets blown if the timer is not reset within time
|
|
|
|
--Blow vehicle if no objects detected within "blowTime"
|
|
local blowTimer = setTimer(
|
|
function()
|
|
local vehicle = getPedOccupiedVehicle ( getLocalPlayer() )
|
|
|
|
if not vehicle then return end
|
|
|
|
if getElementData(getLocalPlayer(), 'state') == 'alive' then
|
|
blowVehicle( vehicle )
|
|
outputChatBox("[AMS]:#ff8000Get rekt filthy cheater", 255, 255, 255, true)
|
|
end
|
|
end,
|
|
blowTime, 0)
|
|
|
|
--Trigger reset of blowTimer if object under vehicle is detected
|
|
addEventHandler('onClientPreRender', root,
|
|
function()
|
|
local vehicle = getPedOccupiedVehicle ( getLocalPlayer() )
|
|
|
|
if not isTimer(blowTimer) then return end
|
|
if not vehicle then resetTimer(blowTimer) return end
|
|
if getElementModel( vehicle ) == 425 then resetTimer(blowTimer) return end
|
|
|
|
-- Check for normal gravity
|
|
if isNormalVehicleGravity(vehicle) then resetTimer(blowTimer) return end
|
|
|
|
local cx, cy, cz = getElementPosition( vehicle )
|
|
local matrix = getElementMatrix(vehicle)
|
|
local offX = 0 * matrix[1][1] + 0 * matrix[2][1] - 2 * matrix[3][1] + matrix[4][1]
|
|
local offY = 0 * matrix[1][2] + 0 * matrix[2][2] - 2 * matrix[3][2] + matrix[4][2]
|
|
local offZ = 0 * matrix[1][3] + 0 * matrix[2][3] - 2 * matrix[3][3] + matrix[4][3]
|
|
|
|
local hit = processLineOfSight(cx, cy, cz, offX, offY, offZ, true, false, false, true, true, true, false, true)
|
|
|
|
-- visualize processLineOfSight and print result
|
|
if debug then
|
|
dxDrawLine3D(cx, cy, cz, offX, offY, offZ, tocolor(255, 0, 0, 255), 3)
|
|
print(tostring(hit))
|
|
end
|
|
|
|
if hit then
|
|
resetTimer(blowTimer)
|
|
end
|
|
end
|
|
)
|
|
|
|
function isNormalVehicleGravity(vehicle)
|
|
local gx, gy, gz = getVehicleGravity(vehicle)
|
|
return gx == 0 and gy == 0 and gz == -1
|
|
end |