I was wondering if there is a way to actually use a radio broadcast system (like in GmodRP) but instead of it only playing soundfiles, make it actually create a voice system so that when you (the broadcaster) use your microphone it will be played to the people connected to your radio channel. I don't know if this is possible or not, but it would be amazing for things like rebel communication and what not (especially when there is a voice radius within the server.) ... If it is possible at all I'm assuming that it would do something along the lines of:
Using the radio channel system like in GmodRP. And making a voice radius of the broadcaster to infinite range, but it would only be heard by those who are connected to his channel via radio. Maybe in order to hear the broadcaster the player would have to be near the radio entity itself. And the only way the broadcaster can emit his voice into the radios would be by sitting in a chair or something... None the less I don't know how to do this and I'm requesting help!
[QUOTE=Diet Taco]be near the radio entity[/QUOTE]
... You want an entity, which streams voice-communication to players on the same team?
Dont think it's possible :/
If he just creates some variables for the players in the server who are on the channel x he can easily do it.
Take a look at the Chat Radius addon made by Sam V522:
[lua]VoiceRadiusConVar = CreateClientConVar( "max_vc_radius", 512, true, false );
local VC_Max_Radius = VoiceRadiusConVar:GetInt();
function ChatRadius()
EntsInRange = ents.FindInSphere() LocalPlayer:GetPos(), VC_Max_Radius )
for i = 0,#EntsInRange do
if EntsInRange[i]:GetClass() == "Player" then
if EntsInRange[i].IsMuted() then
EntsInRange[i]:SetMuted()
end
EntsInRange[i].InVCRadius = true
end
end
for i = 0,#player.GetAll() do
if player.GetByID(i).InVCRadius then
if player.GetByID(i).IsMuted() then
// Do nothing, because the player is already muted, DUH.
else
player.GetByID(i):SetMuted()
end
end
end
end
timer.Create( "VoiceChatRadius", 1.0, 0, ChatRadius)[/lua]
It seems the 2 primary things you want to look at are:
[b][url=http://wiki.garrysmod.com/?title=Player.SetMuted]Player.SetMuted[img]http://wiki.garrysmod.com/favicon.ico[/img][/url]
[url=http://wiki.garrysmod.com/?title=Player.IsMuted]Player.IsMuted[img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
Here's the basic idea how to do it.
[lua]hook.Add("PlayerCanHearPlayersVoice", "InsertNameHere", function( pListener, pTalker )
for k,v in pairs( ents.FindInSphere( pTalker:GetPos(), 128 ) ) do
if v:GetClass() == "sent_radio" and pListener.RadioChannel == pTalker.RadioChannel then
return true
end
end
return false
end )
[/lua]
Uses [b][url=wiki.garrysmod.com/?title=Gamemode.PlayerCanHearPlayersVoice]Gamemode.PlayerCanHearPlayersVoice [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
Oh snap, I never knew there was such a hook. However, yours is Serverside my idea is Clientside.
Clientside also means bypassable :v:
Wow, both very astonishing codes that I have never seen before. And I do believe they would work, problem is I now have to implement it within the gamemode that I'm using (Gmod RP - SVN Ver.) I'm assuming that it would have to be tied into the radiosystem.lua ... Though the first problem I see is that in the system I have (already set up) the broadcaster can name their channel whatever they want, so the code would have to recognize the channel name and who the owner of it is. Then after it recognizes that, I would need to set it up that everyone in radius of the radio entity would be able to hear the broadcaster's voice... Also the other problem, or bonus possibly, would be that the broadcaster can play .mp3's that emit from the radio entity. So this might make things a bit more complicated, but lets say I were to create a tab in the already existing radio station entity, that made it so that the broadcaster could choose when to Emit his voice, and when to just play mp3's... So What I have to work with is:
First I was curious about the init.lua within the gamemode. (This is not the entire init.lua it is actually from line 436-end)
[PHP]function GM:PlayerCanHearPlayersVoice( l, t )
for k, v in pairs( ents.FindInSphere( t:GetPos(), Configuration["talkrange"] ) ) do
if v == l then
return true
end
end
return false
end
function GM:EntityRemoved( ent )
GMRP.DeleteRadiostation( ent )
end
[/PHP]
Then I was also curious on how I could implement raBBish's code into this so that it would work. One file that I think may be very important is the radiosystem.lua that is within the gamemode (sorry for the length):
[PHP]Radio = {}
function Radio.RadioAllowed( ent )
if !ent:IsValid() then return false end
if ent.ID == "radio" then
return true
end
return false
end
function Radio.RadioStationAllowed( ent )
if !ent:IsValid() then return false end
if ent.ID != "radiostation" then return false end
return true
end
function Radio.PlaySound( ent, sound )
ent.TheSound = CreateSound( ent, sound )
ent.TheSound:Play()
end
function Radio.StopSound( ent )
if ent.TheSound != nil then
ent.TheSound:Stop()
ent.TheSound = nil
end
end
function Radio.CPStopSound( p )
local trace = {}
trace.start = p:EyePos()
trace.endpos = trace.start + p:GetAimVector() * 85
trace.filter = p
local tr = util.TraceLine(trace)
if !Radio.RadioStationAllowed( tr.Entity ) then return end
for k, v in pairs(ents.GetAll()) do
if tr.Entity.RadioStationName == v.RadioStation then
if v.TheSound != nil then
Radio.StopSound( v )
end
end
end
end
GMRP.command ( "radiostation_stop", Radio.CPStopSound )
function Radio.ChooseType( name, p )
if !p:isJob( "Radio Broadcaster" ) then
return tostring( name ).."_pirate"
end
return tostring( name )
end
function Radio.CreateRadiostation( p, c ,a )
local trace = {}
trace.start = p:EyePos()
trace.endpos = trace.start + p:GetAimVector() * 85
trace.filter = p
local tr = util.TraceLine(trace)
local ImplArgs = tostring( string.Implode( " ", a ) )
if tostring( ImplArgs ) == nil then return end
if string.find( ImplArgs, "'" ) then
ImplArgs = string.gsub( ImplArgs, "'", "" )
end
if table.HasValue( Radiostations, tostring( ImpArgs ) ) then
p:RedNotify("This radiostation already exists.")
return
end
if !tr.Entity.ChangedChanel then
if Radio.RadioStationAllowed( tr.Entity ) then
table.insert( Radiostations, Radio.ChooseType( tostring( ImplArgs ), p ) )
RunLuaAll( "table.insert( Radiostations, '"..Radio.ChooseType( tostring( ImplArgs ), p ).."' )")
tr.Entity.RadioStationName = Radio.ChooseType( tostring( ImplArgs ), p )
tr.Entity.ChangedChanel = true
end
end
end
GMRP.command ( "radiostation_create", Radio.CreateRadiostation )
function Radio.ChangeChanel( p, c, a )
local trace = {}
trace.start = p:EyePos()
trace.endpos = trace.start + p:GetAimVector() * 85
trace.filter = p
local tr = util.TraceLine(trace)
local ImplArgs = tostring( string.Implode( " ", a ) )
if tostring( ImplArgs ) == nil then return end
if !tr.Entity:IsValid() then return end
if tr.Entity.ID == "radio" then
if table.HasValue( Radiostations, tostring( ImplArgs ) ) then
Radio.StopSound( tr.Entity )
tr.Entity.RadioStation = tostring( ImplArgs )
tr.Entity:EmitSound( "ambient/levels/prison/radio_random"..math.random( 2, 9 )..".wav" )
tr.Entity:SetNWString( "radiostation", tostring( ImplArgs ) )
end
end
end
GMRP.command( "radio_changechanel", Radio.ChangeChanel )
function Radio.HasAntenna( ent )
local Constrained = constraint.GetAllConstrainedEntities( ent )
if ent.IDs != nil then
ent.IDs = nil
end
ent.IDs = {}
for _, v in pairs( Constrained ) do
if v.ID != nil then
table.insert( ent.IDs, v.ID ) --insert the ent.ID's
end
end
if table.HasValue( ent.IDs, "antenna" ) then
return true
end
return false
end
function Radio.TransmitSound( p, c, a )
local trace = {}
trace.start = p:EyePos()
trace.endpos = trace.start + p:GetAimVector() * 85
trace.filter = p
local tr = util.TraceLine(trace)
local ImplArgs = tostring( string.Implode( " ", a ) )
if !Radio.RadioStationAllowed( tr.Entity, p ) then return end
tr.Entity.Range = 3000
if Radio.HasAntenna(tr.Entity) then
tr.Entity.Range = 800000
else
tr.Entity.Range = 10000
end
for k, v in pairs( ents.FindInSphere( tr.Entity:GetPos(), tr.Entity.Range ) ) do
if Radio.RadioAllowed( v ) && tr.Entity.RadioStationName == v.RadioStation then
if v.TheSound != nil then
Radio.StopSound( v )
Radio.PlaySound( v, tostring( ImplArgs ) )
v.CurrentSound = tostring( ImplArgs )
else
Radio.PlaySound( v, tostring( ImplArgs ) )
v.CurrentSound = tostring( ImplArgs )
end
end
end
end
GMRP.command( "radiostation_sound", Radio.TransmitSound)
function GMRP.DeleteRadiostation( ent )
if ent.RadioStationName != nil then
for k, v in pairs( Radiostations ) do
if v == ent.RadioStationName then
table.remove( Radiostations, k )
RunLuaAll( "table.remove( Radiostations, "..k..")" )
end
end
end
end
[/PHP]
Also there is no file within the gamemode that initiates hooks... Or atleast I haven't seen any... Is this a problem??? (PS: If you want to just look at the gamemode itself, which might help give you guys a better picture as of to what we are dealing with here, just go here: [URL="http://www.facepunch.com/showthread.php?t=746852"]http://www.facepunch.com/showthread.php?t=746852[/URL] Specifically I am using the SVN: [url]http://gmodrp.googlecode.com/svn/trunk/[/url]
Easy on the white space, there buddy :o
Sorry, you need to Log In to post a reply to this thread.