local teamName = "" -- إسم التيم
local key = "" -- الزر
addCommandHandler("TeamChat",
function (player, _, ...)
local msg = table.concat({...}, " ")
local pName = getPlayerName(player)
local team = getPlayerTeam(player)
if team and getTeamName(team) == teamName then
local r, g, b = getTeamColor(team)
for _, p in ipairs (getPlayersInTeam(team)) do
outputChatBox("("..teamName..") "..pName..": #FFFFFF"..msg, p, r, g, b, true)
end
else
if isKeyBound(player, key, "down", nothing) then
unbindKey(player, key, "down", "chatbox", "TeamChat")
unbindKey(player, key, "down", nothing)
end
end
end)
addEventHandler("onResourceStart", resourceRoot,
function()
for i, player in ipairs (getElementsByType("player")) do
local team = getPlayerTeam(player)
if team and getTeamName(team) == teamName then
bindKey(player, key, "down", "chatbox", "TeamChat")
bindKey(player, key, "down", nothing)
end
end
end)
addEventHandler("onPlayerSpawn", root,
function()
local team = getPlayerTeam(source)
if team and getTeamName(team) == teamName then
if not isKeyBound(source, key, "down", nothing) then
bindKey(source, key, "down", "chatbox", "TeamChat")
bindKey(source, key, "down", nothing)
end
else
if isKeyBound(source, key, "down", nothing) then
unbindKey(source, key, "down", "chatbox", "TeamChat")
unbindKey(source, key, "down", nothing)
end
end
end)
function nothing()
end