script_name("PizzaBot")
script_authors("by_k0lenval")
script_version("0.2b")
script_dependencies()
slot0 = require("vkeys")
slot1 = require("memory")
slot2 = require("lib.samp.events")
slot3, slot4, slot5, slot6, slot7 = nil
function main()
if not isSampfuncsLoaded() or not isSampLoaded() then
return
end
while not isSampAvailable() do
wait(0)
end
sampAddChatMessage(string.format("{00AAFF}%s {FFFF00}успешно загружен. Команда активации - {FF4400}/pizb", thisScript().name), 16776960)
sampRegisterChatCommand("pizb", cmd_bot)
while true do
wait(0)
if uv0 and isPlayerPlaying(playerHandle) and sampGetPlayerIdByCharHandle(PLAYER_PED) then
if uv1 == -1 then
if isCharInAnyCar(PLAYER_PED) == false then
BeginToPoint(1751, 2216, 10.84, 0.6, true, false, true, false)
uv2 = 0
else
setGameKeyState(15, 255)
wait(200)
end
end
if uv1 == 0 and uv2 ~= 0 and isCharInAnyCar(PLAYER_PED) then
uv1 = InCarGo(uv2, uv1)
end
if uv1 == 1 and isCharInAnyCar(PLAYER_PED) == false then
slot0 = 0
slot1 = 0
slot2 = 0
if uv2 == 2030 then
slot2 = 10.35
slot1 = 987.18
slot0 = 2031.56
end
if uv2 == 2600 then
slot2 = 10.35
slot1 = 1058.92
slot0 = 2599.83
end
if uv2 == 2320 then
slot2 = 10.35
slot1 = 2420.32
slot0 = 2326.42
end
if uv2 == 2345 then
slot2 = 10.35
slot1 = 2406.56
slot0 = 2350.04
end
if uv2 == 2534 then
slot2 = 10.82
slot1 = 2135.69
slot0 = 2536.94
end
if uv2 == -53 then
slot2 = 18.9
slot1 = 1207.61
slot0 = -61.68
end
if uv2 == -85 then
slot2 = 3.12
slot1 = 102.05
slot0 = -86.58
end
if uv2 == -86 then
slot2 = 1.43
slot1 = -311.71
slot0 = -103.62
end
if slot0 ~= 0 then
BeginToPoint(slot0, slot1, slot2, 0.8, true, false, false, true)
end
end
if uv1 == 2 and isCharInAnyCar(PLAYER_PED) then
uv1 = InCarGo(uv2, uv1)
end
end
end
end
function InCarGo(slot0, slot1)
slot3 = {}
if io.open("moonloader\\PathPizBot\\" .. slot0 .. ".txt", "r+") == nil then
return slot1
end
if slot2 then
for slot7 in slot2:lines() do
table.insert(slot3, slot7)
end
end
if slot1 == 2 then
slot3 = ReverseTable(slot3)
end
if slot3 then
for slot7, slot8 in pairs(slot3) do
uv0 = storeCarCharIsInNoSave(PLAYER_PED)
slot10 = os.time()
if uv1 == false then
break
end
slot11, slot12, slot13, slot14 = slot8:match("{(.*)}:{(.*)}:{(.*)}:{(.*)}")
end
if slot1 == 2 then
slot1 = -1
elseif slot1 == 0 then
slot1 = 1
end
end
return slot1
end
function EnterCarExist()
while true do
wait(0)
if uv0 and isCharInAnyCar(PLAYER_PED) == false and (uv1 == 0 or uv1 == 2) then
wait(100)
BoolFind, Car, Lock = FuncFindCar(uv2)
if BoolFind then
slot4, slot5, slot6 = getCarCoordinates(Car)
BeginToPoint(slot0, slot1, slot2, 2, true, true, false, false, Lock)
else
print("Не найден байк")
end
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(slot0)
slot1 = {
[#slot0 + 1 - slot6] = slot7
}
for slot6, slot7 in ipairs(slot0) do
end
return slot1
end
function turning_mechanism(slot0, slot1, slot2, slot3, slot4)
if getHeadingFromVector2d(math.deg(math.sin(slot5)), math.deg(math.cos(math.rad(getHeadingFromVector2d(slot0 - slot2, slot1 - slot3) + math.abs(getCarHeading(slot4) - 360))))) > 180 and slot6 < 355 then
setGameKeyState(0, -128)
elseif slot6 > 5 and slot6 <= 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(slot0)
slot3 = false
slot4 = 0
slot5 = false
for slot9, slot10 in pairs(slot1) do
if doesVehicleExist(slot10) and getNameOfVehicleModel(getCarModel(slot10)) == "PIZZABO" and getDriverOfCar(slot10) == -1 and getCarDoorLockStatus(slot10) == 0 or doesVehicleExist(slot10) and getNameOfVehicleModel(getCarModel(slot10)) == "PIZZABO" and getDriverOfCar(slot10) == -1 and slot0 == slot10 then
slot18, slot19, slot20 = getCharCoordinates(PLAYER_PED)
slot21, slot22, slot23 = getCarCoordinates(slot10)
if ({})[1] == nil then
slot2 = {
slot10,
getDistanceBetweenCoords3d(slot11, slot12, slot13, slot14, slot15, slot16)
}
elseif slot17 < slot2[2] then
slot2 = {
slot10,
slot17
}
end
end
end
if slot2[1] ~= nil and slot2[2] < 80 then
if slot0 == slot2[1] then
slot5 = true
end
slot3 = true
end
return slot3, slot2[1], slot5
end
function BeginToPoint(slot0, slot1, slot2, slot3, slot4, slot5, slot6, slot7, slot8)
slot9 = os.time()
slot10, slot11, slot19 = getCharCoordinates(PLAYER_PED)
slot13 = getDistanceBetweenCoords3d(slot0, slot1, slot2, slot10, slot11, slot12)
slot15 = math.ceil(getHeadingFromVector2d(slot0 - slot10, slot1 - slot11))
for slot22 = 0, 180, 1 do
slot18 = 0 + 1
slot17 = math.ceil(getCharHeading(PLAYER_PED)) - 1
if math.ceil(getCharHeading(PLAYER_PED)) + 1 > 360 then
slot16 = 0
end
if slot17 < 0 then
slot17 = 360
end
if slot16 == slot15 or slot17 == slot15 then
break
end
end
if slot16 == slot15 then
for slot22 = 0, slot18, math.random(3, 5) do
if slot7 and slot3 < slot13 then
setGameKeyState(1, -255)
elseif slot7 == false then
setGameKeyState(1, -255)
end
wait(0)
if uv0 then
setCameraPositionUnfixed(-0.3, math.rad(slot14 + slot22 + 270))
end
end
else
for slot22 = 0, slot18, math.random(3, 5) do
if slot7 and slot3 < slot13 then
setGameKeyState(1, -255)
elseif slot7 == false then
setGameKeyState(1, -255)
end
wait(0)
if uv0 then
setCameraPositionUnfixed(-0.3, math.rad(slot14 - slot22 + 270))
end
end
end
wait(0)
slot19 = true
slot20 = true
slot21 = true
slot22 = true
slot23, slot24, slot25 = getCharCoordinates(PLAYER_PED)
slot26 = math.rad(getHeadingFromVector2d(slot0 - slot23, slot1 - slot24))
slot13 = getDistanceBetweenCoords3d(slot0, slot1, slot2, slot23, slot24, slot2)
end
function ClearLine(slot0)
slot1, slot2, slot3 = getCharCoordinates(PLAYER_PED)
for slot7 = 0.3, 2, 0.2 do
if isLineOfSightClear(slot9, slot10, slot3 - 0.5, slot11, slot12, slot3 - 0.5, true, true, true, true, false) and isLineOfSightClear(slot14, slot15, slot3 - 0.5, slot16, slot17, slot3 - 0.5, true, true, true, true, false) and isLineOfSightClear(slot1, slot2, slot3 - 0.5, slot1 + 2 * math.cos(slot0 + 1.37 - slot7), slot2 + 2 * math.sin(slot0 + 1.37 - slot7), slot3 - 0.5, true, true, true, true, false) then
setCameraPositionUnfixed(-0.3, math.rad(getHeadingFromVector2d(slot19 - slot1, slot20 - slot2)) + 0.1 + 4.7)
break
end
if isLineOfSightClear(slot22, slot23, slot3 - 0.5, slot24, slot25, slot3 - 0.5, true, true, true, true, false) and isLineOfSightClear(slot27, slot28, slot3 - 0.5, slot29, slot30, slot3 - 0.5, true, true, true, true, false) and isLineOfSightClear(slot1, slot2, slot3 - 0.5, slot1 + 2 * math.cos(slot0 + 1.37 + slot7), slot2 + 2 * math.sin(slot0 + 1.37 + slot7), slot3 - 0.5, true, true, true, true, false) then
setCameraPositionUnfixed(-0.3, math.rad(getHeadingFromVector2d(slot32 - slot1, slot33 - slot2)) + 0.1 + 4.7)
break
end
end
end
function cmd_bot(slot0)
uv0 = not uv0
if uv0 then
lua_thread.create(EnterCarExist)
uv1 = -1
uv2 = -1
uv3 = 0
_, uv4 = sampGetPlayerIdByCharHandle(PLAYER_PED)
writeMemory(7634870, 1, 1, 1)
writeMemory(7635034, 1, 1, 1)
uv5.fill(7623723, 144, 8)
uv5.fill(5499528, 144, 6)
sampAddChatMessage(string.format("[%s %s %s]:{FF4040} Активирован", thisScript().name, thisScript().version, thisScript().authors[1]), 4259648)
else
showCursor(false, false)
writeMemory(7634870, 1, 0, 0)
writeMemory(7635034, 1, 0, 0)
uv5.hex2bin("5051FF1500838500", 7623723, 8)
uv5.hex2bin("0F847B010000", 5499528, 6)
sampAddChatMessage(string.format("[%s]: {3398fe}Деактивирован", thisScript().name), 16728128)
end
end
function slot2.onSetPlayerAttachedObject(slot0, slot1, slot2, slot3)
if uv0 and slot0 == uv1 then
if uv2 == -1 and slot3.modelId == 2814 then
uv2 = 0
end
if uv2 == 1 and slot3.modelId == 0 and isCharInAnyCar(PLAYER_PED) == false then
uv2 = 2
end
end
end
function slot2.onSetCheckpoint(slot0, slot1)
if uv0 and uv1 == 0 and slot1 == 3 then
uv2 = math.floor(slot0.x)
end
end
function slot2.onShowDialog(slot0, slot1, slot2, slot3, slot4, slot5)
if uv0 and slot0 == 0 and slot5:find("Вы успешно положили пиццу") then
return false
end
end
function slot2.onCreateObject(slot0, slot1)
if uv0 then
return false
end
end
function slot2.onShowTextDraw(slot0, slot1)
if uv0 then
if slot1.text == "eng" and slot1.boxColor == -14803284 then
sampSendChat("/engine")
end
if slot1.text:find("icon2") then
sampSendClickTextdraw(slot0)
end
end
end
function slot2.onApplyPlayerAnimation(slot0, slot1, slot2, slot3, slot4, slot5, slot6, slot7)
if uv0 and slot0 == uv1 then
return false
end
end