local vector3D = require 'vector3d'
local samp = require 'lib.samp.events'
local returnAgain = false
local xyz = { public = { x = 0, y = 0, z = 0 }, private = { x = 0, y = 0, z = 0 }, static = { x = 0, y = 0, z = 0 } }
local millisecond;
local active = false
function main()
repeat wait(0) until isSampAvailable()
sampAddChatMessage('{696969}[Optimal-{00FFFF}tp]{FFFFFF}супер пупер пиздатый код загружен', -1)
sampAddChatMessage('{696969}[Optimal-{00FFFF}tp]{FFFFFF}: /tp_bot', -1)
sampAddChatMessage('{696969}[Optimal-{00FFFF}tp]{FFFFFF}ЫЫЫ ', -1)
sampAddChatMessage('{696969}[Optimal-{00FFFF}Stp]{FFFFFF}', -1)
sampRegisterChatCommand('tp_bot', function()
active = not active
local myX, myY, myZ = getCharCoordinates(PLAYER_PED)
local res, x, y, z = SearchMarker(myX, myY, myZ, 9999, false)
if res then
local distance = getDistanceBetween3d(myX, myY, myZ, x, y, z)
xyz.private.x, xyz.private.y, xyz.private.z = x, y, z;
xyz.public.x, xyz.public.y, xyz.public.z = x, y, z;
teleport = not teleport
else
sampAddChatMessage('{696969}[Optimal-{00FFFF}tp]{FFFFFF}>!)-.', -1)
end
if not teleport then
freezeCharPosition(playerPed, false)
end
end)
while true do wait(0)
if teleport and isCharOnFoot(playerPed) then
freezeCharPosition(playerPed, true)
local myPosition = {getOffsetFromCharInWorldCoords(playerPed, 0.0, 0.0, -1.5)}
xyz.static.x, xyz.static.y, xyz.static.z = xyz.private.x - myPosition[1], xyz.private.y - myPosition[2], xyz.private.z - myPosition[3];
xyz.public.x, xyz.public.y, xyz.public.z = xyz.public.x - myPosition[1], xyz.public.y - myPosition[2], xyz.public.z - myPosition[3];
local vectorPlayer = vector3D(xyz.static.x, xyz.static.y, xyz.static.z)
vectorPlayer:normalize()
local data = allocateMemory(68)
sampStorePlayerOnfootData(returnid(), data)
setStructFloatElement(data, 38, 0.0, true)
setStructFloatElement(data, 42, 0.0, true)
setStructFloatElement(data, 38, 0.02, true)
setStructFloatElement(data, 42, 0.02, true)
sampSendOnfootData(data)
freeMemory(data)
setCharCoordinates(playerPed, myPosition[1] + vectorPlayer.x * 1.3, myPosition[2] + vectorPlayer.y * 1.3, myPosition[3] + vectorPlayer.z * 1.3)
wait(20)
if getDistanceBetweenCoords3d(xyz.private.x, xyz.private.y, xyz.private.z, myPosition[1], myPosition[2], myPosition[3]) < 1 then
local lastPosition = {getCharCoordinates(playerPed)}
setCharCoordinates(playerPed, lastPosition[1], lastPosition[2], lastPosition[3] + 0.01)
freezeCharPosition(playerPed, false)
sampAddChatMessage('<<<Process...', -1)
end
end
end
end
function returnid()
local result, id = sampGetPlayerIdByCharHandle(playerPed)
if result then return id else error(">>>") end
end
function SearchMarker(posX, posY, posZ, radius, isRace)
local ret_posX = 0.0
local ret_posY = 0.0
local ret_posZ = 0.0
local isFind = false
for id = 0, 31 do
local MarkerStruct = 0
if isRace then MarkerStruct = 0xC7F168 + id * 56
else MarkerStruct = 0xC7DD88 + id * 160 end
local MarkerPosX = representIntAsFloat(readMemory(MarkerStruct + 0, 4, false))
local MarkerPosY = representIntAsFloat(readMemory(MarkerStruct + 4, 4, false))
local MarkerPosZ = representIntAsFloat(readMemory(MarkerStruct + 8, 4, false))
if MarkerPosX ~= 0.0 or MarkerPosY ~= 0.0 or MarkerPosZ ~= 0.0 then
if getDistanceBetweenCoords3d(MarkerPosX, MarkerPosY, MarkerPosZ, posX, posY, posZ) < radius then
ret_posX = MarkerPosX
ret_posY = MarkerPosY
ret_posZ = MarkerPosZ
isFind = true
radius = getDistanceBetweenCoords3d(MarkerPosX, MarkerPosY, MarkerPosZ, posX, posY, posZ)
end
end
end
return isFind, ret_posX, ret_posY, ret_posZ
end