Posts: 246
Threads: 59
Joined: May 2014
Reputation:
0
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)
Posts: 133
Threads: 1
Joined: Apr 2015
Reputation:
0
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.