63 lines
2.4 KiB
Lua
63 lines
2.4 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
|
|
local resetTime = 100 -- in milliseconds - Sets the time interval to check if gravity is altered and objects are below vehivle
|
|
|
|
--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
|
|
|
|
local v1 = Vector3(0,0,-1)
|
|
local gx, gy, gz = getVehicleGravity( vehicle )
|
|
local v2 = Vector3(gx, gy, gz)
|
|
|
|
if isVec3Equal(v1, v2) 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 isVec3Equal(v1,v2)
|
|
if (v1.x ~= v2.x) or (v1.y ~= v2.y) or (v1.z ~= v2.z) then
|
|
return false
|
|
end
|
|
return true
|
|
end |