Скрипт не активируется

MoJlogou_XaKep

Участник
Автор темы
86
5
Версия MoonLoader
.026-beta
Сделал бота, но при вводе команды активации ничего не происходит
сам скрипт:
Код:
script_name("Shaxta bot by Kalgan")
script_authors("Kalgan_Kalganov")
script_description("Бот создан для  своих")
script_version("0.1")
script_dependencies("CLEO")

---------------------------------------------------------------------------

require "lib.moonloader"

---------------------------------------------------------------------------

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    sampRegisterChatCommand("botstart", cmd_bot)
    shaxta == 0
    local saveX = {}
    local saveY = {}
    local saveZ = {}
    local sampev = require "lib.samp.events"
    while true do
        wait(0)
        if isPlayerPlaying(playerHandle) and enabled then
---------------------------------------------------------------------------
            local posX, posY, posZ = GetCoordinates()
            local mfind, mposX, mposY, mposZ = SearchMarker(posX, posY, posZ, 150.000000, false)
            if mfind then BeginToPoint(mposX, mposY, mposZ, 1.000000, -255, false) end
            wait(10000)
            BeginToPoint(-1898.900024, 1247.760010, 1214.839966, 1.000000, -255, false)
            wait(1020)
            BeginToPoint(-1925.949951, 1247.910034, 1216.079956, 30.000000, -255, false)
            wait(510)
            local posX, posY, posZ = GetCoordinates()
            local mfind, mposX, mposY, mposZ = SearchMarker(posX, posY, posZ, 150.000000, false)
            if mfind then BeginToPoint(mposX, mposY, mposZ, 30.000000, -255, false) end
            wait(510)
            BeginToPoint(-1964.180054, 1248.329956, 1216.160034, 30.000000, -255, false)
            wait(510)
            BeginToPoint(-1912.709961, 1248.219971, 1216.770020, 30.000000, -255, false)
            wait(510)
end            
        
        if shaxta == 0 then main() end
        if sampev.onServerMessage(color, У вас сломалась кирка! Для продолжения работы необходимо купить новую!)
        then shaxta == 1
        else
        shaxta == 0 end
        
        if shaxta == 1 then Kirka() end
            
            
            
            
-----------------------------------------------------------------------
    end
end

function Kirka()
BeginToPoint(-1913.66, 1248.329956, 1248.18, 1216.58, -255, false)
wait(510)
local posX, posY, posZ = GetCoordinates()
local mfind, mposX, mposY, mposZ = SearchMarker(posX, posY, posZ, 150.000000, false)
if mfind then BeginToPoint(mposX, mposY, mposZ, 1.000000, -255, false) end
wait(510)
sampSendDialogResponse(9440, 1, 0, Лифт шахты )
wait (510)
BeginToPoint(-1894.32, 1248.219971, -1645.16, 21.77, -255, false)
wait(510)
BeginToPoint(-1870.060059, -1636.270020, 21.879999, -255, false)
local posX, posY, posZ = GetCoordinates()
local mfind, mposX, mposY, mposZ = SearchMarker(posX, posY, posZ, 150.000000, false)
if mfind then BeginToPoint(mposX, mposY, mposZ, 30.000000, -255, false) end
wait(510)
sampSendDialogResponse(9441, 1, 1, Покупка кирки )
wait(510)
sampCloseCurrentDialogWithButton(1)
wait(510)
BeginToPoint(-1873.93, -1639.25, 21.88, -255, false)
wait(510)
local posX, posY, posZ = GetCoordinates()
local mfind, mposX, mposY, mposZ = SearchMarker(posX, posY, posZ, 150.000000, false)
if mfind then BeginToPoint(mposX, mposY, mposZ, 1.000000, -255, false) end
wait(510)
sampSendDialogResponse(9440, 1, 4, Лифт шахты )
wait(510)
BeginToPoint(-1913.66, 1248.329956, 1248.18, 1216.58, -255, false)
wait(510)
if BeginToPoint(-1913.66, 1248.329956, 1248.18, 1216.58, -255, false)
then shaxta == 0 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 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
 

LoManuL Inc

Потрачен
589
106
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.

LoManuL Inc

Потрачен
589
106
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.

LoManuL Inc

Потрачен
589
106
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Но в чате имено "вас" пишиться. А это как тригер для покупки кирки
ну я знаю, но как пофиксить хз

 

MoJlogou_XaKep

Участник
Автор темы
86
5
ну я знаю, но как пофиксить хз

СУКА ХУЛИ ОН ПРИВЯЗАЛСЯ ДО ЭТОГО ВАС
 

Z3roKwq

Известный
294
157
крч я заебался пусть кто то другой допиливает, я кнч подкоректировал много, некоторое заменил, он кнч работать не будет но похуй

+/- нормальный код:
script_name("Shaxta bot by Kalgan")
script_authors("Kalgan_Kalganov")
script_description("Бот создан для своих")
script_version("0.1")

local sampev = require "lib.samp.events"
local saveX = {}
local saveY = {}
local saveZ = {}

shaxta = false

