Need help with .lua

demanding

Новичок
Автор темы
23
1
Is there anyone who can help me make the script below more flexible? I mean adding several commands according to their functions. /changeid to change idReplaceTo and /dialogid to change targetDialogId.

local ev = require 'samp.events'
local targetDialogId = 5
local idReplaceTo = 8
function ev.onShowDialog(dialogId, ...)
if dialogId == targetDialogId then
return {idReplaceTo, ...}
end
end
 

minxty

Известный
941
813
Lua:
local ev = require 'samp.events'
local targetDialogId = 5
local idReplaceTo = 8
function ev.onShowDialog(dialogId)
    if dialogId == targetDialogId then
        dialogId = idReplaceTo
    end
    return {dialogId}
end

function main()
    while not isSampAvailable do wait(0) end
    sampRegisterChatCommand('changeid', function(arg)
        id1, id2 = arg:match('(.+) (.+)')
        if tonumber(id1) and tonumber(id2) then
            targetDialogId = id1
            idReplaceTo = id2
            sampAddChatMessage('Replacing '..id1..' to '..id2, -1)
        end
    end)
    wait(-1)
end
use /changeid [targetDialogId] [idReplaceTo]
 
Последнее редактирование:
  • Нравится
Реакции: demanding

demanding

Новичок
Автор темы
23
1
Lua:
local ev = require 'samp.events'
local targetDialogId = 5
local idReplaceTo = 8
function ev.onShowDialog(dialogId)
    if dialogId == targetDialogId then
        dialogId = idReplaceTo
    end
    return {dialogId}
end

function main()
    while not isSampAvailable do wait(0) end
    sampRegisterChatCommand('changeid', function(arg)
        id1, id2 = arg:match('(.+) (.+)')
        if tonumber(id1) and tonumber(id2) then
            targetDialogId = id1
            idReplaceTo = id2
            sampAddChatMessage('Replacing '..id1..' to '..id2, -1)
        end
    end)
    wait(-1)
end
use /changeid [targetDialogId] [idReplaceTo]
When entering the login dialog, my GTA freezes/force closes.