Garry's Mod

Garry's Mod

EasyChat
EasyChat variables
I made script what make local and global role play commands, but he is not correctly working because i'dont know variables of EasyChat.

For example code:

local function handleRolePlayCommands(ply, text)
local command, action = string.match(text, "^/(%w+)%s*(.*)$")

if command == "me" then
-- Обработка ошибки для команды /me
ply:ChatPrint("Ошибка: Используйте команды /gme и /gdo для глобальных отыгровок, /lme и /ldo для локальных отыгровок в радиусе 300 метров.")
return ""
end

if command and action then
print("Команда:", command, "Действие:", action) -- Логирование

local players = player.GetAll()

if command == "gme" then
-- Глобальная отыгровка от первого лица
local message = string.format("(Глобально) [%s] *%s*", ply:GetName(), action)
for _, player in ipairs(players) do
player:ChatPrint(message)
end


elseif command == "lme" then
-- Локальная отыгровка в радиусе 300 метров
local message = string.format("(Локально) [%s] *%s*", ply:GetName(), action)
for _, player in ipairs(players) do
if player:GetPos():Distance(ply:GetPos()) <= 300 then
player:ChatPrint(message)
end
end
elseif command == "gdo" then
-- Глобальная отыгровка от третьего лица
local message = string.format("(Глобально) *%s* [%s]", action, ply:GetName())
for _, player in ipairs(players) do
player:ChatPrint(message)
end


elseif command == "ldo" then
-- Локальная отыгровка от третьего лица
local message = string.format("(Локально) *%s* [%s]", action, ply:GetName())
for _, player in ipairs(players) do
if player:GetPos():Distance(ply:GetPos()) <= 300 then
player:ChatPrint(message)
end
end
end
end
end

hook.Add("PlayerSay", "RolePlayCommands", handleRolePlayCommands)

----

As a result, the code shows that I can see three notifications at once, and the second player can see one and also see the line that I entered into the chat.

Example:

[Global] Ivan Vladimirov *action*
Ivan Vladimirov: /me *action*

Right example:

[Global] Ivan Vladimirov *action*

Nobody should see the second line (this one - Ivan Vladimirov: /me *action*), and I can’t set the correct variable because I don’t understand what variables EasyChat uses.