script_name("PizzaBot")
script_authors("by_k0lenval")
script_version("0.2b")
script_dependencies()
local var_0_0 = require("vkeys")
local var_0_1 = require("memory")
local var_0_2 = require("lib.samp.events")
local var_0_3
local var_0_4
local var_0_5
local var_0_6
local var_0_7
function main()
if not isSampfuncsLoaded() or not isSampLoaded() then
return
end
while not isSampAvailable() do
wait(0)
end
sampAddChatMessage(string.format("{00AAFF}%s {FFFF00}\xF3\xF1\xEF\xE5\xF8\xED\xEE \xE7\xE0\xE3\xF0\xF3\xE6\xE5\xED. \xCA\xEE\xEC\xE0\xED\xE4\xE0 \xE0\xEA\xF2\xE8\xE2\xE0\xF6\xE8\xE8 - {FF4400}/pizb", thisScript().name), 16776960)
sampRegisterChatCommand("pizb", cmd_bot)
while true do
wait(0)
if var_0_3 and isPlayerPlaying(playerHandle) and sampGetPlayerIdByCharHandle(PLAYER_PED) then
if var_0_4 == -1 then
if isCharInAnyCar(PLAYER_PED) == false then
BeginToPoint(1751, 2216, 10.84, 0.6, true, false, true, false)
var_0_6 = 0
else
setGameKeyState(15, 255)
wait(200)
end
end
if var_0_4 == 0 and var_0_6 ~= 0 and isCharInAnyCar(PLAYER_PED) then
var_0_4 = InCarGo(var_0_6, var_0_4)
end
if var_0_4 == 1 and isCharInAnyCar(PLAYER_PED) == false then
local var_1_0 = 0
local var_1_1 = 0
local var_1_2 = 0
if var_0_6 == 2030 then
var_1_0, var_1_1, var_1_2 = 2031.56, 987.18, 10.35
end
if var_0_6 == 2600 then
var_1_0, var_1_1, var_1_2 = 2599.83, 1058.92, 10.35
end
if var_0_6 == 2320 then
var_1_0, var_1_1, var_1_2 = 2326.42, 2420.32, 10.35
end
if var_0_6 == 2345 then
var_1_0, var_1_1, var_1_2 = 2350.04, 2406.56, 10.35
end
if var_0_6 == 2534 then
var_1_0, var_1_1, var_1_2 = 2536.94, 2135.69, 10.82
end
if var_0_6 == -53 then
var_1_0, var_1_1, var_1_2 = -61.68, 1207.61, 18.9
end
if var_0_6 == -85 then
var_1_0, var_1_1, var_1_2 = -86.58, 102.05, 3.12
end
if var_0_6 == -86 then
var_1_0, var_1_1, var_1_2 = -103.62, -311.71, 1.43
end
if var_1_0 ~= 0 then
BeginToPoint(var_1_0, var_1_1, var_1_2, 0.8, true, false, false, true)
end
end
if var_0_4 == 2 and isCharInAnyCar(PLAYER_PED) then
var_0_4 = InCarGo(var_0_6, var_0_4)
end
end
end
end
function InCarGo(arg_2_0, arg_2_1)
local var_2_0 = io.open("moonloader\\PathPizBot\\" .. arg_2_0 .. ".txt", "r+")
local var_2_1 = {}
if var_2_0 == nil then
return arg_2_1
end
if var_2_0 then
for iter_2_0 in var_2_0:lines() do
table.insert(var_2_1, iter_2_0)
end
end
if arg_2_1 == 2 then
var_2_1 = ReverseTable(var_2_1)
end
if var_2_1 then
for iter_2_1, iter_2_2 in pairs(var_2_1) do
local var_2_2 = storeCarCharIsInNoSave(PLAYER_PED)
var_0_7 = var_2_2
local var_2_3 = os.time()
if var_0_3 == false then
break
end
local var_2_4, var_2_5, var_2_6, var_2_7 = iter_2_2:match("{(.*)}:{(.*)}:{(.*)}:{(.*)}")
if var_2_4 and var_2_5 and var_2_6 and var_2_7 then
repeat
wait(0)
if isCharInAnyCar(PLAYER_PED) then
if tonumber(var_2_7) == 1 and getCarSpeed(var_2_2) < 32.4 then
setGameKeyState(14, -128)
setGameKeyState(1, -128)
end
setCarEngineOn(var_2_2, true)
if iter_2_1 % 2 > 0 then
if getCarSpeed(var_2_2) <= 1 and os.time() - var_2_3 > 3 then
for iter_2_3 = 0, 170 do
wait(0)
setGameKeyState(14, 128)
end
var_2_3 = os.time()
end
local var_2_8, var_2_9, var_2_10 = getCarCoordinates(var_2_2)
local var_2_11 = getDistanceBetweenCoords3d(var_2_4, var_2_5, var_2_10, var_2_8, var_2_9, var_2_10)
if var_2_11 > 3 and var_2_11 < 8 and os.time() - var_2_3 > 3 then
setCharCoordinates(PLAYER_PED, var_2_4, var_2_5, getGroundZFor3dCoord(var_2_4, var_2_5, var_2_10))
end
turning_mechanism(tonumber(var_2_4), tonumber(var_2_5), var_2_8, var_2_9, var_2_2)
if getCarSpeed(var_2_2) < var_2_6 + 2 then
press_gas()
else
press_brake()
end
else
break
end
end
until locateCharInCar2d(PLAYER_PED, tonumber(var_2_4), tonumber(var_2_5), 5, 5, false) or var_0_3 == false
end
end
if arg_2_1 == 2 then
arg_2_1 = -1
elseif arg_2_1 == 0 then
arg_2_1 = 1
end
end
return arg_2_1
end
function EnterCarExist()
while true do
wait(0)
if var_0_3 and isCharInAnyCar(PLAYER_PED) == false and (var_0_4 == 0 or var_0_4 == 2) then
repeat
wait(100)
BoolFind, Car, Lock = FuncFindCar(var_0_7)
if BoolFind then
local var_3_0, var_3_1, var_3_2 = getCarCoordinates(Car)
BeginToPoint(var_3_0, var_3_1, var_3_2, 2, true, true, false, false, Lock)
else
print("\xCD\xE5 \xED\xE0\xE9\xE4\xE5\xED \xE1\xE0\xE9\xEA")
end
until isCharInAnyCar(PLAYER_PED) or var_0_3 == false
if isCharInAnyCar(PLAYER_PED) and doesVehicleExist(Car) and getCarDoorLockStatus(Car) == 0 then
wait(1000)
sampSendChat("/jlock")
setCharCanBeKnockedOffBike(PLAYER_PED, true)
end
end
end
end
function ReverseTable(arg_4_0)
local var_4_0 = {}
local var_4_1 = #arg_4_0
for iter_4_0, iter_4_1 in ipairs(arg_4_0) do
var_4_0[var_4_1 + 1 - iter_4_0] = iter_4_1
end
return var_4_0
end
function turning_mechanism(arg_5_0, arg_5_1, arg_5_2, arg_5_3, arg_5_4)
local var_5_0 = math.rad(getHeadingFromVector2d(arg_5_0 - arg_5_2, arg_5_1 - arg_5_3) + math.abs(getCarHeading(arg_5_4) - 360))
local var_5_1 = getHeadingFromVector2d(math.deg(math.sin(var_5_0)), math.deg(math.cos(var_5_0)))
if var_5_1 > 180 and var_5_1 < 355 then
setGameKeyState(0, -128)
elseif var_5_1 > 5 and var_5_1 <= 180 then
setGameKeyState(0, 128)
else
setGameKeyState(0, 0)
end
end
function press_gas()
writeMemory(12006520, 1, 255, false)
end
function press_brake()
writeMemory(12006500, 1, 255, false)
end
function FuncFindCar(arg_8_0)
local var_8_0 = getAllVehicles()
local var_8_1 = {}
local var_8_2 = false
local var_8_3 = 0
local var_8_4 = false
for iter_8_0, iter_8_1 in pairs(var_8_0) do
if doesVehicleExist(iter_8_1) and getNameOfVehicleModel(getCarModel(iter_8_1)) == "PIZZABO" and getDriverOfCar(iter_8_1) == -1 and getCarDoorLockStatus(iter_8_1) == 0 or doesVehicleExist(iter_8_1) and getNameOfVehicleModel(getCarModel(iter_8_1)) == "PIZZABO" and getDriverOfCar(iter_8_1) == -1 and arg_8_0 == iter_8_1 then
local var_8_5, var_8_6, var_8_7 = getCharCoordinates(PLAYER_PED)
local var_8_8, var_8_9, var_8_10 = getCarCoordinates(iter_8_1)
local var_8_11 = getDistanceBetweenCoords3d(var_8_5, var_8_6, var_8_7, var_8_8, var_8_9, var_8_10)
if var_8_1[1] == nil then
var_8_1 = {
iter_8_1,
var_8_11
}
elseif var_8_11 < var_8_1[2] then
var_8_1 = {
iter_8_1,
var_8_11
}
end
end
end
if var_8_1[1] ~= nil and var_8_1[2] < 80 then
if arg_8_0 == var_8_1[1] then
var_8_4 = true
end
var_8_2 = true
end
return var_8_2, var_8_1[1], var_8_4
end
function BeginToPoint(arg_9_0, arg_9_1, arg_9_2, arg_9_3, arg_9_4, arg_9_5, arg_9_6, arg_9_7, arg_9_8)
local var_9_0 = os.time()
local var_9_1, var_9_2, var_9_3 = getCharCoordinates(PLAYER_PED)
local var_9_4 = getDistanceBetweenCoords3d(arg_9_0, arg_9_1, arg_9_2, var_9_1, var_9_2, var_9_3)
local var_9_5 = math.ceil(getCharHeading(PLAYER_PED))
local var_9_6 = math.ceil(getHeadingFromVector2d(arg_9_0 - var_9_1, arg_9_1 - var_9_2))
local var_9_7 = var_9_5
local var_9_8 = var_9_5
local var_9_9 = 0
for iter_9_0 = 0, 180 do
var_9_9 = var_9_9 + 1
var_9_7 = var_9_7 + 1
var_9_8 = var_9_8 - 1
if var_9_7 > 360 then
var_9_7 = 0
end
if var_9_8 < 0 then
var_9_8 = 360
end
if var_9_7 == var_9_6 or var_9_8 == var_9_6 then
break
end
end
if var_9_7 == var_9_6 then
for iter_9_1 = 0, var_9_9, math.random(3, 5) do
if arg_9_7 and arg_9_3 < var_9_4 then
setGameKeyState(1, -255)
elseif arg_9_7 == false then
setGameKeyState(1, -255)
end
wait(0)
if var_0_3 then
setCameraPositionUnfixed(-0.3, math.rad(var_9_5 + iter_9_1 + 270))
end
end
else
for iter_9_2 = 0, var_9_9, math.random(3, 5) do
if arg_9_7 and arg_9_3 < var_9_4 then
setGameKeyState(1, -255)
elseif arg_9_7 == false then
setGameKeyState(1, -255)
end
wait(0)
if var_0_3 then
setCameraPositionUnfixed(-0.3, math.rad(var_9_5 - iter_9_2 + 270))
end
end
end
repeat
wait(0)
local var_9_10 = true
local var_9_11 = true
local var_9_12 = true
local var_9_13 = true
local var_9_14, var_9_15, var_9_16 = getCharCoordinates(PLAYER_PED)
local var_9_17 = math.rad(getHeadingFromVector2d(arg_9_0 - var_9_14, arg_9_1 - var_9_15))
local var_9_18 = getDistanceBetweenCoords3d(arg_9_0, arg_9_1, arg_9_2, var_9_14, var_9_15, arg_9_2)
if arg_9_6 and var_0_4 == 0 then
break
end
if arg_9_5 and arg_9_8 and var_9_18 < 2 and doesVehicleExist(var_0_7) and getCarDoorLockStatus(var_0_7) == 2 then
sampSendChat("/jlock")
arg_9_8 = false
end
if arg_9_5 and var_9_18 < arg_9_3 then
repeat
setGameKeyState(15, 255)
wait(800)
until isCharInAnyCar(PLAYER_PED) or os.time() - var_9_0 > 8 or var_0_3 == false
break
end
if arg_9_7 and var_0_4 == 2 then
break
end
if var_9_18 > 1.5 then
for iter_9_3 = -0.5, 0.7, 0.2 do
local var_9_19 = var_9_14 + 0.4 * math.cos(var_9_17 + 0.2 + 0)
local var_9_20 = var_9_15 + 0.4 * math.sin(var_9_17 + 0.2 + 0)
local var_9_21 = var_9_14 + 1.5 * math.cos(var_9_17 + 1.35)
local var_9_22 = var_9_15 + 1.5 * math.sin(var_9_17 + 1.35)
local var_9_23 = isLineOfSightClear(var_9_19, var_9_20, var_9_16 + iter_9_3, var_9_21, var_9_22, var_9_16 + iter_9_3, true, true, true, true, false)
local var_9_24 = var_9_14 + 0.4 * math.cos(var_9_17 + 3 + 0)
local var_9_25 = var_9_15 + 0.4 * math.sin(var_9_17 + 3 + 0)
local var_9_26 = var_9_14 + 1.5 * math.cos(var_9_17 + 1.75)
local var_9_27 = var_9_15 + 1.5 * math.sin(var_9_17 + 1.75)
local var_9_28 = isLineOfSightClear(var_9_24, var_9_25, var_9_16 + iter_9_3, var_9_26, var_9_27, var_9_16 + iter_9_3, true, true, true, true, false)
local var_9_29 = var_9_14 + 1.5 * math.cos(var_9_17 + 1.55)
local var_9_30 = var_9_15 + 1.5 * math.sin(var_9_17 + 1.55)
local var_9_31 = isLineOfSightClear(var_9_14, var_9_15, var_9_16 + iter_9_3, var_9_29, var_9_30, var_9_16 + iter_9_3, true, true, true, true, false)
if var_9_23 == false or var_9_28 == false or var_9_31 == false then
var_9_13 = false
break
end
end
end
if var_9_13 == false then
ClearLine(var_9_17)
else
setCameraPositionUnfixed(-0.3, var_9_17 + 4.7)
end
if arg_9_7 and arg_9_3 < var_9_18 then
setGameKeyState(1, -255)
elseif arg_9_7 == false then
setGameKeyState(1, -255)
end
if arg_9_4 then
local var_9_32 = readMemory(getCharPointer(PLAYER_PED) + 1133, 2, 0)
if var_9_32 == 32 or var_9_32 == 544 then
state_jump = true
else
state_jump = false
end
if getCharSpeed(PLAYER_PED) > 6 and state_jump and math.ceil(getCharHeading(PLAYER_PED)) == math.floor(getHeadingFromVector2d(arg_9_0 - var_9_14, arg_9_1 - var_9_15)) and var_9_18 > 10 then
setGameKeyState(14, 255)
else
setGameKeyState(16, 255)
end
end
until var_0_3 == false
end
function ClearLine(arg_10_0)
local var_10_0, var_10_1, var_10_2 = getCharCoordinates(PLAYER_PED)
for iter_10_0 = 0.3, 2, 0.2 do
local var_10_3 = iter_10_0 / 1.2
local var_10_4 = var_10_0 + 0.4 * math.cos(arg_10_0 + 0.2 - var_10_3)
local var_10_5 = var_10_1 + 0.4 * math.sin(arg_10_0 + 0.2 - var_10_3)
local var_10_6 = var_10_0 + 2 * math.cos(arg_10_0 + 1.15 - iter_10_0)
local var_10_7 = var_10_1 + 2 * math.sin(arg_10_0 + 1.15 - iter_10_0)
local var_10_8 = isLineOfSightClear(var_10_4, var_10_5, var_10_2 - 0.5, var_10_6, var_10_7, var_10_2 - 0.5, true, true, true, true, false)
local var_10_9 = var_10_0 + 0.4 * math.cos(arg_10_0 + 2.6 - var_10_3)
local var_10_10 = var_10_1 + 0.4 * math.sin(arg_10_0 + 2.6 - var_10_3)
local var_10_11 = var_10_0 + 2 * math.cos(arg_10_0 + 1.6 - iter_10_0)
local var_10_12 = var_10_1 + 2 * math.sin(arg_10_0 + 1.6 - iter_10_0)
local var_10_13 = isLineOfSightClear(var_10_9, var_10_10, var_10_2 - 0.5, var_10_11, var_10_12, var_10_2 - 0.5, true, true, true, true, false)
local var_10_14 = var_10_0 + 2 * math.cos(arg_10_0 + 1.37 - iter_10_0)
local var_10_15 = var_10_1 + 2 * math.sin(arg_10_0 + 1.37 - iter_10_0)
local var_10_16 = isLineOfSightClear(var_10_0, var_10_1, var_10_2 - 0.5, var_10_14, var_10_15, var_10_2 - 0.5, true, true, true, true, false)
if var_10_8 and var_10_13 and var_10_16 then
local var_10_17 = math.rad(getHeadingFromVector2d(var_10_14 - var_10_0, var_10_15 - var_10_1))
setCameraPositionUnfixed(-0.3, var_10_17 + 0.1 + 4.7)
break
end
local var_10_18 = var_10_0 + 0.4 * math.cos(arg_10_0 + 0.2 + var_10_3)
local var_10_19 = var_10_1 + 0.4 * math.sin(arg_10_0 + 0.2 + var_10_3)
local var_10_20 = var_10_0 + 2 * math.cos(arg_10_0 + 1.15 + iter_10_0)
local var_10_21 = var_10_1 + 2 * math.sin(arg_10_0 + 1.15 + iter_10_0)
local var_10_22 = isLineOfSightClear(var_10_18, var_10_19, var_10_2 - 0.5, var_10_20, var_10_21, var_10_2 - 0.5, true, true, true, true, false)
local var_10_23 = var_10_0 + 0.4 * math.cos(arg_10_0 + 2.6 + var_10_3)
local var_10_24 = var_10_1 + 0.4 * math.sin(arg_10_0 + 2.6 + var_10_3)
local var_10_25 = var_10_0 + 2 * math.cos(arg_10_0 + 1.6 + iter_10_0)
local var_10_26 = var_10_1 + 2 * math.sin(arg_10_0 + 1.6 + iter_10_0)
local var_10_27 = isLineOfSightClear(var_10_23, var_10_24, var_10_2 - 0.5, var_10_25, var_10_26, var_10_2 - 0.5, true, true, true, true, false)
local var_10_28 = var_10_0 + 2 * math.cos(arg_10_0 + 1.37 + iter_10_0)
local var_10_29 = var_10_1 + 2 * math.sin(arg_10_0 + 1.37 + iter_10_0)
local var_10_30 = isLineOfSightClear(var_10_0, var_10_1, var_10_2 - 0.5, var_10_28, var_10_29, var_10_2 - 0.5, true, true, true, true, false)
if var_10_22 and var_10_27 and var_10_30 then
local var_10_31 = math.rad(getHeadingFromVector2d(var_10_28 - var_10_0, var_10_29 - var_10_1))
setCameraPositionUnfixed(-0.3, var_10_31 + 0.1 + 4.7)
break
end
end
end
function cmd_bot(arg_11_0)
var_0_3 = not var_0_3
if var_0_3 then
lua_thread.create(EnterCarExist)
var_0_4 = -1
var_0_7 = -1
var_0_6 = 0
_, var_0_5 = sampGetPlayerIdByCharHandle(PLAYER_PED)
writeMemory(7634870, 1, 1, 1)
writeMemory(7635034, 1, 1, 1)
var_0_1.fill(7623723, 144, 8)
var_0_1.fill(5499528, 144, 6)
sampAddChatMessage(string.format("[%s %s %s]:{FF4040} \xC0\xEA\xF2\xE8\xE2\xE8\xF0\xEE\xE2\xE0\xED", thisScript().name, thisScript().version, thisScript().authors[1]), 4259648)
else
showCursor(false, false)
writeMemory(7634870, 1, 0, 0)
writeMemory(7635034, 1, 0, 0)
var_0_1.hex2bin("5051FF1500838500", 7623723, 8)
var_0_1.hex2bin("0F847B010000", 5499528, 6)
sampAddChatMessage(string.format("[%s]: {3398fe}\xC4\xE5\xE0\xEA\xF2\xE8\xE2\xE8\xF0\xEE\xE2\xE0\xED", thisScript().name), 16728128)
end
end
function var_0_2.onSetPlayerAttachedObject(arg_12_0, arg_12_1, arg_12_2, arg_12_3)
if var_0_3 and arg_12_0 == var_0_5 then
if var_0_4 == -1 and arg_12_3.modelId == 2814 then
var_0_4 = 0
end
if var_0_4 == 1 and arg_12_3.modelId == 0 and isCharInAnyCar(PLAYER_PED) == false then
var_0_4 = 2
end
end
end
function var_0_2.onSetCheckpoint(arg_13_0, arg_13_1)
if var_0_3 and var_0_4 == 0 and arg_13_1 == 3 then
var_0_6 = math.floor(arg_13_0.x)
end
end
function var_0_2.onShowDialog(arg_14_0, arg_14_1, arg_14_2, arg_14_3, arg_14_4, arg_14_5)
if var_0_3 and arg_14_0 == 0 and arg_14_5:find("\xC2\xFB \xF3\xF1\xEF\xE5\xF8\xED\xEE \xEF\xEE\xEB\xEE\xE6\xE8\xEB\xE8 \xEF\xE8\xF6\xF6\xF3") then
return false
end
end
function var_0_2.onCreateObject(arg_15_0, arg_15_1)
if var_0_3 then
return false
end
end
function var_0_2.onShowTextDraw(arg_16_0, arg_16_1)
if var_0_3 then
if arg_16_1.text == "eng" and arg_16_1.boxColor == -14803284 then
sampSendChat("/engine")
end
if arg_16_1.text:find("icon2") then
sampSendClickTextdraw(arg_16_0)
end
end
end
function var_0_2.onApplyPlayerAnimation(arg_17_0, arg_17_1, arg_17_2, arg_17_3, arg_17_4, arg_17_5, arg_17_6, arg_17_7)
if var_0_3 and arg_17_0 == var_0_5 then
return false
end
end