Найдите ошибку

fo-zsd

Новичок
Автор темы
4
0
Версия MoonLoader
.026-beta
Вообщем есть скрипт но не могу понять в чем ошибка есть команда в нем что-бы убрать подсказку в начале скрипта /pod но после ее прописи весь скрипт крашится, кидаю весь код пожалуйста помогите.
Lua:
script_author('fo-zsd')
script_version('v1.0')

local sampev = require("lib.samp.events")
local inicfg = require 'inicfg'
require("moonloader")
local act
local mainIni = inicfg.load({
  settings =
  {
    id = 50,
    summa = 50000,
    mode = 1
  }
    }, 'givemoney')
function main()
    repeat wait(0) until isSampAvailable()
    sampRegisterChatCommand('ggg', function() state = not state
        sampAddChatMessage(state and '{808080}givermoney {ffffff} [ {19ff19}ON {ffffff}]' or '{808080}givermoney {ffffff} [ {ff6666}OFF {ffffff}]', -1)
    end)
    sampRegisterChatCommand('pod', hint_command)
    sampAddChatMessage("{ffffff}Скрипт {19ff19}успешно {ffffff}загружен. {FFD700} Автор: {FF8C00}fo{FF0000}-{F0E68C}zsd", -1)
    if mainIni.settings.mode == 1 then
      sampAddChatMessage("Специально для {FFFFFF}BLAST{87CEEB}HACK", -1)
    sampAddChatMessage("Активация скрипта: {FFA500} /ggg", -1)
    sampAddChatMessage("Убрать/вернуть подсказку: {FFA500} /pod", -1)
  end

    while true do
        wait(0)
    if state then
        inicfg.load(mainIni)
        sampSendChat('/pay '..mainIni.settings.id..' '..mainIni.settings.summa)
        wait(30000)
                end

        function hint_command()
          if mainIni.settings.mode == 1 then
            sampAddChatMessage("{00AAFF}[givemoney]{FFFFFF} Подсказка была отключена", -1)
            mainIni.settings.mode = 0
            inicfg.save(mainIni, 'givemoney')
          else
            sampAddChatMessage("{00AAFF}[givemoney]{FFFFFF} Подсказка была включена", -1)
            mainIni.settings.mode = 1
            inicfg.save(mainIni, 'givemoney')
          end
        end
            end
end
заранее спасибо что помогли.
P.S Пробывал на другом коде у меня почему то не работает inicfg.save вот кстати лог из основного кода
[10:06:43.278089] (system) Session started.
[10:06:43.280088] (debug) Module handle: 7B280000

MoonLoader v.026.5-beta loaded.
Developers: FYP, hnnssy, EvgeN 1137

Copyright (c) 2016, BlastHack Team
https://www.blast.hk/moonloader/

[10:06:43.280088] (info) Working directory: D:\Games\GTA San Andreas\moonloader
[10:06:43.280088] (debug) FP Control: 0009001F
[10:06:43.280088] (debug) Game: GTA SA 1.0.0.0 US
[10:06:43.280088] (system) Installing pre-game hooks...
[10:06:43.282086] (system) Hooks installed.
[10:06:44.147554] (debug) Initializing opcode handler table
[10:06:44.147554] (debug) package.path = D:\Games\GTA San Andreas\moonloader\lib\?.lua;D:\Games\GTA San Andreas\moonloader\lib\?\init.lua;D:\Games\GTA San Andreas\moonloader\?.lua;D:\Games\GTA San Andreas\moonloader\?\init.lua;.\?.lua;D:\Games\GTA San Andreas\moonloader\lib\?.luac;D:\Games\GTA San Andreas\moonloader\lib\?\init.luac;D:\Games\GTA San Andreas\moonloader\?.luac;D:\Games\GTA San Andreas\moonloader\?\init.luac;.\?.luac
[10:06:44.147554] (debug) package.cpath = D:\Games\GTA San Andreas\moonloader\lib\?.dll;
[10:52:48.860249] (system) Loading script 'D:\Games\GTA San Andreas\moonloader\givemoney130.lua'...
[10:52:48.860249] (debug) New script: 166C5E4C
[10:52:48.864245] (system) givemoney130.lua: Loaded successfully.
[10:52:50.862247] (error) givemoney130.lua: attempt to call a nil value -- после прописи команды /pod
stack traceback:
[10:52:50.863245] (error) givemoney130.lua: Script died due to an error. (166C5E4C)
 
Последнее редактирование:

СоМиК

Известный
458
311
Вообщем есть скрипт но не могу понять в чем ошибка есть команда в нем что-бы убрать подсказку в начале скрипта /pod но после ее прописи весь скрипт крашится, кидаю весь код пожалуйста помогите.
Lua:
script_author('fo-zsd')
script_version('v1.0')

local sampev = require("lib.samp.events")
local inicfg = require 'inicfg'
require("moonloader")
local act
local mainIni = inicfg.load({
  settings =
  {
    id = 50,
    summa = 50000,
    mode = 1
  }
    }, 'givemoney')
