Помогите добавить вторую команду в скрипт

Oldbiz

Участник
Автор темы
48
2
Версия SA-MP
  1. Любая
Помогите пожалуйста добавить вторую команду в скрипт, вот у меня есть скрипт, но хочу добавить, чтобы при вводе команды /oahp циклично использовался адреналин с задержкой в 1 секунду
 

Вложения

  • 160hp by Oldbiz.lua
    576 байт · Просмотры: 4

YarikVL

Известный
Проверенный
4,783
1,807
Помогите пожалуйста добавить вторую команду в скрипт, вот у меня есть скрипт, но хочу добавить, чтобы при вводе команды /oahp циклично использовался адреналин с задержкой в 1 секунду
Есть два способа:
1. Без потока:
Lua:
require "lib.moonloader"

local drugs = false

function main()
   while not isSampAvailable() do wait(100) end
   repeat wait(15000) until isSampAvailable()
 sampAddChatMessage("{FF00FF}Прокачка 160hp {FFFF00}by Oldbiz :)",  0xFF2020)
   sampRegisterChatCommand("ohp", function()
       drugs = not drugs
       sampAddChatMessage(drugs and "{00FF00}Прокачка началась" or "{FF0000}Прокачка закончилась", 0xFF2020)
   end)
   sampRegisterChatCommand("oahp", function()
      active = not active
      sampAddChatMessage(active and "Adrenalin ON" or "Adrenalin OFF")
   end)

while true do
       wait(0)
       if drugs then
          wait(100)
          sampSendChat("/usedrugs 3")
       end
       if active then
          wait(100)
          sampSendChat("/Komanda Adrenalina")
       end
   end
2. С потоками:
Lua:
require "lib.moonloader"

local drugs = false

function main()
   while not isSampAvailable() do wait(100) end
   repeat wait(15000) until isSampAvailable()
 sampAddChatMessage("{FF00FF}Прокачка 160hp {FFFF00}by Oldbiz :)",  0xFF2020)
   sampRegisterChatCommand("ohp", function()
       drugs = not drugs
       sampAddChatMessage(drugs and "{00FF00}Прокачка началась" or "{FF0000}Прокачка закончилась", 0xFF2020)
   end)
   sampRegisterChatCommand("oahp", function()
      active = not active
      sampAddChatMessage(active and "Adrenalin ON" or "Adrenalin OFF")
   end)
lua_thread.create(function()
   while true do wait(0)
      if drugs then
          wait(100)
          sampSendChat("/usedrugs 3")
       end
    end
end)
lua_thread.create(function()
   while true do wait(0)
       if active then
          wait(100)
          sampSendChat("/Komanda Adrenalina")
       end
   end
end)
Там уже можешь под себя подкорректировать ( задержки и команды активаций )
 
  • Нравится
Реакции: Oldbiz

Oldbiz

Участник
Автор темы
48
2
по
Есть два способа:
1. Без потока:
Lua:
require "lib.moonloader"

local drugs = false

function main()
   while not isSampAvailable() do wait(100) end
   repeat wait(15000) until isSampAvailable()
 sampAddChatMessage("{FF00FF}Прокачка 160hp {FFFF00}by Oldbiz :)",  0xFF2020)
   sampRegisterChatCommand("ohp", function()
       drugs = not drugs
       sampAddChatMessage(drugs and "{00FF00}Прокачка началась" or "{FF0000}Прокачка закончилась", 0xFF2020)
   end)
   sampRegisterChatCommand("oahp", function()
      active = not active
      sampAddChatMessage(active and "Adrenalin ON" or "Adrenalin OFF")
   end)

while true do
       wait(0)
       if drugs then
          wait(100)
          sampSendChat("/usedrugs 3")
       end
       if active then
          wait(100)
          sampSendChat("/Komanda Adrenalina")
       end
   end
2. С потоками:
Lua:
require "lib.moonloader"

local drugs = false

function main()
   while not isSampAvailable() do wait(100) end
   repeat wait(15000) until isSampAvailable()
 sampAddChatMessage("{FF00FF}Прокачка 160hp {FFFF00}by Oldbiz :)",  0xFF2020)
   sampRegisterChatCommand("ohp", function()
       drugs = not drugs
       sampAddChatMessage(drugs and "{00FF00}Прокачка началась" or "{FF0000}Прокачка закончилась", 0xFF2020)
   end)
   sampRegisterChatCommand("oahp", function()
      active = not active
      sampAddChatMessage(active and "Adrenalin ON" or "Adrenalin OFF")
   end)
lua_thread.create(function()
   while true do wait(0)
      if drugs then
          wait(100)
          sampSendChat("/usedrugs 3")
       end
    end
end)
lua_thread.create(function()
   while true do wait(0)
       if active then
          wait(100)
          sampSendChat("/Komanda Adrenalina")
       end
   end
end)
Там уже можешь под себя подкорректировать ( задержки и команды активаций )

Есть два способа:
1. Без потока:
Lua:
require "lib.moonloader"

local drugs = false

function main()
   while not isSampAvailable() do wait(100) end
   repeat wait(15000) until isSampAvailable()
 sampAddChatMessage("{FF00FF}Прокачка 160hp {FFFF00}by Oldbiz :)",  0xFF2020)
   sampRegisterChatCommand("ohp", function()
       drugs = not drugs
       sampAddChatMessage(drugs and "{00FF00}Прокачка началась" or "{FF0000}Прокачка закончилась", 0xFF2020)
   end)
   sampRegisterChatCommand("oahp", function()
      active = not active
      sampAddChatMessage(active and "Adrenalin ON" or "Adrenalin OFF")
   end)

while true do
       wait(0)
       if drugs then
          wait(100)
          sampSendChat("/usedrugs 3")
       end
       if active then
          wait(100)
          sampSendChat("/Komanda Adrenalina")
       end
   end
2. С потоками:
Lua:
require "lib.moonloader"

local drugs = false

function main()
   while not isSampAvailable() do wait(100) end
   repeat wait(15000) until isSampAvailable()
 sampAddChatMessage("{FF00FF}Прокачка 160hp {FFFF00}by Oldbiz :)",  0xFF2020)
   sampRegisterChatCommand("ohp", function()
       drugs = not drugs
       sampAddChatMessage(drugs and "{00FF00}Прокачка началась" or "{FF0000}Прокачка закончилась", 0xFF2020)
   end)
   sampRegisterChatCommand("oahp", function()
      active = not active
      sampAddChatMessage(active and "Adrenalin ON" or "Adrenalin OFF")
   end)
lua_thread.create(function()
   while true do wait(0)
      if drugs then
          wait(100)
          sampSendChat("/usedrugs 3")
       end
    end
end)
lua_thread.create(function()
   while true do wait(0)
       if active then
          wait(100)
          sampSendChat("/Komanda Adrenalina")
       end
   end
end)
Там уже можешь под себя подкорректировать ( задержки и команды активаций )
скрипт полностью перестал работать, даже старая команда

просто не запускается