массив и говно код

Lance_Sterling

Известный
Автор темы
959
336
Версия MoonLoader
.026-beta
пытаюсь перебрать массив
Код:
function samp.onSendCommand(message)
    if mainIni.settings.auto_send_form then
        cmds_asf = {'jail', 'mute'}--комманд больше но не надо их сливать
        if mainIni.settings.alvl == 1 then
            for k, v in pairs(cmds_asf) do
                if cmd_asf:find(v) then
                    sampSendChat(message)
                    message = ''
                    return false
                end
            end
        end
    end
end
в итоге либо краш либо ошибка в мунлог, там чето с message связано
хелп пж
 

xColorized

Известный
1,108
476
пытаюсь перебрать массив
Код:
function samp.onSendCommand(message)
    if mainIni.settings.auto_send_form then
        cmds_asf = {'frem', 'rem', 'getip', 'flip', 'spawn', 'slap', 'mute', 'prison', 'kick', 'setmark', 'stats', 'showhistory', 'showhistoryoffline', 'aeject', 'amembers', 'sethp', 'unmute', 'pclist', 'adelbarricade', 'offstats', 'actiondel', 'warn', 'offwarn', 'tempskin', 'freeze', 'unfreeze', 'msg', 'unjail', 'pveh', 'alldelv', 'unwarn', 'auninvite', 'cc', 'offmute', 'offunmute', 'offunjail', 'offunprison', 'pc', 'ponline', 'ban', 'offban', 'unban', 'setweather', 'fuelvehs', 'banip', 'unbanip', 'hc', 'givecupon', 'resetcupon'}
        if mainIni.settings.alvl == 1 then
            for k, v in pairs(cmds_asf) do
                if cmd_asf:find(v) then
                    sampSendChat(message)
                    message = ''
                    return false
                end
            end
        end
    end
end
в итоге либо краш либо ошибка в мунлог, там чето с message связано
хелп пж
Lua:
function samp.onSendCommand(message)
    if mainIni.settings.auto_send_form then
        cmds_asf = {'frem', 'rem', 'getip', 'flip', 'spawn', 'slap', 'mute', 'prison', 'kick', 'setmark', 'stats', 'showhistory', 'showhistoryoffline', 'aeject', 'amembers', 'sethp', 'unmute', 'pclist', 'adelbarricade', 'offstats', 'actiondel', 'warn', 'offwarn', 'tempskin', 'freeze', 'unfreeze', 'msg', 'unjail', 'pveh', 'alldelv', 'unwarn', 'auninvite', 'cc', 'offmute', 'offunmute', 'offunjail', 'offunprison', 'pc', 'ponline', 'ban', 'offban', 'unban', 'setweather', 'fuelvehs', 'banip', 'unbanip', 'hc', 'givecupon', 'resetcupon'}
        if mainIni.settings.alvl == 1 then
            for i = 1, #cmds_asf do
                for k, v in pairs(cmds_asf) do
                    if (cmd_asf[i]):find(v) then
                        sampSendChat(message)
                        message = ''
                        return false
                    end
                end
            end
        end
    end
end
Попробуй так
 

Lance_Sterling

Известный
Автор темы
959
336
Lua:
function samp.onSendCommand(message)
    if mainIni.settings.auto_send_form then
        cmds_asf = {'frem', 'rem', 'getip', 'flip', 'spawn', 'slap', 'mute', 'prison', 'kick', 'setmark', 'stats', 'showhistory', 'showhistoryoffline', 'aeject', 'amembers', 'sethp', 'unmute', 'pclist', 'adelbarricade', 'offstats', 'actiondel', 'warn', 'offwarn', 'tempskin', 'freeze', 'unfreeze', 'msg', 'unjail', 'pveh', 'alldelv', 'unwarn', 'auninvite', 'cc', 'offmute', 'offunmute', 'offunjail', 'offunprison', 'pc', 'ponline', 'ban', 'offban', 'unban', 'setweather', 'fuelvehs', 'banip', 'unbanip', 'hc', 'givecupon', 'resetcupon'}
        if mainIni.settings.alvl == 1 then
            for i = 1, #cmds_asf do
                for k, v in pairs(cmds_asf) do
                    if (cmd_asf[i]):find(v) then
                        sampSendChat(message)
                        message = ''
                        return false
                    end
                end
            end
        end
    end
