Ошибка при добавлении строк

Памперс

Участник
Автор темы
68
9
Версия MoonLoader
.027.0-preview
Вообщем то решил дополнить arzcatcher, добавить функцию что бы он выбирал сам цвет и название лавки, но когда я добавил строки, скрипт начал крашить.
arzcatcher:
script_name("ARZCatcher")
script_author("ANONIMazer")

events = require "samp.events"
local font = renderCreateFont("Arial", 8, 5)
local status = false

function main()
    repeat wait(0) until isSampAvailable()
    sampAddChatMessage("{FF0000}[AC]{FFFFFF} Скрипт запущен! {ffb400}Разработчик: {FFFFFF}ANONIMazer. || {ffb400}ВК: {FFFFFF}@pu1seanon", -1)
    sampRegisterChatCommand('arzcatcher', function()
        status = not status
        if status then
            sampAddChatMessage("{FF0000}[BL]{FFFFFF} Скрипт вкключен...", -1)
        else
            sampAddChatMessage("{DA70D6}[BL]{FFFFFF} Скрипт выключен...", -1)
        end
    end)
    while true do
        wait(0)
    end
end

function events.onShowDialog(dialogId)
    if dialogId == 3010 and status then
        sampSendDialogResponse(dialogId, 1, 0, 0)
        sampAddChatMessage("{FF0000}[AC]{FFFFFF} Вы поймали {ffb400}лавку!", -1)
    end
end

function events.onSetObjectMaterialText(ev, data)
    local Object = sampGetObjectHandleBySampId(ev)
    if doesObjectExist(Object) and getObjectModel(Object) == 18663 and string.find(data.text, "(.-) {30A332}Свободная!") then
        if get_distance(Object) and status then
            lua_thread.create(press_key)
        end
    end
end

function press_key()
    setGameKeyState(21, 256)
end

function get_distance(Object)
    local result, posX, posY, posZ = getObjectCoordinates(Object)
    if result then
        if doesObjectExist(Object) then
            local pPosX, pPosY, pPosZ = getCharCoordinates(PLAYER_PED)
            local distance = (math.abs(posX - pPosX)^2 + math.abs(posY - pPosY)^2)^0.5
            local posX, posY = convert3DCoordsToScreen(posX, posY, posZ)
            if round(distance, 2) <= 0.9 then
                return true
            end
        end
    end
    return false
end

function round(x, n)
    n = math.pow(10, n or 0)
    x = x * n
    if x >= 0 then x = math.floor(x + 0.5) else x = math.ceil(x - 0.5) end
    return x / n
end

endwhile true do
    wait(0)
function events.onShowDialog(dialogId)
    if dialogId == 3021 and status then
    sampSendDialogResponse(dialogId, 1, 1, 0)
  end
end

endwhile true do
wait(0)
function events.onShowDialog(dialogId)
if dialogId == 3020 and status then
sampSendDialogResponse(dialogId, 1, 0, Дорогой скуп)
end
end

endwhile true do
wait(0)
function events.onShowDialog(dialogId)
if dialogId == 3030 and status then
sampSendDialogResponse(dialogId, 1, 1, 0)
end
end
вот сам код
Строки которые добавил:
endwhile true do
wait(0)
function events.onShowDialog(dialogId)
if dialogId == 3021 and status then
sampSendDialogResponse(dialogId, 1, 1, 0)
end
end

endwhile true do
wait(0)
function events.onShowDialog(dialogId)
if dialogId == 3020 and status then
sampSendDialogResponse(dialogId, 1, 0, Дорогой скуп)
end
end

endwhile true do
wait(0)
function events.onShowDialog(dialogId)
if dialogId == 3030 and status then
sampSendDialogResponse(dialogId, 1, 1, 0)
end
end
вот такие я строки добавил и скрипт начало крашить.
мунлог:
[13:44:04.837614] (error)    132.lua: C:\GTA 140K BY DAPO SHOW\moonloader\132.lua:44: '=' expected near 'true'
[13:44:04.837614] (error)    132.lua: Script died due to an error. (0E6D75C4)
вот что пишет в мунлоге

@chapo @Hatiko
 
Последнее редактирование:
Решение

@Hatiko Всё равно не помогло
код:
script_name("ARZCatcher")
script_author("ANONIMazer")

events = require "samp.events"
local font = renderCreateFont("Arial", 8, 5)
local status = false

