[Help]: Radio system
#1

Hi,

I need a little help with my radio system. Is there a function I can use to
detect if an audio stream is playing ? I have the command /stopradio - This
can be used even when there is no audio stream playing. Anyone who can help me
will get a reputation point.

Kind regards,

Sean
Reply
#2

No, there's not a native function for it. Although, I imagine you could hook PlayAudioStreamForPlayer and set a variable to true and then hook StopAudioStreamForPlayer (I think that's the function name) to set that same variable to false. It's worth a shot!
Reply
#3

Thank you for the quick response. Could you walk me through on how to do that ? I tried
using a boolean value but that wasn't successful
Reply
#4

Just a variable with playerid array.

Код:
new Streaming[MAX_PLAYERS];

//When you use PlayAudioStreamForPlayer
Streaming[playerid/i/whatever you use in the scripting] = 1;
//When you use StopAudioStreamForPlayer
Streamer[playerid] = 0;
//When you want to detect if it's streaming something.
if(Streamer[playerid] == 1)
It seems basic for me, but I dunno if it's gonna work. You'll have to do that in all the PlayAudio and StopAudio used.
Reply
#5

What exactly do you need it for?
If it's for a player exiting a car you could use this:
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
        // If the player exits a vehicle
	if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER) 
	{
	    StopAudioStreamForPlayer(playerid); // Stop the audio stream
	}
	return 1;
}
Reply
#6

Thanks Stront, one reputation from me
Reply
#7

*Fixed. Thread can be locked.
Reply
#8

You're welcome bro, I hope it helped you.
Reply
#9

If your using this in a car, you should also store the string of the URL to the vehicleid, so when the player gets back in the vehicle, the audio plays again :P
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)