Вечная работа скрипта.

Firus20016

Участник
Автор темы
148
15
Версия MoonLoader
.025-beta
Приветствую всех. Пожалуйста, помогите исправить в коде такую фигню. Когда появляется диалог, то скрипт все время работает по заданному циклу и при любой попытке открыть диалог, никак не могу выбрать другой пункт. Приходится временно удалять скрипт. Мне нужно, что бы данный скрипт работал через определенный тайминг а не всю вечность проверял наличие диалога. Пожалуйста, помогите, а то то я тупенький как хлебушек.
Lua:
local sampev = require 'lib.samp.events'

 function main()
  if not isSampfuncsLoaded() or not isSampLoaded() then return end
  while not isSampAvailable() do wait(100) end
      while true do
        sampSendChat("/house")
        wait(1800000)
     end
 end

 function activatecmd()
    if active == 0 then -- Если active == 0, то присваиваем ему 1
        active = 1
    else -- Если active == 0, то присваиваем 1
        active = 0
      end
 end

 function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
     if dialogId == 174 then
       sampSendDialogResponse(174, 1, 1, -1)
       return false
     end
     if dialogId == 2431 then
       sampSendDialogResponse(2431, 1, 0, -1)
       return false
     end
     if dialogId == 185 then
       sampSendDialogResponse(185, 1, 6, -1)
       return false
     end
 end
 
Решение
Какой тайминг тебе нужен?
Как вариант можно поставить команду вкл/выкл скрипта
Lua:
local sampev = require 'lib.samp.events'
local active = true -- по дефолту скрипт будет включен

function main()
  if not isSampfuncsLoaded() or not isSampLoaded() then return end
  while not isSampAvailable() do wait(100) end
  sampRegisterChatCommand("script", activatecmd)
      while true do
        sampSendChat("/house")
        wait(1800000)
     end
end

function activatecmd()
    active = not active
    sampAddChatMessage("Скрипт ".. active and "{00FF00}Включен" or "{FF0000}Выключен", -1)
end

function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
     if dialogId == 174 and active then
       sampSendDialogResponse(174, 1, 1...

Quasper

Известный
834
354
Какой тайминг тебе нужен?
Как вариант можно поставить команду вкл/выкл скрипта
Lua:
local sampev = require 'lib.samp.events'
local active = true -- по дефолту скрипт будет включен

function main()
  if not isSampfuncsLoaded() or not isSampLoaded() then return end
  while not isSampAvailable() do wait(100) end
  sampRegisterChatCommand("script", activatecmd)
      while true do
        sampSendChat("/house")
        wait(1800000)
     end
end

function activatecmd()
    active = not active
    sampAddChatMessage("Скрипт ".. active and "{00FF00}Включен" or "{FF0000}Выключен", -1)
end

function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
     if dialogId == 174 and active then
       sampSendDialogResponse(174, 1, 1, -1)
       return false
     end
     if dialogId == 2431 and active then
       sampSendDialogResponse(2431, 1, 0, -1)
       return false
     end
     if dialogId == 185 and active then
       sampSendDialogResponse(185, 1, 6, -1)
       return false
     end
end
 
Последнее редактирование:

Firus20016

Участник
Автор темы
148
15
Какой тайминг тебе нужен?
Как вариант можно поставить команду вкл/выкл скрипта
Lua:
local sampev = require 'lib.samp.events'
local active = true -- по дефолту скрипт будет включен

function main()
  if not isSampfuncsLoaded() or not isSampLoaded() then return end
  while not isSampAvailable() do wait(100) end
  sampRegisterChatCommand("script", activatecmd)
      while true do
        sampSendChat("/house")
        wait(1800000)
     end
end

function activatecmd()
    active = not active
    sampAddChatMessage("Скрипт ".. active and "{00FF00}Включен" or "{FF0000}Выключен", -1)
end

function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
     if dialogId == 174 and active then
       sampSendDialogResponse(174, 1, 1, -1)
       return false
     end
     if dialogId == 2431 and active then
       sampSendDialogResponse(2431, 1, 0, -1)
       return false
     end
     if dialogId == 185 and active then
       sampSendDialogResponse(185, 1, 6, -1)
       return false
     end
end
выдаёт такие ошибки :
[ML] (error) AutoEatInHome: C:\Games\gta 1300\moonloader\AutoEat in house.lua:22: attempt to concatenate upvalue 'active' (a boolean value)
stack traceback:
C:\Games\gta 1300\moonloader\AutoEat in house.lua:22: in function <C:\Games\gta 1300\moonloader\AutoEat in house.lua:20>
[ML] (error) AutoEatInHome: Script died due to error. (36181884)