function main()
    repeat wait(0) until isSampAvailable()
    sampAddChatMessage("{FF0000}[AC]{FFFFFF} Скрипт запущен! {ffb400}Разработчик: {FFFFFF}ANONIMazer. || {ffb400}ВК: {FFFFFF}@pu1seanon", -1)
    sampRegisterChatCommand('arzc', function()
        status = not status
        if status then
            sampAddChatMessage("{FF0000}[BL]{FFFFFF} Скрипт вкключен...", -1)
        else
            sampAddChatMessage("{DA70D6}[BL]{FFFFFF} Скрипт выключен...", -1)
        end
    end)
    while true do
        wait(0)
    end
end...

Памперс

Участник
Автор темы
68
9

@Hatiko Всё равно не помогло
код:
script_name("ARZCatcher")
script_author("ANONIMazer")

events = require "samp.events"
local font = renderCreateFont("Arial", 8, 5)
local status = false

function main()
    repeat wait(0) until isSampAvailable()
    sampAddChatMessage("{FF0000}[AC]{FFFFFF} Скрипт запущен! {ffb400}Разработчик: {FFFFFF}ANONIMazer. || {ffb400}ВК: {FFFFFF}@pu1seanon", -1)
    sampRegisterChatCommand('arzc', function()
        status = not status
        if status then
            sampAddChatMessage("{FF0000}[BL]{FFFFFF} Скрипт вкключен...", -1)
        else
            sampAddChatMessage("{DA70D6}[BL]{FFFFFF} Скрипт выключен...", -1)
        end
    end)
    while true do
        wait(0)
    end
end

function events.onShowDialog(dialogId)
    if dialogId == 3010 and status then
        sampSendDialogResponse(dialogId, 1, 0, 0)
        sampAddChatMessage("{FF0000}[AC]{FFFFFF} Вы поймали {ffb400}лавку!", -1)
    end
end

function events.onSetObjectMaterialText(ev, data)
    local Object = sampGetObjectHandleBySampId(ev)
    if doesObjectExist(Object) and getObjectModel(Object) == 18663 and string.find(data.text, "(.-) {30A332}Свободная!") then
        if get_distance(Object) and status then
            lua_thread.create(press_key)
        end
    end
end

function press_key()
    setGameKeyState(21, 256)
end

function get_distance(Object)
    local result, posX, posY, posZ = getObjectCoordinates(Object)
    if result then
        if doesObjectExist(Object) then
            local pPosX, pPosY, pPosZ = getCharCoordinates(PLAYER_PED)
            local distance = (math.abs(posX - pPosX)^2 + math.abs(posY - pPosY)^2)^0.5
            local posX, posY = convert3DCoordsToScreen(posX, posY, posZ)
            if round(distance, 2) <= 0.9 then
                return true
            end
        end
    end
    return false
end

function round(x, n)
    n = math.pow(10, n or 0)
    x = x * n
    if x >= 0 then x = math.floor(x + 0.5) else x = math.ceil(x - 0.5) end
    return x / n
end

    wait(0)
function events.onShowDialog(dialogId)
    if dialogId == 3021 and status then
    sampSendDialogResponse(dialogId, 1, 1, 0)
    end


function events.onShowDialog(dialogId)
if dialogId == 3020 and status then
sampSendDialogResponse(dialogId, 1, 0, "дорогой скуп")
end

function events.onShowDialog(dialogId)
if dialogId == 3030 and status then
sampSendDialogResponse(dialogId, 1, 1, 0)
end
код который щас
луа лог:
[ML] (error) 132.lua: C:\GTA 140K BY DAPO SHOW\moonloader\132.lua:82: 'end' expected (to close 'function' at line 78) near '<eof>'
[ML] (error) 132.lua: Script died due to an error. (0E6D0E94)
 
Последнее редактирование:
  • Нравится
Реакции: Hatiko

Dmitriy Makarov

25.05.2021
Проверенный
2,478
1,113

@Hatiko Всё равно не помогло
код:
script_name("ARZCatcher")
script_author("ANONIMazer")

events = require "samp.events"
local font = renderCreateFont("Arial", 8, 5)
local status = false

function main()
    repeat wait(0) until isSampAvailable()
    sampAddChatMessage("{FF0000}[AC]{FFFFFF} Скрипт запущен! {ffb400}Разработчик: {FFFFFF}ANONIMazer. || {ffb400}ВК: {FFFFFF}@pu1seanon", -1)
    sampRegisterChatCommand('arzc', function()
        status = not status
        if status then
            sampAddChatMessage("{FF0000}[BL]{FFFFFF} Скрипт вкключен...", -1)
        else
            sampAddChatMessage("{DA70D6}[BL]{FFFFFF} Скрипт выключен...", -1)
        end
    end)
    while true do
        wait(0)
    end
