SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 26/01/2020, 08:50 PM   #1
ShiffeyTheGamer
Huge Clucker
 
ShiffeyTheGamer's Avatar
 
Join Date: May 2014
Posts: 246
Reputation: 25
Default attach PlayAudioStream to a player?

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)
ShiffeyTheGamer is offline   Reply With Quote
Old 26/01/2020, 09:07 PM   #2
Davi52
Little Clucker
 
Join Date: Sep 2018
Posts: 40
Reputation: 0
Default Re: attach PlayAudioStream to a player?

https://forum.sa-mp.com/showthread.php?t=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.
Davi52 is offline   Reply With Quote
Old 26/01/2020, 09:32 PM   #3
Markski
Big Clucker
 
Markski's Avatar
 
Join Date: Apr 2015
Location: La Plata, Argentina
Posts: 133
Reputation: 59
Default Re: attach PlayAudioStream to a player?

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.
Markski is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
attach to player StR_MaRy Scripting Help 3 15/11/2016 12:28 PM
How do I attach a player object to a player? Dylan_Madigan69 Scripting Help 1 14/12/2013 03:17 AM
help me PlayAudioStream For all Player Smith_Jim Scripting Help 2 26/05/2013 04:56 AM
How To Attach object to Player to all player see? Azazelo Scripting Help 2 14/05/2012 08:03 AM
Attach a Player to.... Trooper[Y] Help Archive 12 23/04/2009 05:28 PM


All times are GMT. The time now is 05:47 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.