Boombox or PlayAudioStream -
Malcor - 03.09.2012
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);
}
}
}
Re: Boombox or PlayAudioStream - HuSs3n - 03.09.2012
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
Re: Boombox or PlayAudioStream -
Malcor - 03.09.2012
I wanted the audio to play on the location object instead of the player.
Re: Boombox or PlayAudioStream - HuSs3n - 03.09.2012
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);
}
}
Re: Boombox or PlayAudioStream -
Malcor - 03.09.2012
undefined symbol Boomboxitem :/
Re: Boombox or PlayAudioStream - HuSs3n - 03.09.2012
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
Re: Boombox or PlayAudioStream -
Malcor - 05.09.2012
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);
}
}
}
Re: Boombox or PlayAudioStream -
Malcor - 05.09.2012
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);
Re: Boombox or PlayAudioStream -
leonardo1434 - 05.09.2012
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);
}
}