script_authors("AkeGGa")
script_name("[{0395fb}Shahta bot by AkeGGa{FFFFFF}]")
require('lib.moonloader')
require('lib.sampfuncs')
local ev = require('lib.samp.events')
local memory = require 'memory'
local state = false
local svobodnayaRuka = false
local player = {
x = 0.0,
y = 0.0,
z = 0.0
}
function sendMessage(msg)
sampAddChatMessage("[{0395fb}Shahta bot by AkeGGa{FFFFFF}]: "..msg, -1)
end
function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(100) end
writeMemory(7634870, 1, 1, 1)
writeMemory(7635034, 1, 1, 1)
memory.fill(7623723, 144, 8)
memory.fill(5499528, 144, 6)
sendMessage("Активация бота на шахту: {eee823}/shahta{FFFFFF}.")
sampRegisterChatCommand("shahta", function()
state = not state
sendMessage((state and 'Включен' or 'Выключен'))
if state then
lua_thread.create(function()
while state do wait(0)
player.x, player.y, player.z = getCharCoordinates(PLAYER_PED)
end
end)
end
end)
while true do wait (0)
if state then
svobodnayaRuka = false
runToPoint(-846.95587158203, 1213.2403564453)
runToPoint(-752.20776367188, 1217.6728515625)
svobodnayaRuka = true
wait(12000)
runToPoint(-846.95587158203, 1213.2403564453)
svobodnayaRuka = false
wait(1200)
runToPoint(-806.02770996094, 1213.0245361328)
runToPoint(-782.15106201172, 1204.8879394531)
runToPoint(-770.41479492188, 1192.7536621094)
svobodnayaRuka = true
wait(12000)
runToPoint(-782.15106201172, 1204.8879394531)
runToPoint(-806.02770996094, 1213.0245361328)
runToPoint(-846.95587158203, 1213.2403564453)
svobodnayaRuka = false
wait(1200)
end
end
end
function sendKey(code, scode, key)
local _, myId = sampGetPlayerIdByCharHandle(PLAYER_PED)
local data = allocateMemory(68)
sampStorePlayerOnfootData(myId, data)
setStructElement(data, code, scode, key, false)
sampSendOnfootData(data)
freeMemory(data)
end
function runToPoint(tox, toy)
if tox == nil or toy == nil or not state then return end
if perekus then return end
local angle = getHeadingFromVector2d(tox - player.x, toy - player.y)
local xAngle = -0.1
local isJump = false
setCameraPositionUnfixed(xAngle, math.rad(angle - 90))
local dist = getDistanceBetweenCoords2d(player.x, player.y, tox, toy)
while dist > 1.5 and state do wait(0)
dist = getDistanceBetweenCoords2d(player.x, player.y, tox, toy)
setGameKeyState(1, -255)
setGameKeyState(16, -255)
if not isCharInAir(PLAYER_PED) and not isJump and not svobodnayaRuka and dist > 15 then
setGameKeyState(14, 1)
isJump = true
lua_thread.create(function()
wait(700)
isJump = false
end)
end
angle = getHeadingFromVector2d(tox - player.x, toy - player.y)
setCameraPositionUnfixed(xAngle, math.rad(angle - 90))
end
end
function ev.onSendPlayerSync(data)
if bit.band(data.keysData, 0x28) == 0x28 and state then
data.keysData = bit.bxor(data.keysData, 0x20)
end
end
function onScriptTerminate(scr, onExitGame)
if scr == thisScript() then
if not onExitGame then
sendMessage("mq, crach script")
end
end
end