end

function events.onShowDialog(dialogId)
    if dialogId == 3010 and status then
        sampSendDialogResponse(dialogId, 1, 0, 0)
        sampAddChatMessage("{FF0000}[AC]{FFFFFF} Вы поймали {ffb400}лавку!", -1)
    end
end

function events.onSetObjectMaterialText(ev, data)
    local Object = sampGetObjectHandleBySampId(ev)
    if doesObjectExist(Object) and getObjectModel(Object) == 18663 and string.find(data.text, "(.-) {30A332}Свободная!") then
        if get_distance(Object) and status then
            lua_thread.create(press_key)
        end
    end
end

function press_key()
    setGameKeyState(21, 256)
end

function get_distance(Object)
    local result, posX, posY, posZ = getObjectCoordinates(Object)
    if result then
        if doesObjectExist(Object) then
            local pPosX, pPosY, pPosZ = getCharCoordinates(PLAYER_PED)
            local distance = (math.abs(posX - pPosX)^2 + math.abs(posY - pPosY)^2)^0.5
            local posX, posY = convert3DCoordsToScreen(posX, posY, posZ)
            if round(distance, 2) <= 0.9 then
                return true
            end
        end
    end
    return false
end

function round(x, n)
    n = math.pow(10, n or 0)
    x = x * n
    if x >= 0 then x = math.floor(x + 0.5) else x = math.ceil(x - 0.5) end
    return x / n
end

    wait(0)
function events.onShowDialog(dialogId)
    if dialogId == 3021 and status then
    sampSendDialogResponse(dialogId, 1, 1, 0)
    end


function events.onShowDialog(dialogId)
if dialogId == 3020 and status then
sampSendDialogResponse(dialogId, 1, 0, "дорогой скуп")
end

function events.onShowDialog(dialogId)
if dialogId == 3030 and status then
sampSendDialogResponse(dialogId, 1, 1, 0)
end
код который щас
луа лог:
[ML] (error) 132.lua: C:\GTA 140K BY DAPO SHOW\moonloader\132.lua:82: 'end' expected (to close 'function' at line 78) near '<eof>'
[ML] (error) 132.lua: Script died due to an error. (0E6D0E94)
Lua:
script_name("ARZCatcher")
script_author("ANONIMazer")

local events = require "samp.events"
local font = renderCreateFont("Arial", 8, 5)
local status = false

function main()
    repeat wait(0) until isSampAvailable()
    sampAddChatMessage("{FF0000}[AC]{FFFFFF} Скрипт запущен! {ffb400}Разработчик: {FFFFFF}ANONIMazer. || {ffb400}ВК: {FFFFFF}@pu1seanon", -1)
    sampRegisterChatCommand('arzc', function()
        status = not status
        sampAddChatMessage(status and "{FF0000}[BL]{FFFFFF} Скрипт включен..." or "{DA70D6}[BL]{FFFFFF} Скрипт выключен...", -1)
    end)
    while true do
        wait(0)
    end
end

function events.onShowDialog(dialogId, dialogStyle, dialogTitle, dialogButton1, dialogButton2, dialogText)
    if status then
        if dialogId == 3010 then
            sampSendDialogResponse(3010, 1, 0, 0)
            sampAddChatMessage("{FF0000}[AC]{FFFFFF} Вы поймали {ffb400}лавку!", -1)
        elseif dialogId == 3021 then
            sampSendDialogResponse(3021, 1, 1, 0)
        elseif dialogId == 3020 then
            sampSendDialogResponse(3020, 1, 0, "дорогой скуп")
        elseif dialogId == 3030 then
            sampSendDialogResponse(3030, 1, 1, 0)
        end
    end
end

function events.onSetObjectMaterialText(ev, data)
    local Object = sampGetObjectHandleBySampId(ev)
    if doesObjectExist(Object) and getObjectModel(Object) == 18663 and string.find(data.text, "(.-) {30A332}Свободная!") then
        if get_distance(Object) and status then
            lua_thread.create(press_key)
        end
    end
end

function press_key()
    setGameKeyState(21, 256)
end

function get_distance(Object)
    local result, posX, posY, posZ = getObjectCoordinates(Object)
    if result then
        if doesObjectExist(Object) then
            local pPosX, pPosY, pPosZ = getCharCoordinates(PLAYER_PED)
            local distance = (math.abs(posX - pPosX)^2 + math.abs(posY - pPosY)^2)^0.5
            local posX, posY = convert3DCoordsToScreen(posX, posY, posZ)
            if round(distance, 2) <= 0.9 then
                return true
            end
        end
    end
    return false