end
Попробуй так
[ML] (error) AdminTools.lua: ... Launcher\GTA SA (without ENB)\moonloader\AdminTools.lua:767: attempt to index global 'cmd_asf' (a nil value)
stack traceback:
... Launcher\GTA SA (without ENB)\moonloader\AdminTools.lua:767: in function 'callback'
...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:77: in function 'process_event'
...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:100: in function 'process_packet'
...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:119: in function <...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:118>
[ML] (error) AdminTools.lua: Script died due to an error. (0F92AFCC)


если написать cmds_asf

[ML] (error) AdminTools.lua: opcode '0AF9' call caused an unhandled exception
stack traceback:
[C]: in function 'sampSendChat'
... Launcher\GTA SA (without ENB)\moonloader\AdminTools.lua:768: in function 'callback'
...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:77: in function 'process_event'
...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:100: in function 'process_packet'
...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:119: in function <...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:118>
[C]: in function 'sampSendChat'
... Launcher\GTA SA (without ENB)\moonloader\AdminTools.lua:768: in function 'callback'
...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:77: in function 'process_event'
...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:100: in function 'process_packet'
...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:119: in function <...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:118>
...
...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:119: in function <...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:118>
[C]: in function 'sampSendChat'
... Launcher\GTA SA (without ENB)\moonloader\AdminTools.lua:768: in function 'callback'
...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:77: in function 'process_event'
...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:100: in function 'process_packet'
...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:119: in function <...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:118>
[C]: in function 'sampSendChat'
... Launcher\GTA SA (without ENB)\moonloader\AdminTools.lua:768: in function 'callback'
...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:77: in function 'process_event'
...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:100: in function 'process_packet'
...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:119: in function <...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:118>
[ML] (error) AdminTools.lua: Script died due to an error. (0FAF9344)
тыдыщ бабам нахуй
 

VRush

https://t.me/vrushscript
2,418
1,191
Lua:
function samp.onSendCommand(message)
    if mainIni.settings.auto_send_form then
        cmds_asf = {'frem', 'rem', 'getip', 'flip', 'spawn', 'slap', 'mute', 'prison', 'kick', 'setmark', 'stats', 'showhistory', 'showhistoryoffline', 'aeject', 'amembers', 'sethp', 'unmute', 'pclist', 'adelbarricade', 'offstats', 'actiondel', 'warn', 'offwarn', 'tempskin', 'freeze', 'unfreeze', 'msg', 'unjail', 'pveh', 'alldelv', 'unwarn', 'auninvite', 'cc', 'offmute', 'offunmute', 'offunjail', 'offunprison', 'pc', 'ponline', 'ban', 'offban', 'unban', 'setweather', 'fuelvehs', 'banip', 'unbanip', 'hc', 'givecupon', 'resetcupon'}
        if mainIni.settings.alvl == 1 then
            for k, v in ipairs(cmds_asf) do
                if message:find(v) then
                    sampSendChat(message)
                    return false
                end
            end
        end
    end
end
 

Lance_Sterling

Известный
Автор темы
959
336
Lua:
function samp.onSendCommand(message)
    if mainIni.settings.auto_send_form then
        cmds_asf = {'frem', 'rem', 'getip', 'flip', 'spawn', 'slap', 'mute', 'prison', 'kick', 'setmark', 'stats', 'showhistory', 'showhistoryoffline', 'aeject', 'amembers', 'sethp', 'unmute', 'pclist', 'adelbarricade', 'offstats', 'actiondel', 'warn', 'offwarn', 'tempskin', 'freeze', 'unfreeze', 'msg', 'unjail', 'pveh', 'alldelv', 'unwarn', 'auninvite', 'cc', 'offmute', 'offunmute', 'offunjail', 'offunprison', 'pc', 'ponline', 'ban', 'offban', 'unban', 'setweather', 'fuelvehs', 'banip', 'unbanip', 'hc', 'givecupon', 'resetcupon'}
        if mainIni.settings.alvl == 1 then
            for k, v in ipairs(cmds_asf) do
                if message:find(v) then
                    sampSendChat(message)
                    return false
                end
            end
        end
    end
end
crash game
 

VRush

https://t.me/vrushscript
2,418
1,191
Lua:
или как делал я в своем админ хелпере
local acmd = {
   {
      '/msg', '/jail', '/unjail', '/skick', '/spawn','/scapt', -- 2
      '/ban', '/unban', '/offban', '/offjail', '/offunjail', '/offmute', '/offunmute', '/offrmute', '/offunrmute', '/acm', '/unacm', -- 3
      '/sban', '/cban', '/uncban', '/offcban', '/open', '/close', -- 4
      '/scban', '/givegun', '/setskin', --5   
   },
   {
      '/ban', '/unban', '/offban', '/offjail', '/offunjail', '/offmute', '/offunmute', '/offrmute', '/offunrmute', '/acm', '/unacm', -- 3
      '/sban', '/cban', '/uncban', '/offcban', '/open', '/close', -- 4
      '/scban', '/givegun', '/setskin', --5   
   },
   {
      '/sban', '/cban', '/uncban', '/offcban', '/open', '/close', -- 4
      '/scban', '/givegun', '/setskin', --5   
   },
   {
      '/scban', '/givegun', '/setskin', --5   
   },
}

