SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 27/06/2020, 09:16 PM   #1
Inspiron
Huge Clucker
 
Inspiron's Avatar
 
Join Date: Jul 2013
Location: Mount Chiliad
Posts: 233
Reputation: 18
Default Help with playing audio stream

So guys, I'm trying to create a party room for players. I've looked on the internet and found the function PlayAudioStreamForPlayer. However, I couldn't find a solution on how to play it in a specific area. I've managed to play it in a specific area with a command. But how do I keep it constant, that whenever a player is near or inside the room, the music starts playing for him. I don't really want it to be an online stream, I'm ok with in game music too such as music in alhambra. Is there a solution for this? My party room isn't an interior. Its in the san andreas world and there's a simple door to pass it without using an interior.
__________________

Website | Discord
Inspiron is offline   Reply With Quote
Old 27/06/2020, 09:31 PM   #2
Kwarde
High-roller
 
Kwarde's Avatar
 
Join Date: Nov 2009
Location: The Netherlands
Posts: 2,735
Reputation: 1686
Default Re: Help with playing audio stream

Well, when they enter the room (you could use OnPlayerUpdate() to check if they entered a specific area, or use includes that do this (OnPlayerEnter/ExitArea) -streamer has this -or do it when they enter a room in a specific function (such as entering a house -where the code is that puts the player in the house [for example]), use PlayAudioStreamForPlayer().
https://wiki.sa-mp.com/wiki/PlayAudioStreamForPlayer

As stated on the wiki, parameters:
Code:
playerid	The ID of the player to play the audio for.
url[]	        The url to play. Valid formats are mp3 and ogg/vorbis. A link to a .pls (playlist) file will play that playlist.
Float:PosX	The X position at which to play the audio. Default 0.0. Has no effect unless usepos is set to 1.
Float:PosY	The Y position at which to play the audio. Default 0.0. Has no effect unless usepos is set to 1.
Float:PosZ	The Z position at which to play the audio. Default 0.0. Has no effect unless usepos is set to 1.
Float:distance	The distance over which the audio will be heard. Has no effect unless usepos is set to 1.
usepos	        Use the positions and distance specified. Default disabled (0).
If you wish to look for a way to play the audio for players who enter after it started playing, you can't. PlayAudioStreamForPlayer() is per-player. When you play the sound in a specific area, it must be used for all players in that area, and players who enter it after you started playing some music, you must use it for too.
__________________
When the opportunity presents itself to flip-a da table, uh, you flip-a da table.

Discord: Kwarde#8009
Kwarde is offline   Reply With Quote
Old 28/06/2020, 11:48 AM   #3
Inspiron
Huge Clucker
 
Inspiron's Avatar
 
Join Date: Jul 2013
Location: Mount Chiliad
Posts: 233
Reputation: 18
Default Re: Help with playing audio stream

pawn Code:
forward OnPlayerEnterDynamicArea(playerid, areaid);
forward OnPlayerLeaveDynamicArea(playerid, areaid);

public OnGameModeInit()
{
new partyy;
    partyy = CreateDynamicRectangle(-2091.6467,1430.2505,7.1459, -2089.4465,1431.5364,7.1459, -2064.9319,1387.5784,7.1459, -2064.6858,1385.8391,7.1459, -1, -1, -1);
    return 1;
}




public OnPlayerEnterDynamicArea(playerid, areaid)
{
if(areaid == partyy)
    {
      PlayAudioStreamForPlayer(playerid, "http://uhfgaming.net/music/Cut%20Off%20-%20Escuro%20(Original%20Mix).mp3", -2078.4548, 1410.1182, 7.1803, 5, 1);
      ResetPlayerWeapons(playerid);
      }
      return 1;
}

public OnPlayerLeaveDynamicArea(playerid, areaid)
{
     if(areaid == partyy)
    {
       StopAudioStreamForPlayer(playerid);
    }
    return 1;
}

Gives out the following warnings:
Code:
warning 213: tag mismatch
warning 202: number of arguments does not match definition
warning 204: symbol is assigned a value that is never used: "partyy"
All these warnings are from same line number 452 which is the line where I created the DynamicRectangle. Also, there is no audio stream when I enter the area.
__________________

Website | Discord
Inspiron is offline   Reply With Quote
Old 28/06/2020, 11:55 AM   #4
Kwarde
High-roller
 
Kwarde's Avatar
 
Join Date: Nov 2009
Location: The Netherlands
Posts: 2,735
Reputation: 1686
Default Re: Help with playing audio stream

1) partyy must be a global variable
2) the function Create..Rectangle has 7 parameters
Code:
CreateDynamicRectangle(Float:minx, Float:miny, Float:maxx, Float:maxy, worldid = -1, interiorid = -1, playerid = -1)
yours has 15 parameters (hence the number of arguments does not match definition, and the tag mismatch (as a floating number is used in a parameters that expects an integer):
Code:
CreateDynamicRectangle(-2091.6467,1430.2505,7.1459, -2089.4465,1431.5364,7.1459, -2064.9319,1387.5784,7.1459, -2064.6858,1385.8391,7.1459, -1, -1, -1);
3) Because partyy is not a global variable, the script thinks that that value is never used (hence the symbol is assigned a value that is never used warning)

