что тут не так Lua

Lance Sterling

Потрачен
Автор темы
140
8
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
почему этот скрипт крашит обосовываясь тем что authorNick это nil
Lua:
local samp = require 'lib.samp.events'

function samp.onServerMessage(color, text)
    if text:find('[ЖБ] (%w+)[(%d+)] на (%w+)[(%d+)] прич.: (%w+)') then
        local authorNick, authorID, suspectNick, suspectID, reportText text:match('[ЖБ] (%w+)[(%d+)] на (%w+)[(%d+)] прич.: (%w+)')
      if text:find('Всего жалоб: (%d+)') then
        local reportAll text:match('Всего жалоб: (%d+)')
        if reportAll then
            sampSendChat('/ar')
        end
      end
    end
end
function sampGetListboxItemByText(text, plain)
    if not sampIsDialogActive() then return -1 end
    plain = not (plain == false)
    for i = 0, sampGetListboxItemsCount() - 1 do
        if sampGetListboxItemText(i):find(text, 1, plain) then
            return i
        end
    end
    return -1
end
function samp.onShowDialog(id, style, title, button1, button2, text)
    if id == 988 then
        local listItem = sampGetListboxItemByText(reportAll..'|'..authorNick)
        sampSendDialogResponse(dialogId, 0, listItem, '')
    end
end
украл из SF integration в консоли крч
[ML] (error) dialog — êîïèÿ.lua: D:\ãîòîâàÿ íîðì èãðà ìîðäîð\moonloader\dialog — êîïèÿ.lua:337: attempt to concatenate global 'authorNick' (a nil value)
stack traceback:
D:\ãîòîâàÿ íîðì èãðà ìîðäîð\moonloader\dialog — êîïèÿ.lua:337: in function 'callback'
...íîðì èãðà ìîðäîð\moonloader\lib\lib\samp\events\core.lua:77: in function 'process_event'
...íîðì èãðà ìîðäîð\moonloader\lib\lib\samp\events\core.lua:100: in function 'process_packet'
...íîðì èãðà ìîðäîð\moonloader\lib\lib\samp\events\core.lua:127: in function <...íîðì èãðà ìîðäîð\moonloader\lib\lib\samp\events\core.lua:126>
[ML] (error) dialog — êîïèÿ.lua: Script died due to an error. (101B3494)
 

Sadow

Известный
1,439
588
Lua:
local samp = require 'lib.samp.events'

function samp.onServerMessage(color, text)
    if text:find('%[ЖБ%] (.+)%[(%d+)%] на (.+)%[(%d+)%] прич%.%: (.+)') then
        authorNick, authorID, suspectNick, suspectID, reportText = text:match('%[ЖБ%] (.+)%[(%d+)%] на (.+)%[(%d+)%] прич%.%: (.+)')
      if text:find('Всего жалоб%: (%d+)') then
        local reportAll = text:match('Всего жалоб%: (%d+)')
        if reportAll then
            sampSendChat('/ar')
        end
      end
    end
end
function sampGetListboxItemByText(text, plain)
    if not sampIsDialogActive() then return -1 end
    plain = not (plain == false)
    for i = 0, sampGetListboxItemsCount() - 1 do
        if sampGetListboxItemText(i):find(text, 1, plain) then
            return i
        end
    end
    return -1
end
function samp.onShowDialog(id, style, title, button1, button2, text)
    if id == 988 then
        local listItem = sampGetListboxItemByText(reportAll..'|'..authorNick)
        sampSendDialogResponse(dialogId, 0, listItem, '')
    end
end
 

Lance Sterling

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

Lua:
local samp = require 'lib.samp.events'

function samp.onServerMessage(color, text)
    if text:find('%[ЖБ%] (.+)%[(%d+)%] на (.+)%[(%d+)%] прич%.%: (.+)') then
        authorNick, authorID, suspectNick, suspectID, reportText = text:match('%[ЖБ%] (.+)%[(%d+)%] на (.+)%[(%d+)%] прич%.%: (.+)')
      if text:find('Всего жалоб%: (%d+)') then
        local reportAll = text:match('Всего жалоб%: (%d+)')
        if reportAll then
            sampSendChat('/ar')
        end
      end
    end
end
function sampGetListboxItemByText(text, plain)
    if not sampIsDialogActive() then return -1 end
    plain = not (plain == false)
    for i = 0, sampGetListboxItemsCount() - 1 do
        if sampGetListboxItemText(i):find(text, 1, plain) then
            return i
        end
    end
    return -1
end
function samp.onShowDialog(id, style, title, button1, button2, text)
    if id == 988 then
        local listItem = sampGetListboxItemByText(reportAll..'|'..authorNick)
        sampSendDialogResponse(dialogId, 0, listItem, '')
    end
end
не работает
 
Последнее редактирование: