1. This forum is ARCHIVED! Visit the new Cloud Sixteen forums, codename Eden, at https://eden.cloudsixteen.com. These forums will remain archived for a few months before being closed down, so try to encourage plugin developers to begin moving their content across to the new forums.
Dismiss Notice
Hi Guest, you need a Steam account to register and post on these forums. Login with Steam at the top of the forums to get started!
Dismiss Notice
Hi Guest, do you want to buy HL2RP or another Clockwork schema? Visit the Cloud Sixteen Store to get started!

Ambient Radio Sounds

Discussion in 'Discussion' started by 003390501570513, Jan 4, 2013.

  1. Razor

    Razor Guest

    Why not, it could be there without many problems.
    It's just that the way he put it is wrong :X
     
  2. Then, What's the problem?
     
  3. TJjokerR

    TJjokerR Formerly known as TJjokerR

    Look at your code:
    For every player the server thinks and your code hooks into it and creates a timer every think for every player. This means that 1.5sec after the first PlayerThink every player will spam that sound every PlayerThink.
     
  4. Ok, I removed the timer and I set the change to 1, but I still can't hearing sounds.
     
  5. Razor

    Razor Guest

    REmoving the timer is even worse, but meh.
    At least you can't hear sounds.
    Don't trust that code unless you know how to use it
     
  6. TJjokerR

    TJjokerR Formerly known as TJjokerR

    Haven't tested or looked over it, but it should work.

    Code:
    -- The interval between sounds in seconds.
    Clockwork.config:Add("ambient_radio_sound_interval", 5);
    
    -- The chance for a sound to play as a percentage between 0 and 1, where 0.5 would be 50%.
    Clockwork.config:Add("ambient_radio_sound_chance", .5);
    
    local radioSounds = {
    	"npc/combine_soldier/vo/prison_soldier_prosecuteD7",
    	"npc/combine_soldier/vo/prison_soldier_tohighpoints.wav",
    	"npc/combine_soldier/vo/prison_soldier_leader9dead.wav",
    	"npc/combine_soldier/vo/prison_soldier_negativecontainment.wav",
    	"npc/combine_soldier/vo/prison_soldier_sundown3dead.wav"
    };
    
    -- Called for every player, each think.
    function PLUGIN:PlayerThink(player, curTime, infoTable)
    	if( Schema:PlayerIsCombine(player) and (not player._nextRadioAmbient or player._nextRadioAmbient < CurTime()) )then
    		local chance = math.random() < Clockwork.config:Get("ambient_radio_sound_chance"):Get();
    		
    		if( chance )then
    			player:EmitSound(table.Random(radioSounds));
    		end;
    		
    		player._nextRadioAmbient = CurTime() + Clockwork.config:Get("ambient_radio_sound_interval"):Get();
    	end;
    end;
     
  7. It doesn't work!
     
  8. TJjokerR

    TJjokerR Formerly known as TJjokerR

    I can't help you if you don't tell me what error occurs. If none occurs, where are you putting it? Are you sure your plugin has the right format?
     
  9. I tried it in sv_hooks.lua and in sv_plugin.lua. And yes, I think that the plugin files are right. Does it work for you?
     
  10. TJjokerR

    TJjokerR Formerly known as TJjokerR

Previous Readers (Total: 0)