end

function round(x, n)
    n = math.pow(10, n or 0)
    x = x * n
    if x >= 0 then x = math.floor(x + 0.5) else x = math.ceil(x - 0.5) end
    return x / n
end
 
  • Нравится
Реакции: Памперс

Памперс

Участник
Автор темы
68
9
Lua:
script_name("ARZCatcher")
script_author("ANONIMazer")

local events = require "samp.events"
local font = renderCreateFont("Arial", 8, 5)
local status = false

function main()
    repeat wait(0) until isSampAvailable()
    sampAddChatMessage("{FF0000}[AC]{FFFFFF} Скрипт запущен! {ffb400}Разработчик: {FFFFFF}ANONIMazer. || {ffb400}ВК: {FFFFFF}@pu1seanon", -1)
    sampRegisterChatCommand('arzc', function()
        status = not status
        sampAddChatMessage(status and "{FF0000}[BL]{FFFFFF} Скрипт включен..." or "{DA70D6}[BL]{FFFFFF} Скрипт выключен...", -1)
    end)
    while true do
        wait(0)
    end
end

function events.onShowDialog(dialogId, dialogStyle, dialogTitle, dialogButton1, dialogButton2, dialogText)
    if status then
        if dialogId == 3010 then
            sampSendDialogResponse(3010, 1, 0, 0)
            sampAddChatMessage("{FF0000}[AC]{FFFFFF} Вы поймали {ffb400}лавку!", -1)
        elseif dialogId == 3021 then
            sampSendDialogResponse(3021, 1, 1, 0)
        elseif dialogId == 3020 then
            sampSendDialogResponse(3020, 1, 0, "дорогой скуп")
        elseif dialogId == 3030 then
            sampSendDialogResponse(3030, 1, 1, 0)
        end
    end
end

function events.onSetObjectMaterialText(ev, data)
    local Object = sampGetObjectHandleBySampId(ev)
    if doesObjectExist(Object) and getObjectModel(Object) == 18663 and string.find(data.text, "(.-) {30A332}Свободная!") then
        if get_distance(Object) and status then
            lua_thread.create(press_key)
        end
    end
end

function press_key()
    setGameKeyState(21, 256)
end

function get_distance(Object)
    local result, posX, posY, posZ = getObjectCoordinates(Object)
    if result then
        if doesObjectExist(Object) then
            local pPosX, pPosY, pPosZ = getCharCoordinates(PLAYER_PED)
            local distance = (math.abs(posX - pPosX)^2 + math.abs(posY - pPosY)^2)^0.5
            local posX, posY = convert3DCoordsToScreen(posX, posY, posZ)
            if round(distance, 2) <= 0.9 then
                return true
            end
        end
    end
    return false
end

function round(x, n)
    n = math.pow(10, n or 0)
    x = x * n
    if x >= 0 then x = math.floor(x + 0.5) else x = math.ceil(x - 0.5) end
    return x / n
end
Мне не нужно в противном случае, мне надо короче что бы лавку ловило и потом цвет меняло и названия
 

FixZer

Активный
126
36

@Hatiko Всё равно не помогло
код:
script_name("ARZCatcher")
script_author("ANONIMazer")

events = require "samp.events"
local font = renderCreateFont("Arial", 8, 5)
local status = false

function main()
    repeat wait(0) until isSampAvailable()
    sampAddChatMessage("{FF0000}[AC]{FFFFFF} Скрипт запущен! {ffb400}Разработчик: {FFFFFF}ANONIMazer. || {ffb400}ВК: {FFFFFF}@pu1seanon", -1)
    sampRegisterChatCommand('arzc', function()
        status = not status
        if status then
            sampAddChatMessage("{FF0000}[BL]{FFFFFF} Скрипт вкключен...", -1)
        else
            sampAddChatMessage("{DA70D6}[BL]{FFFFFF} Скрипт выключен...", -1)
        end
    end)
    while true do
        wait(0)
    end
end

function events.onShowDialog(dialogId)
    if dialogId == 3010 and status then
        sampSendDialogResponse(dialogId, 1, 0, 0)
        sampAddChatMessage("{FF0000}[AC]{FFFFFF} Вы поймали {ffb400}лавку!", -1)
    end
end

