Boombox or PlayAudioStream
#1

Everytime when I typed /boombox, and clicked it which the response is below, I got crashed. Can anyone help me fix it to remove the crash?

pawn Код:
if(BoomboxPlaced[playerid] == 1)
                        {
                            for(new i = 0; i < MAX_PLAYERS; i++)
                            {
                                for(new BoomBoxItem = 0; BoomBoxItem < MAX_OBJECTS; BoomBoxItem++)
                                {
                                    new Float:X, Float:Y, Float:Z, Float:Distance = 15.0;
                                    GetDynamicObjectPos(BoomBoxItem, X, Y, Z);
                                    StopAudioStreamForPlayer(i);
                                    PlayAudioStreamForPlayer(i, "http://relay.181.fm:8018/", X, Y, Z, Distance, 1);
                                }
                            }
                        }
Reply
#2

what are you trying to do with this?
This plays the audio for all players*MAX_OBJECTS
for examble if MAX_OBJECTS is 50 , it plays the audio FOREACH player 50times o_O
Reply
#3

I wanted the audio to play on the location object instead of the player.
Reply
#4

try this
pawn Код:
if(BoomboxPlaced[playerid] == 1)
{
   new Float:X, Float:Y, Float:Z;
   GetDynamicObjectPos(BoomBoxItem, X, Y, Z);

   for(new i = 0; i < MAX_PLAYERS; i++)
   {
       PlayAudioStreamForPlayer(i, "http://relay.181.fm:8018/", X, Y, Z, 15.0, 1);
   }
}
Reply
#5

undefined symbol Boomboxitem :/
Reply
#6

Quote:
Originally Posted by Malcor
Посмотреть сообщение
location object instead of the player.
Show the line of CreateObject(.............) , for the object that you want to play audio near it
Reply
#7

pawn Код:
case 0:
                    {
                        if(BoomboxPlaced[playerid] == 1)
                        {
                            new Float:X, Float:Y, Float:Z;
                            new BoomBoxItem;
                            GetDynamicObjectPos(BoomBoxItem, X, Y, Z);
                            for(new i = 0; i < MAX_PLAYERS; i++)
                            {
                                StopAudioStreamForPlayer(i);
                                PlayAudioStreamForPlayer(i, "http://relay.181.fm:8018/", X, Y, Z, 15.0, 1);
                            }
                        }
                        else
                        {
                            for(new i = 0; i < MAX_PLAYERS; i++)
                            {
                                new Float:X, Float:Y, Float:Z, Float:Distance = 15.0;
                                GetPlayerPos(playerid, X, Y, Z);
                                for(new BoomBoxItem = 0; BoomBoxItem < MAX_OBJECTS; BoomBoxItem++)
                                {
                                    if(IsValidObject(BoomBoxItem)) DestroyDynamicObject(BoomBoxItem);
                                }
                                new BoomBoxItem;
                                BoomBoxItem = CreateDynamicObject(2226, X, Y, Z-0.9, 0, 0, 3.9700012207031);
                                BoomboxPlaced[playerid] = 1;
                                StopAudioStreamForPlayer(i);
                                PlayAudioStreamForPlayer(i, "http://relay.181.fm:8018/", X, Y, Z, Distance, 1);
                            }
                        }
                    }
Reply
#8

I want player to spawn their own ID of boombox, but this one seems weird.., sometimes the object itself doesn't show up,

this is the pwn when no song is chosen(despawn object)
pawn Код:
new Float:X, Float:Y, Float:Z, Float:Distance = 15.0;
                        for(new BoomBoxItem = 0; BoomBoxItem < MAX_OBJECTS; BoomBoxItem++)
                        {
                            if(IsValidObject(BoomBoxItem)) DestroyDynamicObject(BoomBoxItem);
                        }
                        for(new i = 0; i < MAX_PLAYERS; i++)
                        {
                            for(new BoomBoxItem = 0; BoomBoxItem < MAX_OBJECTS; BoomBoxItem++)
                            {

                                GetDynamicObjectPos(BoomBoxItem, X, Y, Z);
                            }
                            if(IsPlayerInRangeOfPoint(i, X, Y, Z, Distance))
                            {
                                StopAudioStreamForPlayer(i);
                            }
                         }
                        BoomboxPlaced[playerid] = 0;
                        StopAudioStreamForPlayer(playerid);
Reply
#9

something like this might work, you would have to make it similar. or give more codes instead of pieces.

pawn Код:
new boombox[MAX_PLAYERS]; // store the id of the object,
public OnPlayerConnect(playerid)
{
    boombox = createdynamicobject(....); // creates the object for each player
}
public OnPlayerDisconnect(playerid,reason)
{
   DestroyDynamicObject(boombox[playerid]); // destroy when the player leaves.
}

// this one.. you put into the code... will get the pos of the object of the playerd and stop the audio for everyone who is near to the object
new Float:X,Float:Y,Float:Z;
    GetDynamicObjectPos(boombox[playerid], X, Y, Z);
    for(new i; i < MAX_PLAYERS; ++i)
    {
       if(!IsPlayerConnected(i)) continue;
       if(IsPlayerInRangeOfPoint(i,radius, X, Y, Z)) // put the radius..
       {
          StopAudioStreamForPlayer(i);
       }
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)