Help with playing audio stream
#1

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.
Reply
#2

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://sampwiki.blast.hk/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.
Reply
#3

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.
Reply
#4

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
Reply
#5

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?
Reply
#6

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://sampwiki.blast.hk/wiki/PlayerPlaySound
https://sampwiki.blast.hk/wiki/SoundID
Reply
#7

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!
Reply
#8

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)