Отыгровка

masiiksmasik3134

Участник
Автор темы
33
2
Версия MoonLoader
Другое
Как сделать отыгровку перед сообщением в /r? Пример:
Игрок пишет что-то в рацию -
/do Рация на плече
А дальше его сообщение
 
Решение
local text = tostring(text)
if text ~= nil and text:len() > 0 then
шо оно делает? :D
задает локальную переменную text, в которую присваивает текст с изменённым типом переменной в строковую
дальше идёт проверка есть ли какой либо текст после /r

Albertio

Attention! Thanks for your attention.
877
703
Lua:
require "lib.moonloader"
require "lib.sampfuncs"

function main()
  if not isSampLoaded() or not isSampfuncsLoaded() then return end
  while not isSampAvailable() do wait(100) end
  sampRegisterChatCommand('r', cmd_rchat)
  while true do
    wait(0)
  end
end

function cmd_rchat(text)
  local text = tostring(text)
  if text ~= nil and text:len() > 0 then
    lua_thread.create(function()
      sampSendChat("/do Рация на плече")
      wait(500)
      sampSendChat("/me нажав кнопку, передал сообщение по рации")
      wait(500)
      sampSendChat('/r '..text)
    end)
  else
    sampAddChatMessage('Используйте: /r [текст]', 0xCECECE)
  end
end
 

Albertio

Attention! Thanks for your attention.
877
703
local text = tostring(text)
if text ~= nil and text:len() > 0 then
шо оно делает? :D
задает локальную переменную text, в которую присваивает текст с изменённым типом переменной в строковую
дальше идёт проверка есть ли какой либо текст после /r
 
  • Нравится
Реакции: masiiksmasik3134

trefa

Известный
Всефорумный модератор
2,097
1,233
Lua:
require "lib.moonloader"
require "lib.sampfuncs"

function main()
  if not isSampLoaded() or not isSampfuncsLoaded() then return end
  while not isSampAvailable() do wait(100) end
  sampRegisterChatCommand('r', cmd_rchat)
  while true do
    wait(0)
  end
end

function cmd_rchat(text)
  local text = tostring(text)
  if text ~= nil and text:len() > 0 then
    lua_thread.create(function()
      sampSendChat("/do Рация на плече")
      wait(500)
      sampSendChat("/me нажав кнопку, передал сообщение по рации")
      wait(500)
      sampSendChat('/r '..text)
    end)
  else
    sampAddChatMessage('Используйте: /r [текст]', 0xCECECE)
  end
end
Lua:
local text = tostring(text)
Нахуя?