attach PlayAudioStream to a player?
#1

Is there a way to attach a audio stream to a player with a radius?

I.e
/sound 1
(Plays URL provided, attaches it to the player so if he/she is driving around others can here it within the range)
Reply
#2

https://sampforum.blast.hk/showthread.php?tid=331533
You should check this. This include allows you to attach an audio stream to an object. Now you only need to create an object and attaching that to the player, so it will be streaming the music around you for those who are in the range. Didn't tested it.
Reply
#3

The solution above is good, but to do it yourself, basically:

- Keep constant track of the position of the players who have ongoing streams.
- Have a player variable ("Listening") for everyone which contains either the ID of the player who's stream they're near of, or INVALID_PLAYER_ID if none.
- Constantly (1 second timer perhaps) check for wether each individual player is near a player with a stream, and act accordingly:

1. If a player has their "Listening" variable as INVALID_PLAYER_ID and is near no stream, do nothing.
2. If a player has their "Listening" variable as INVALID_PLAYER_ID and is near a stream, assign that variable to the nearby player and start the stream.
3. If a player has their "Listening" variable the same as the nearby player who is streaming, do nothing.
4. If a player has their "Listening" variable as a player but now there's nothing near, stop the stream and set their "Listening" back to INVALID_PLAYER_ID.
5. Finally, if a player has their "Listening" variable as a player, but is now closer to another player with a stream, stop the previous stream, start the new one, and update the "Listening" variable.

Sounds complicated, but I reckon this solution can be factored in such a way that it'd take a meaningless amount of time to run.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)