function sampev.onSendCommand(text)
   for lvl, list in ipairs(acmd) do
      for index, cmd in ipairs(list) do
         if cfg.config.adminlvl <= lvl and text:find('^'..cmd) then
            return {'/a '..text}
         end
      end
   end
end
 

Lance_Sterling

Известный
Автор темы
959
336
Lua:
или как делал я в своем админ хелпере
local acmd = {
   {
      '/msg', '/jail', '/unjail', '/skick', '/spawn','/scapt', -- 2
      '/ban', '/unban', '/offban', '/offjail', '/offunjail', '/offmute', '/offunmute', '/offrmute', '/offunrmute', '/acm', '/unacm', -- 3
      '/sban', '/cban', '/uncban', '/offcban', '/open', '/close', -- 4
      '/scban', '/givegun', '/setskin', --5  
   },
   {
      '/ban', '/unban', '/offban', '/offjail', '/offunjail', '/offmute', '/offunmute', '/offrmute', '/offunrmute', '/acm', '/unacm', -- 3
      '/sban', '/cban', '/uncban', '/offcban', '/open', '/close', -- 4
      '/scban', '/givegun', '/setskin', --5  
   },
   {
      '/sban', '/cban', '/uncban', '/offcban', '/open', '/close', -- 4
      '/scban', '/givegun', '/setskin', --5  
   },
   {
      '/scban', '/givegun', '/setskin', --5  
   },
}

function sampev.onSendCommand(text)
   for lvl, list in ipairs(acmd) do
      for index, cmd in ipairs(list) do
         if cfg.config.adminlvl <= lvl and text:find('^'..cmd) then
            return {'/a '..text}
         end
      end
   end
end
не понял
function sampev.onSendCommand(text)
for lvl, list in ipairs(acmd) do
for index, cmd in ipairs(list) do
if cfg.config.adminlvl <= lvl and text:find('^'..cmd) then
return {'/a '..text}
end
end
end
end
можешь просто сказать как сделать что бы мой массив перебрало и не крашнуло?
 

AeSiK256

Участник
58
24
[ML] (error) AdminTools.lua: ... Launcher\GTA SA (without ENB)\moonloader\AdminTools.lua:767: attempt to index global 'cmd_asf' (a nil value)
stack traceback:
... Launcher\GTA SA (without ENB)\moonloader\AdminTools.lua:767: in function 'callback'
...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:77: in function 'process_event'
...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:100: in function 'process_packet'
...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:119: in function <...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:118>
[ML] (error) AdminTools.lua: Script died due to an error. (0F92AFCC)


если написать cmds_asf

[ML] (error) AdminTools.lua: opcode '0AF9' call caused an unhandled exception
stack traceback:
[C]: in function 'sampSendChat'
... Launcher\GTA SA (without ENB)\moonloader\AdminTools.lua:768: in function 'callback'
...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:77: in function 'process_event'
...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:100: in function 'process_packet'
...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:119: in function <...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:118>
[C]: in function 'sampSendChat'
... Launcher\GTA SA (without ENB)\moonloader\AdminTools.lua:768: in function 'callback'
...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:77: in function 'process_event'
...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:100: in function 'process_packet'
...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:119: in function <...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:118>
...
...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:119: in function <...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:118>
[C]: in function 'sampSendChat'
... Launcher\GTA SA (without ENB)\moonloader\AdminTools.lua:768: in function 'callback'
...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:77: in function 'process_event'
...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:100: in function 'process_packet'
...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:119: in function <...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:118>
[C]: in function 'sampSendChat'
... Launcher\GTA SA (without ENB)\moonloader\AdminTools.lua:768: in function 'callback'
...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:77: in function 'process_event'
...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:100: in function 'process_packet'
...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:119: in function <...SA (without ENB)\moonloader\lib\lib\samp\events\core.lua:118>
[ML] (error) AdminTools.lua: Script died due to an error. (0FAF9344)
тыдыщ бабам нахуй
cmd_asf замени на cmds_asf
 
  • Нравится
Реакции: xColorized