function main()
    repeat wait(0) until isSampAvailable()
    sampRegisterChatCommand('ggg', function() state = not state
        sampAddChatMessage(state and '{808080}givermoney {ffffff} [ {19ff19}ON {ffffff}]' or '{808080}givermoney {ffffff} [ {ff6666}OFF {ffffff}]', -1)
    end)
    sampRegisterChatCommand('pod', hint_command)
    sampAddChatMessage("{ffffff}Скрипт {19ff19}успешно {ffffff}загружен. {FFD700} Автор: {FF8C00}fo{FF0000}-{F0E68C}zsd", -1)
    if mainIni.settings.mode == 1 then
      sampAddChatMessage("Специально для {FFFFFF}BLAST{87CEEB}HACK", -1)
    sampAddChatMessage("Активация скрипта: {FFA500} /ggg", -1)
    sampAddChatMessage("Убрать/вернуть подсказку: {FFA500} /pod", -1)
  end

    while true do
        wait(0)
    if state then
        inicfg.load(mainIni)
        sampSendChat('/pay '..mainIni.settings.id..' '..mainIni.settings.summa)
        wait(30000)
                end

        function hint_command()
          if mainIni.settings.mode == 1 then
            sampAddChatMessage("{00AAFF}[givemoney]{FFFFFF} Подсказка была отключена", -1)
            mainIni.settings.mode = 0
            inicfg.save(mainIni, 'givemoney')
          else
            sampAddChatMessage("{00AAFF}[givemoney]{FFFFFF} Подсказка была включена", -1)
            mainIni.settings.mode = 1
            inicfg.save(mainIni, 'givemoney')
          end
        end
            end
end
заранее спасибо что помогли.
P.S Пробывал на другом коде у меня почему то не работает inicfg.save вот кстати лог из основного кода
[10:06:43.278089] (system) Session started.
[10:06:43.280088] (debug) Module handle: 7B280000

MoonLoader v.026.5-beta loaded.
Developers: FYP, hnnssy, EvgeN 1137

Copyright (c) 2016, BlastHack Team

[10:06:43.280088] (info) Working directory: D:\Games\GTA San Andreas\moonloader
[10:06:43.280088] (debug) FP Control: 0009001F
[10:06:43.280088] (debug) Game: GTA SA 1.0.0.0 US
[10:06:43.280088] (system) Installing pre-game hooks...
[10:06:43.282086] (system) Hooks installed.
[10:06:44.147554] (debug) Initializing opcode handler table
[10:06:44.147554] (debug) package.path = D:\Games\GTA San Andreas\moonloader\lib\?.lua;D:\Games\GTA San Andreas\moonloader\lib\?\init.lua;D:\Games\GTA San Andreas\moonloader\?.lua;D:\Games\GTA San Andreas\moonloader\?\init.lua;.\?.lua;D:\Games\GTA San Andreas\moonloader\lib\?.luac;D:\Games\GTA San Andreas\moonloader\lib\?\init.luac;D:\Games\GTA San Andreas\moonloader\?.luac;D:\Games\GTA San Andreas\moonloader\?\init.luac;.\?.luac
[10:06:44.147554] (debug) package.cpath = D:\Games\GTA San Andreas\moonloader\lib\?.dll;
[10:52:48.860249] (system) Loading script 'D:\Games\GTA San Andreas\moonloader\givemoney130.lua'...
[10:52:48.860249] (debug) New script: 166C5E4C
[10:52:48.864245] (system) givemoney130.lua: Loaded successfully.
[10:52:50.862247] (error) givemoney130.lua: attempt to call a nil value -- после прописи команды /pod
stack traceback:
[10:52:50.863245] (error) givemoney130.lua: Script died due to an error. (166C5E4C)
Достаточно было убрать свою функцию из цикла, вот рабочий код с НОРМАЛЬНОЙ табуляцией

WOW:
script_author('fo-zsd')
script_version('v1.0')

local sampev = require("lib.samp.events")
local inicfg = require 'inicfg'
require("moonloader")
local act
local mainIni = inicfg.load({
    settings =
        {
            id = 50,
            summa = 50000,
            mode = 1
        }
    }, 'givemoney')
local hint_command = function()
    if mainIni.settings.mode == 1 then
        sampAddChatMessage("{00AAFF}[givemoney]{FFFFFF} Подсказка была отключена", -1)
        mainIni.settings.mode = 0
        inicfg.save(mainIni, 'givemoney')
    else
        sampAddChatMessage("{00AAFF}[givemoney]{FFFFFF} Подсказка была включена", -1)
        mainIni.settings.mode = 1
        inicfg.save(mainIni, 'givemoney')
    end
end
function main()
    repeat wait(0) until isSampAvailable()
    sampRegisterChatCommand('ggg', function() state = not state
        sampAddChatMessage(state and '{808080}givermoney {ffffff} [ {19ff19}ON {ffffff}]' or '{808080}givermoney {ffffff} [ {ff6666}OFF {ffffff}]', -1)
    end)
    sampRegisterChatCommand('pod', hint_command)
    sampAddChatMessage("{ffffff}Скрипт {19ff19}успешно {ffffff}загружен. {FFD700} Автор: {FF8C00}fo{FF0000}-{F0E68C}zsd", -1)
    if mainIni.settings.mode == 1 then
        sampAddChatMessage("Специально для {FFFFFF}BLAST{87CEEB}HACK", -1)
        sampAddChatMessage("Активация скрипта: {FFA500} /ggg", -1)
        sampAddChatMessage("Убрать/вернуть подсказку: {FFA500} /pod", -1)
    end

    while true do
        wait(0)
        if state then
            inicfg.load(mainIni)
            sampSendChat('/pay '..mainIni.settings.id..' '..mainIni.settings.summa)
            wait(30000)
        end
    end
end