Помогите изменить активацию скрипта.

Статус
В этой теме нельзя размещать новые ответы.

vlads250

Известный
Автор темы
27
0
Есть скрипт, как сделать его активацию по вводу команды в чат? А то он активируется, только когда в чате видит [A] Nick_Name: /money id
Код:
script_name("Money")
script_version_number(0.1)
script_author("///")

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    adminlvl = 999
    lua_thread.create(money)
end
function money()
    while true do
        money, _ , _ , _ = sampGetChatString(99)
        if money ~= textmoney and adminlvl >= 2 then
            if string.match(money, "A] [A-z]+_[A-z]+[[0-9]+]: /money [0-9]+") ~= nil then
                moneyid = string.match(string.match(money, "/money %d+.-$"), "%d+")
                nickname = sampGetPlayerNickname(moneyid)
                sampSendChat("/money "..moneyid)
                while not sampIsDialogActive() do wait(0) end
                wait(200)
                dialogtext = sampGetDialogText()
                getMoney()
                sampAddChatMessage("[A] Деньги игрока "..nickname..":", 0x7ACC29)
                sampAddChatMessage("[A] Наличные: "..money1.."$ | Осн. банк. счет: "..money2.." | На всех счетах: "..money3.."$.", 0x7ACC29)
                sampAddChatMessage("[A] Всего денег: "..money4.."$.", 0x7ACC29)
            end
        end
        textmoney = money
        wait(0)
    end
end
function getMoney()
    money1 = string.match(string.match(dialogtext, "Наличные деньги:        [0-9]+"),"[0-9]+")
    money2 = string.match(string.match(dialogtext, "Осн. банковский счёт:        [0-9]+"), "[0-9]+")
    money3 = string.match(string.match(dialogtext, "На всех доп. банк. счетах:    [0-9]+"), "[0-9]+")
    money4 = money1 + money2 + money3
end
function getDevNick(name)
    name=string.gsub(name, "_", " ")
    p1=string.match(name, "[A-Z]")
    p2=string.match(name, " .-$")
    p3=p1..". "..p2
end
 

trefa

Известный
Всефорумный модератор
2,097
1,231
Lua:
script_name("Money")
script_version_number(0.1)
script_author("///")

act = false

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    adminlvl = 999
    sampRegisterChatCommand("mon", function()
        act = not act
    end)
    lua_thread.create(money)
end
function money()
    while true do
        if act then
        money, _ , _ , _ = sampGetChatString(99)
        if money ~= textmoney and adminlvl >= 2 then
            if string.match(money, "A] [A-z]+_[A-z]+[[0-9]+]: /money [0-9]+") ~= nil then
                moneyid = string.match(string.match(money, "/money %d+.-$"), "%d+")
                nickname = sampGetPlayerNickname(moneyid)
                sampSendChat("/money "..moneyid)
                while not sampIsDialogActive() do wait(0) end
                wait(200)
                dialogtext = sampGetDialogText()
                getMoney()
                sampAddChatMessage("[A] Деньги игрока "..nickname..":", 0x7ACC29)
                sampAddChatMessage("[A] Наличные: "..money1.."$ | Осн. банк. счет: "..money2.." | На всех счетах: "..money3.."$.", 0x7ACC29)
                sampAddChatMessage("[A] Всего денег: "..money4.."$.", 0x7ACC29)
            end
        end
        textmoney = money
        end
        wait(0)
    end
end
function getMoney()
    money1 = string.match(string.match(dialogtext, "Наличные деньги:        [0-9]+"),"[0-9]+")
    money2 = string.match(string.match(dialogtext, "Осн. банковский счёт:        [0-9]+"), "[0-9]+")
    money3 = string.match(string.match(dialogtext, "На всех доп. банк. счетах:    [0-9]+"), "[0-9]+")
    money4 = money1 + money2 + money3
end
function getDevNick(name)
    name=string.gsub(name, "_", " ")
    p1=string.match(name, "[A-Z]")
    p2=string.match(name, " .-$")
    p3=p1..". "..p2
end
 
Статус
В этой теме нельзя размещать новые ответы.