settings = {['ug'] = -20, ['step'] = 10, ['speed'] = 100}
settingscar = {['ug'] = -20, ['step'] = 40, ['speed'] = 20}
local events = require 'samp.events'
local vector = require 'vector3d'
local state = false
function main()
while not isSampAvailable() do wait(0) end wait(1)
while true do wait(0)
if testCheat('rk') then
if not state then
state = true
lua_thread.create(function()
while not getTargetBlipCoordinates() do wait(100)
printString('Set a blip',1000)
end
return CoordMaster()
end)
else
sampAddChatMessage('Coordmaster is now running!', -1)
end
end
end
end
function CoordMaster()
local x, y, z = getTargetBlipCoordinatesFixed()
local myX, myY, myZ = getCharCoordinates(PLAYER_PED)
if isCharInAnyCar(1) and getDriverOfCar(getCarCharIsUsing(1)) == 1 then
local FIRST_DIST = getDistanceBetweenCoords2d(x,y,myX,myY)
lua_thread.create(function()
freezeCharPosition(PLAYER_PED,true)
local myX, myY, myZ = getCharCoordinates(PLAYER_PED)
local angle = getHeadingFromVector2d(x - myX,y - myY)
while math.abs(myZ - settingscar.ug) > settingscar.step do
if settingscar.ug > myZ then
setCharCoordinates(PLAYER_PED,myX,myY,myZ - 1 + settingscar.step)
else
setCharCoordinates(PLAYER_PED,myX,myY,myZ - 1 - settingscar.step)
end
myX, myY, myZ = getCharCoordinates(PLAYER_PED)
wait(settingscar.speed)
end
setCharCoordinates(PLAYER_PED, myX, myY, settingscar.ug)
while getDistanceBetweenCoords2d(x,y,myX,myY) > settingscar.step do
setCharCoordinates(PLAYER_PED, myX - settingscar.step * math.sin(math.rad(angle)), myY + settingscar.step * math.cos(math.rad(angle)), myZ - 1)
myX, myY, myZ = getCharCoordinates(PLAYER_PED)
angle = getHeadingFromVector2d(x - myX, y - myY)
local DISTANCE = getDistanceBetweenCoords2d(x,y,myX,myY)
DIST_MATH = DISTANCE / FIRST_DIST
DIST_TWO = DIST_MATH * 100
DIST_PROC = 100 - DIST_TWO
TIMES = DISTANCE / settingscar.step
TIMESS = (math.ceil(TIMES) - 1) * settingscar.speed
TIME = TIMESS / 1000
if TIME > 0 then
printStringNow('~b~~h~TELEPORT: ~w~~h~'..math.floor(DIST_PROC)..'% ~r~~h~TIME: '..TIME..' SEC',1000)
else
printStringNow('~b~~h~TELEPORT: ~w~~h~'..math.floor(DIST_PROC)..'% ~r~~h~TIME: 0 SEC',1000)
end
wait(settingscar.speed)
end
while math.abs(myZ - z) > settingscar.step do
if z > myZ then
setCharCoordinates(PLAYER_PED, myX, myY, myZ - 1 - settingscar.step)
end
myX, myY, myZ = getCharCoordinates(PLAYER_PED)
wait(settingscar.speed)
end
state = false
setCharCoordinates(PLAYER_PED, x, y, z)
printStringNow('~b~~h~TELEPORT: ~w~~h~DONE', 1000)
wait(1000)
freezeCharPosition(PLAYER_PED,false)
end)
else
local FIRST_DIST = getDistanceBetweenCoords2d(x,y,myX,myY)
lua_thread.create(function()
freezeCharPosition(PLAYER_PED,true)
local myX, myY, myZ = getCharCoordinates(PLAYER_PED)
local angle = getHeadingFromVector2d(x - myX,y - myY)
while math.abs(myZ - settings.ug) > settings.step do
if settings.ug > myZ then
setCharCoordinates(PLAYER_PED,myX,myY,myZ - 1 + settings.step)
else
setCharCoordinates(PLAYER_PED,myX,myY,myZ - 1 - settings.step)
end
myX, myY, myZ = getCharCoordinates(PLAYER_PED)
wait(settings.speed)
end
setCharCoordinates(PLAYER_PED, myX, myY, settings.ug)
while getDistanceBetweenCoords2d(x,y,myX,myY) > settings.step do
setCharCoordinates(PLAYER_PED, myX - settings.step * math.sin(math.rad(angle)), myY + settings.step * math.cos(math.rad(angle)), myZ - 1)
myX, myY, myZ = getCharCoordinates(PLAYER_PED)
angle = getHeadingFromVector2d(x - myX, y - myY)
local DISTANCE = getDistanceBetweenCoords2d(x,y,myX,myY)
DIST_MATH = DISTANCE / FIRST_DIST
DIST_TWO = DIST_MATH * 100
DIST_PROC = 100 - DIST_TWO
TIMES = DISTANCE / settings.step
TIMESS = (math.ceil(TIMES) - 0.5) * settings.speed
TIME = TIMESS / 1000
if TIME > 0 then
printStringNow('~b~~h~TELEPORT: ~w~~h~'..math.floor(DIST_PROC)..'% ~r~~h~TIME: '..TIME..' SEC',1000)
else
printStringNow('~b~~h~TELEPORT: ~w~~h~'..math.floor(DIST_PROC)..'% ~r~~h~TIME: 0 SEC',1000)
end
wait(settings.speed)
end
while math.abs(myZ - z) > settings.step do
if z > myZ then
setCharCoordinates(PLAYER_PED, myX, myY, myZ - 1 - settings.step)
end
myX, myY, myZ = getCharCoordinates(PLAYER_PED)
wait(settings.speed)
end
state = false
setCharCoordinates(PLAYER_PED, x, y, z)
printStringNow('~b~~h~TELEPORT: ~w~~h~DONE', 1000)
wait(1000)
freezeCharPosition(PLAYER_PED,false)
end)
end
end
function getTargetBlipCoordinatesFixed()
local bool, x, y, z = getTargetBlipCoordinates(); if not bool then return false end
requestCollision(x,y); loadScene(x,y,z)
local bool, x, y, z = getTargetBlipCoordinates()
return bool and x, y, z or nil
end