I don't get why OnPlayerEnter/LeaveDynamicArea never showed errors though, since partyy is not a global variable. That should have given an "undefined symbol" error
__________________
When the opportunity presents itself to flip-a da table, uh, you flip-a da table.

Discord: Kwarde#8009
Kwarde is offline   Reply With Quote
Old 28/06/2020, 12:25 PM   #5
Inspiron
Huge Clucker
 
Inspiron's Avatar
 
Join Date: Jul 2013
Location: Mount Chiliad
Posts: 233
Reputation: 18
Default Re: Help with playing audio stream

Yes thank you. Fixed it. But is there any way to play sound for a player instead of a stream? Sounds of such as jizzy's or the club in idlewood. Within that area?
__________________

Website | Discord
Inspiron is offline   Reply With Quote
Old 28/06/2020, 12:41 PM   #6
GameOvr
Huge Clucker
 
GameOvr's Avatar
 
Join Date: Jun 2018
Posts: 296
Reputation: 9
Default Re: Help with playing audio stream

Quote:
Originally Posted by Inspiron View Post
Yes thank you. Fixed it. But is there any way to play sound for a player instead of a stream? Sounds of such as jizzy's or the club in idlewood. Within that area?
https://wiki.sa-mp.com/wiki/PlayerPlaySound
https://wiki.sa-mp.com/wiki/SoundID
__________________
GameOvr is offline   Reply With Quote
Old 28/06/2020, 01:14 PM   #7
Inspiron
Huge Clucker
 
Inspiron's Avatar
 
Join Date: Jul 2013
Location: Mount Chiliad
Posts: 233
Reputation: 18
Default Re: Help with playing audio stream

Yes I am aware of the PlayerPlaySound function. But I can't find the sound ids that are played in interior such as AlHambra Club. Is there anyway to get them?
EDIT: Found them under disco sounds. Thank you!
__________________

Website | Discord
Inspiron is offline   Reply With Quote
Old 28/06/2020, 01:26 PM   #8
GameOvr
Huge Clucker
 
GameOvr's Avatar
 
Join Date: Jun 2018
Posts: 296
Reputation: 9
Default Re: Help with playing audio stream

maybe this
"IDLEWOOD" - 2064

All the sound ids are there in the link. but you have to find the correct one! pretty much time consuming
__________________
GameOvr 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
Audio Stream Not Playing Xessive Scripting Help 3 17/10/2017 06:20 PM
Audio stream not playing? Stupid Scripting Help 5 30/05/2015 05:08 PM
Playing audio stream,based on url user enters Tagathron Scripting Help 5 04/11/2013 06:36 PM
Playing audio stream in interior! RavGaming Scripting Help 4 23/02/2013 09:28 PM
Playing audio stream works only for me! pasha97 Scripting Help 11 27/11/2012 03:44 PM


All times are GMT. The time now is 05:18 PM.


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