Hey there,
I'm looking to make this chat only view-able by the team that is listed as "emergencyTeams". The code works, however, everyone can view it, which I don't want. If anyone could point me in the right direction I would be very thankful.
function EmergencyRadio(ply, args)
local emergencyTeams = {
TEAM_METCONTROL,
TEAM_ERT,
TEAM_RTPC,
TEAM_SCO19,
TEAM_DETECTIVE,
TEAM_PARAMEDIC,
TEAM_FIREFIGHTER
}
if(table.HasValue(emergencyTeams, ply:Team())) then
if args == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return ""
end
local DoSay = function(text)
if text == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return
end
for k,v in pairs(player.GetAll()) do
local col = team.GetColor(ply:Team())
DarkRP.talkToPerson(v, col, ply:Nick() .. " [Government Radio]", Color(7, 163, 175, 255), text, ply)
end
end
return args, DoSay
else
DarkRP.notify( ply, 1, 5, "You are not in a service job, therefore, cannot use the radio." )
end
end
DarkRP.defineChatCommand("gov", EmergencyRadio, 1.5)
DarkRP.defineChatCommand("radio", EmergencyRadio, 1.5)
In your player loop you never actually checked that the player’s job was in your job table.
ok, can you advise me then on how to make it work so that only "emergencyTeams" can view the text chat.
When you send the chat in the loop,check if the player you want to send it to is member of a emergency Team
Thanks for the response. I understand what you are saying, however, I don't understand putting that into practice. I've tried to specify the loop but it's not working. Could you help me out.
Just put an if check inside of the loop. You already done one further above to check the emergency team.
Alright, well I added another one before DarkRP.talkToPerson, however, it still doesn't work.
function EmergencyRadio(ply, args)
local emergencyTeams = {
TEAM_METCONTROL,
TEAM_ERT,
TEAM_RTPC,
TEAM_SCO19,
TEAM_DETECTIVE,
TEAM_PARAMEDIC,
TEAM_FIREFIGHTER
}
if(table.HasValue(emergencyTeams, ply:Team())) then
if args == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return ""
end
local DoSay = function(text)
if text == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return
end
for k,v in pairs(player.GetAll()) do
local col = team.GetColor(ply:Team())
if(table.HasValue(emergencyTeams, ply:Team())) then
DarkRP.talkToPerson(v, col, ply:Nick() .. " [Government Radio]", Color(7, 163, 175, 255), text, ply)
end
end
end
return args, DoSay
else
DarkRP.notify( ply, 1, 5, "You are not in a service job, therefore, cannot use the radio." )
end
end
DarkRP.defineChatCommand("gov", EmergencyRadio, 1.5)
DarkRP.defineChatCommand("radio", EmergencyRadio, 1.5)
void. I've fixed the issue. Cheers!
What was the issue if someone else also is having issues?
Guessing the issue was this in the loop?:
if(table.HasValue(emergencyTeams, ply:Team())) then
Fixed:
if(table.HasValue(emergencyTeams, v:Team())) then
Sorry, you need to Log In to post a reply to this thread.