script_name("stageRPzavod")
script_authors("Enotawer")
script_description("kek lol bot_maker")
script_version("0.1")
script_dependencies("CLEO")
---------------------------------------------------------------------------
require "lib.moonloader"
local ffi = require "ffi"
ffi.cdef[[
void keybd_event(int keycode, int scancode, int flags, int extra);
]]
---------------------------------------------------------------------------
function main()
if not isSampfuncsLoaded() or not isSampLoaded() then return end
sampRegisterChatCommand("srpbot", cmd_bot)
local saveX = {}
local saveY = {}
local saveZ = {}
while true do
wait(0)
if isPlayerPlaying(playerHandle) and enabled then
---------------------------------------------------------------------------
BeginToPoint(2559.310059, -1287.229980, 1044.150024, 1.000000, -255, false)
wait(1000)
BeginToPoint(2556.000000, -1290.989990, 1044.150024, 1.000000, -255, false)
wait(1000)
EmulateKey(VK_Y, true)
wait(20)
EmulateKey(VK_Y, false)
EmulateKey(VK_N, true)
wait(20)
EmulateKey(VK_N, false)
wait(10000)
BeginToPoint(2559.739990, -1289.069946, 1044.150024, 1.000000, -255, false)
BeginToPoint(2564.770020, -1293.079956, 1044.150024, 1.000000, -255, false)
---------------------------------------------------------------------------
end
end
end
--------------------------- STANDART FUNCTIONS ---------------------------
function BeginToPoint(x, y, z, radius, move_code, isSprint)
repeat
local posX, posY, posZ = GetCoordinates()
SetAngle(x, y, z)
MovePlayer(move_code, isSprint)
local dist = getDistanceBetweenCoords3d(x, y, z, posX, posY, z)
wait(0)
until not enabled or dist < radius
end
function MovePlayer(move_code, isSprint)
setGameKeyState(1, move_code)
--[[255 - обычный бег назад
-255 - обычный бег вперед
65535 - идти шагом вперед
-65535 - идти шагом назад]]
if isSprint then setGameKeyState(16, 255) end
end
function SetAngle(x, y, z)
local posX, posY, posZ = GetCoordinates()
local pX = x - posX
local pY = y - posY
local zAngle = getHeadingFromVector2d(pX, pY)
if isCharInAnyCar(playerPed) then
local car = storeCarCharIsInNoSave(playerPed)
setCarHeading(car, zAngle)
else
setCharHeading(playerPed, zAngle)
end
restoreCameraJumpcut()
end
function GetCoordinates()
if isCharInAnyCar(playerPed) then
local car = storeCarCharIsInNoSave(playerPed)
return getCarCoordinates(car)
else
return getCharCoordinates(playerPed)
end
end
function cmd_bot(param)
enabled = not enabled
if enabled then
sampAddChatMessage(string.format("[%s]: јктивирован", thisScript().name), 0x40FF40)
else
sampAddChatMessage(string.format("[%s]: ƒеактивирован", thisScript().name), 0xFF4040)
end
end
-- Teleport from ClickWarp (by FYP)
function teleportPlayer(x, y, z)
if isCharInAnyCar(playerPed) then
setCharCoordinates(playerPed, x, y, z)
end
setCharCoordinatesDontResetAnim(playerPed, x, y, z)
end
function setCharCoordinatesDontResetAnim(char, x, y, z)
if doesCharExist(char) then
local ptr = getCharPointer(char)
setEntityCoordinates(ptr, x, y, z)
end
end
function setEntityCoordinates(entityPtr, x, y, z)
if entityPtr ~= 0 then
local matrixPtr = readMemory(entityPtr + 0x14, 4, false)
if matrixPtr ~= 0 then
local posPtr = matrixPtr + 0x30
writeMemory(posPtr + 0, 4, representFloatAsInt(x), false) --X
writeMemory(posPtr + 4, 4, representFloatAsInt(y), false) --Y
writeMemory(posPtr + 8, 4, representFloatAsInt(z), false) --Z
end
end
end
-- End Teleport code
--------------------------- ADDITIONAL FUNCTIONS ---------------------------
function EmulateKey(key, isDown)
if not isDown then
ffi.C.keybd_event(key, 0, 2, 0)
else
ffi.C.keybd_event(key, 0, 0, 0)
end
end