Флуд при наведении на игрока

Neil_

Известный
Автор темы
204
32
Версия MoonLoader
Другое
Как сделать если я навёлся на игрока то в чат писало 1 раз что-то? Если создавать отдельную функция для команды, то в ней ничего не выводит

Lua:
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end

  while true do
    wait(0)
    result, pped = getCharPlayerIsTargeting(PLAYER_HANDLE)
    if result then
      sampAddChatMessage('Должно выполнятся 1 раз', -1)
  end
  end
end
 
Решение
Lua:
local count = 0
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end

  while true do
    wait(0)
        local result, pped = getCharPlayerIsTargeting(PLAYER_HANDLE)
        if result then
            if count == 1 then
                sampAddChatMessage('Должно выполнятся 1 раз', -1)
            end
            count = count + 1
        else count = 0
        end
    end
end

Manuel Leon

Известный
266
170
Lua:
local count = 0
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end

  while true do
    wait(0)
        local result, pped = getCharPlayerIsTargeting(PLAYER_HANDLE)
        if result then
            if count == 1 then
                sampAddChatMessage('Должно выполнятся 1 раз', -1)
            end
            count = count + 1
        else count = 0
        end
    end
end