SA:MP time

sulovy

Новичок
Автор темы
25
0
Версия SA-MP
  1. 0.3.7 (R1)
in this code when i type /actog it starts timer with 5 seconds and every 5 seconds i types /mafiawar in chat basically it should automatically initiate mafia war and sometimes it prints "Don't Flood" in chat which messes up whole timing system and i can type /mafiawar every 5 seconds on the server and whats the issue?

code:
local sampev = require("samp.events")
local enabled = false
local checked = false

function main()
    while not isSampAvailable() do wait(100) end
    sampAddChatMessage('{C3B1E1}[AC] {FFFFFF}Warmatebit Chaitvirta by {C3B1E1}StoneStreetRasala {FFFFFF}| For EDRP | Gamoiyenet {C3B1E1}/actog', -1)
    sampRegisterChatCommand('actog', actog)
    while true do
        if enabled then
            wait(5000)
            sampSendChat('/mafiawar')
        end
        wait(0)
    end
    wait(-1)
end

function actog()
    enabled = not enabled
    if enabled then
        sampAddChatMessage('{C3B1E1}[AC] {FFFFFF}Warmatebit Chairto', -1)
    else
        sampAddChatMessage('{C3B1E1}[AC] {FFFFFF}Warmatebit Gamoirto', -1)
    end
end

function sampev.onServerMessage(color, text)
    if enabled then
        if string.match(text, "BizWar Shedzlebt Daiwyot (%d+) Wamshi") then
            -- Extract the number (timer) only from this pattern
            local num = string.match(text, "BizWar Shedzlebt Daiwyot (%d+) Wamshi")
            if num then
                -- Check if the number ends with 0 or 5
                if num:sub(-1) == "0" and checked == false or num:sub(-1) == "5" and checked == false then
                    checked = true
                    sampAddChatMessage("{C3B1E1}[AC] {FFFFFF}Auto Capturem Daiwyo Mushaoba, Gtxovt Agar Dawerot /mafiawar Chatshi!", -1)
                end
            end
        end
    end
end