function main()
    repeat wait(0) until isSampAvailable()
    sampRegisterChatCommand("botstart", function()
        shaxta = not shaxta
        if shaxta == true then
            sampAddChatMessage(string.format("[%s]: Активирован", thisScript().name), 0x40FF40)
            runToPoint(-1913.66, 1248.329956, 1248.18)
            wait(510)
            local mc, posX, posY, posZ = GetCoordinates()
            local mfind, mposX, mposY, mposZ = SearchMarker(posX, posY, posZ, 150.000000, false)
            if mfind then runToPoint(mposX, mposY, mposZ) end
            wait(510)
                sampSendDialogResponse(9440, 1, 0, Лифт шахты)
            wait(510)
                runToPoint(-1894.32, 1248.219971, -1645.16)
            wait(510)
                runToPoint(-1870.060059, -1636.270020, 21.879999)
        
            local mfind, mposX, mposY, mposZ = SearchMarker(posX, posY, posZ, 150.000000, false)
            if mfind then
                runToPoint(mposX, mposY, mposZ)
            end
            wait(510)
                sampSendDialogResponse(9441, 1, 1, Покупка кирки)
            wait(510)
                sampCloseCurrentDialogWithButton(1)
            wait(510)
                runToPoint(-1873.93, -1639.25, 21.88)
            wait(510)
        
            local mfind, mposX, mposY, mposZ = SearchMarker(posX, posY, posZ, 150.000000, false)
            if mfind then
                runToPoint(mposX, mposY, mposZ)
            end
            wait(510)
                sampSendDialogResponse(9440, 1, 4, Лифт шахты)
            wait(510)
                runToPoint(-1913.66, 1248.329956, 1248.18)
            wait(510)
        end
        if shaxta == false then
            setCameraPositionUnfixed(0, 0)
            setGameKeyState(0, -255)
            sampAddChatMessage(string.format("[%s]: Дективирован", thisScript().name), 0x40FF40)
        end
        sampRegisterChatCommand("botstart2", function()
            enabled = not enabled
            if enabled == false then
                setCameraPositionUnfixed(0, 0)
                setGameKeyState(0, -255)
            end
        end)
    end)
    while true do
        wait(0)
        if isPlayerPlaying(playerHandle) and enabled then
            local posX, posY, posZ = GetCoordinates()
            local mfind, mposX, mposY, mposZ = SearchMarker(posX, posY, posZ, 150.000000, false)
            if mfind then
                runToPoint(mposX, mposY, mposZ)
            end
            wait(10000)
                runToPoint(-1898.900024, 1247.760010, 1214.839966)
            wait(1020)
                runToPoint(-1925.949951, 1247.910034, 1216.079956)
            wait(510)
            
            local find, moposX, moposY, moposZ = SearchMarker(posX, posY, posZ, 150.000000, false)
            if find then
                runToPoint(moposX, moposY, moposZ)
            end
            wait(510)
                runToPoint(-1964.180054, 1248.329956, 1216.160034)
            wait(510)
                runToPoint(-1912.709961, 1248.219971, 1216.770020)
            wait(510)
        end
    end
end

function sampev.onServerMessage(color, text) then
    if text:find("У вас сломалась кирка! Для продолжения работы необходимо купить новую!") and enabled or shaxta then
        setCameraPositionUnfixed(0, 0)
        setGameKeyState(0, -255)
    end
end



function runToPoint(tox, toy, toz)
    local setpX, setpY, setpZ = getCharCoordinates(PLAYER_PED)
    setCum({setpX, setpY, setpZ}, {tox, toy, toz})
    while getDistanceBetweenCoords2d(x, y, tox, toy) > 0.8 and enabled do
        setGameKeyState(1, -255)
        setGameKeyState(16, 1)
        wait(1)
        x, y, z = getCharCoordinates(PLAYER_PED)
        angle = getHeadingFromVector2d(tox - x, toy - y)
        setCameraPositionUnfixed(xAngle, math.rad(angle - 90))
    end
end

function setCum(pos1, pos2)
    local function f(ang)
     if ang > math.pi then
         ang = ang - (math.pi * 2)
     elseif ang < -math.pi then
         ang = ang + (math.pi * 2)
     end
     return ang
    end
    local vector = {pos1[1] - pos2[1], pos1[2] - pos2[2], pos1[3] - pos2[3]}
    if isWidescreenOnInOptions() then coefficentZ = 0.0778 else coefficentZ = 0.103 end
        local ang = {(math.atan2(vector[2], vector[1]) + 0.10000), (math.atan2((math.sqrt((math.pow(vector[1], 2) + math.pow(vector[2], 2)))), vector[3]) - math.pi / 2 - coefficentZ)}
        local vw = {f(representIntAsFloat(readMemory(0xB6F258, 4, false))), f(representIntAsFloat(readMemory(0xB6F248, 4, false)))}
        local df = {ang[1] - vw[1], ang[2] - vw[2]}
        local smth = {df[1] / 7, df[2] / 7}
        setCameraPositionUnfixed((vw[2] + smth[2]), (vw[1] + smth[1]))
end

function GetCoordinates()
    if isCharInAnyCar(playerPed) then
        local car = storeCarCharIsInNoSave(playerPed)
        return getCarCoordinates(car)
    else
        return getCharCoordinates(playerPed)
    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

https://www.blast.hk/threads/18157/ - обратись сюда, тебе врятли помогут, но это уже не мои проблемы