function events.onSetObjectMaterialText(ev, data)
    local Object = sampGetObjectHandleBySampId(ev)
    if doesObjectExist(Object) and getObjectModel(Object) == 18663 and string.find(data.text, "(.-) {30A332}Свободная!") then
        if get_distance(Object) and status then
            lua_thread.create(press_key)
        end
    end
end

function press_key()
    setGameKeyState(21, 256)
end

function get_distance(Object)
    local result, posX, posY, posZ = getObjectCoordinates(Object)
    if result then
        if doesObjectExist(Object) then
            local pPosX, pPosY, pPosZ = getCharCoordinates(PLAYER_PED)
            local distance = (math.abs(posX - pPosX)^2 + math.abs(posY - pPosY)^2)^0.5
            local posX, posY = convert3DCoordsToScreen(posX, posY, posZ)
            if round(distance, 2) <= 0.9 then
                return true
            end
        end
    end
    return false
end

function round(x, n)
    n = math.pow(10, n or 0)
    x = x * n
    if x >= 0 then x = math.floor(x + 0.5) else x = math.ceil(x - 0.5) end
    return x / n
end

    wait(0)
function events.onShowDialog(dialogId)
    if dialogId == 3021 and status then
    sampSendDialogResponse(dialogId, 1, 1, 0)
    end


function events.onShowDialog(dialogId)
if dialogId == 3020 and status then
sampSendDialogResponse(dialogId, 1, 0, "дорогой скуп")
end

function events.onShowDialog(dialogId)
if dialogId == 3030 and status then
sampSendDialogResponse(dialogId, 1, 1, 0)
end
код который щас
луа лог:
[ML] (error) 132.lua: C:\GTA 140K BY DAPO SHOW\moonloader\132.lua:82: 'end' expected (to close 'function' at line 78) near '<eof>'
[ML] (error) 132.lua: Script died due to an error. (0E6D0E94)
Исправлено!:
script_name("ARZCatcher")
script_author("ANONIMazer")

events = require "samp.events"
local font = renderCreateFont("Arial", 8, 5)
local status = false

function main()
    repeat wait(0) until isSampAvailable()
    sampAddChatMessage("{FF0000}[AC]{FFFFFF} Скрипт запущен! {ffb400}Разработчик: {FFFFFF}ANONIMazer. || {ffb400}ВК: {FFFFFF}@pu1seanon", -1)
    sampRegisterChatCommand('arzc', function()
        status = not status
        if status then
            sampAddChatMessage("{FF0000}[BL]{FFFFFF} Скрипт вкключен...", -1)
        else
            sampAddChatMessage("{DA70D6}[BL]{FFFFFF} Скрипт выключен...", -1)
        end
    end)
    while true do
        wait(0)
    end
end

function events.onSetObjectMaterialText(ev, data)
    local Object = sampGetObjectHandleBySampId(ev)
    if doesObjectExist(Object) and getObjectModel(Object) == 18663 and string.find(data.text, "(.-) {30A332}Свободная!") then
        if get_distance(Object) and status then
            lua_thread.create(press_key)
        end
    end
end

function press_key()
    setGameKeyState(21, 256)
end

function get_distance(Object)
    local result, posX, posY, posZ = getObjectCoordinates(Object)
    if result then
        if doesObjectExist(Object) then
            local pPosX, pPosY, pPosZ = getCharCoordinates(PLAYER_PED)
            local distance = (math.abs(posX - pPosX)^2 + math.abs(posY - pPosY)^2)^0.5
            local posX, posY = convert3DCoordsToScreen(posX, posY, posZ)
            if round(distance, 2) <= 0.9 then
                return true
            end
        end
    end
    return false
end

function round(x, n)
    n = math.pow(10, n or 0)
    x = x * n
    if x >= 0 then x = math.floor(x + 0.5) else x = math.ceil(x - 0.5) end
    return x / n
end

function events.onShowDialog(dialogId)
    if dialogId == 3010 and status then
        sampSendDialogResponse(dialogId, 1, 0, 0)
        sampAddChatMessage("{FF0000}[AC]{FFFFFF} Вы поймали {ffb400}лавку!", -1)
    elseif dialogId == 3021 and status then
        sampSendDialogResponse(dialogId, 1, 1, 0)
    elseif dialogId == 3020 and status then
        sampSendDialogResponse(dialogId, 1, 0, "дорогой скуп")
    elseif dialogId == 3030 and status then
        sampSendDialogResponse(dialogId, 1, 1, 0)
    end
end


Все перепроверил и исправил, можешь проверять
 
Последнее редактирование: