Pivity

Making a group chat for different 'teams'

Last read Never
#1

So I have a sever up and coming.


I am wondering, with making sort of 'team' chats.



local function GroupMsg(ply, args)
if args == "" then return "" end
local DoSay = function(text)
if text == "" then return end
local t = ply:Team()
local audience = {}
 
if t == TEAM_POLICE or t == TEAM_CHIEF or t == TEAM_MAYOR then
for k, v in pairs(player.GetAll()) do
local vt = v:Team()
if vt == TEAM_POLICE or vt == TEAM_CHIEF or vt == TEAM_MAYOR then table.insert(audience, v) end
end
elseif t == TEAM_MOB or t == TEAM_GANG then
for k, v in pairs(player.GetAll()) do
local vt = v:Team()
if vt == TEAM_MOB or vt == TEAM_GANG then table.insert(audience, v) end
end
elseif t == TEAM_HOBO then
for k, v in pairs(player.GetAll()) do
local vt = v:Team()
if vt == TEAM_HOBO then table.insert(audience, v) end
end
end
 
for k, v in pairs(audience) do
local col = team.GetColor(ply:Team())
TalkToPerson(v, col, LANGUAGE.group..ply:Nick(),Color(255,255,255,255), text, ply)
end
end
return args, DoSay
end
AddChatCommand("/g", GroupMsg)


With that code for making normal team chats, am I right in saying you can make different chat commands and link them to each group in a way?

#2

Pretty much want a chat such as gangsters and thiefs could talk to eachother in secret with /crime hey and police and the mayor with /cp hey

#3

local function CRIME(ply, args)

    if args == "" then return "" end

    local DoSay = function(text)

        if text == "" then return end

        local t = ply:Team()

        local audience = {}


        if t == TEAM_ROBBER or t == TEAM_THIEF or t == TEAM_MAFIA or t == TEAM_GANGSTER then

            for k, v in pairs(player.GetAll()) do

                local vt = v:Team()

                if vt == TEAM_ROBBER or vt == TEAM_THIEF or vt == TEAM_MAFIA or vt == TEAM_GANGSTER then table.insert(audience, v) end

            end

end

        for k, v in pairs(audience) do

            local col = team.GetColor(ply:Team())

            TalkToPerson(v, col, LANGUAGE.group..ply:Nick(),Color(255,255,255,255), text, ply)

        end

    end

    return args, DoSay

end

AddChatCommand("/crime", CRIME)


is this how?

#4

Take a look at this example https://mtxserv.com/gmod-server/doc/how-to-add-ano-command and rewrite it, so it only prints to your desired team(s).

Friendly x 2
Users viewing this thread
Nobody