Помогите

By.Egorka

Участник
Автор темы
70
18
Версия MoonLoader
.026-beta
помогите с скриптом надо чтобы сообщение показывало 1 раз
Говнокод:
     while true do
         wait(1111)
         if active then
             stype()
         end
     end
end

function stype()
    _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
    nick = sampGetPlayerNickname(id)
    sampAddChatMessage("Ваш ид:" ..id..  " | Ваш ник:" ..nick, -1 )
end
 

By.Egorka

Участник
Автор темы
70
18
1 раз при старте игры?
при команде
полн.код:
script_name("name")
script_author("By Egorka")
script_version("0.1")

require = "lib.moonloader"

local active = false
local a = false

function main()
     while not isSampAvailable() do wait(0) end
     sampRegisterChatCommand("ss", function()
         active = not active
         sampAddChatMessage(active and "Включен" or "Выключено", -1)
     end)
     sampRegisterChatCommand("su", function()
         a = not a
         sampAddChatMessage(a and "On" or "Off", -1  )
     end)
     while true do
         wait(1111)
         if active then
             stype()
         end
     end
end

function stype()
    _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
    nick = sampGetPlayerNickname(id)
    sampAddChatMessage("Ваш ид:" ..id..  " | Ваш ник:" ..nick, -1 )
end
 

ChromiusJ

Известный
Друг
4,900
3,188
при команде
полн.код:
script_name("name")
script_author("By Egorka")
script_version("0.1")

require = "lib.moonloader"

local active = false
local a = false

function main()
     while not isSampAvailable() do wait(0) end
     sampRegisterChatCommand("ss", function()
         active = not active
         sampAddChatMessage(active and "Включен" or "Выключено", -1)
     end)
     sampRegisterChatCommand("su", function()
         a = not a
         sampAddChatMessage(a and "On" or "Off", -1  )
     end)
     while true do
         wait(1111)
         if active then
             stype()
         end
     end
end

function stype()
    _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
    nick = sampGetPlayerNickname(id)
    sampAddChatMessage("Ваш ид:" ..id..  " | Ваш ник:" ..nick, -1 )
end
Lua:
script_name("name")
script_author("By Egorka")
script_version("0.1")

require "lib.moonloader"

local active = false

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand("ss", function()
        active = not active
        sampAddChatMessage(active and "Включен" or "Выключено", -1)
        stype()
    end)

    while true do
        wait(0)
    end
end

function stype()
    if active then
        local _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
        local nick = sampGetPlayerNickname(id)
        sampAddChatMessage("Ваш ид: " .. id .. " | Ваш ник: " .. nick, -1)
    end
end
 
  • Нравится
Реакции: By.Egorka и arpix

arpix

Активный
120
33
при команде
полн.код:
script_name("name")
script_author("By Egorka")
script_version("0.1")

require = "lib.moonloader"

local active = false
local a = false

function main()
     while not isSampAvailable() do wait(0) end
     sampRegisterChatCommand("ss", function()
         active = not active
         sampAddChatMessage(active and "Включен" or "Выключено", -1)
     end)
     sampRegisterChatCommand("su", function()
         a = not a
         sampAddChatMessage(a and "On" or "Off", -1  )
     end)
     while true do
         wait(1111)
         if active then
             stype()
         end
     end
end

function stype()
    _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
    nick = sampGetPlayerNickname(id)
    sampAddChatMessage("Ваш ид:" ..id..  " | Ваш ник:" ..nick, -1 )
end
у тебя получается так что при вводе команды переменная становится активной, а в цикле проверка все время, вот и флуд, попробуй так:
Lua:
script_name("name")
script_author("By Egorka")
script_version("0.1")

require = "lib.moonloader"

local active = false
local a = false

function main()
     while not isSampAvailable() do wait(0) end
     sampRegisterChatCommand("ss", function()
         active = not active
         sampAddChatMessage(active and "Включен" or "Выключено", -1)
     end)
     sampRegisterChatCommand("su", function()
         a = not a
         sampAddChatMessage(a and "On" or "Off", -1  )
     end)
     while true do wait(100)
         if active then
             stype()
         end
     end
end

function stype()
    _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
    nick = sampGetPlayerNickname(id)
    sampAddChatMessage("Ваш ид:" ..id..  " | Ваш ник:" ..nick, -1 )
    active = not active
end
ну или как выше тебе скинули
 
  • Влюблен
Реакции: By.Egorka

By.Egorka

Участник
Автор темы
70
18
у тебя получается так что при вводе команды переменная становится активной, а в цикле проверка все время, вот и флуд, попробуй так:
Lua:
script_name("name")
script_author("By Egorka")
script_version("0.1")

require = "lib.moonloader"

local active = false
local a = false

function main()
     while not isSampAvailable() do wait(0) end
     sampRegisterChatCommand("ss", function()
         active = not active
         sampAddChatMessage(active and "Включен" or "Выключено", -1)
     end)
     sampRegisterChatCommand("su", function()
         a = not a
         sampAddChatMessage(a and "On" or "Off", -1  )
     end)
     while true do wait(100)
         if active then
             stype()
         end
     end
end

function stype()
    _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
    nick = sampGetPlayerNickname(id)
    sampAddChatMessage("Ваш ид:" ..id..  " | Ваш ник:" ..nick, -1 )
    active = not active
end
ну или как выше тебе скинули
Спасибо!

Lua:
script_name("name")
script_author("By Egorka")
script_version("0.1")

require "lib.moonloader"

local active = false

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand("ss", function()
        active = not active
        sampAddChatMessage(active and "Включен" or "Выключено", -1)
        stype()
    end)

    while true do
        wait(0)
    end
end

function stype()
    if active then
        local _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
        local nick = sampGetPlayerNickname(id)
        sampAddChatMessage("Ваш ид: " .. id .. " | Ваш ник: " .. nick, -1)
    end
end
Спасибо!