SA-MP Forums Archive
Audio stream problem. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Audio stream problem. (/showthread.php?tid=641345)



Audio stream problem. - andrikela - 14.09.2017

Hi, I have this filterscript.
It must play stream put in /speaker command. For example /speaker http://site.com/music.mp3
Problem is that it doesn't stream music for any player around.
What's fault is this?

PHP код:
#define FILTERSCRIPT
// Incl
#include <a_samp>
#include <streamer>
#include <foreach>
#include <zcmd>
#include <sscanf2>
// Defs
#define COLOR_WHITE 0xFFFFFFFF
#define COLOR_RED 0xFF0000FF
#define COLOR_LIGHTBLUE 0x33CCFFFF
#define COLOR_GREY 0xAFAFAFFF
public OnPlayerConnect(playerid)
{
    
DeletePVar(playerid"BoomboxObject"); DeletePVar(playerid"BoomboxURL");
    
DeletePVar(playerid"bposX"); DeletePVar(playerid"bposY"); DeletePVar(playerid"bposZ"); DeletePVar(playerid"bboxareaid");
    
DeletePVar(playerid"author");
    if(
IsValidDynamicObject(GetPVarInt(playerid"BoomboxObject"))) DestroyDynamicObject(GetPVarInt(playerid"BoomboxObject"));
    return 
1;
}
public 
OnPlayerDisconnect(playerid)
{
    if(
GetPVarType(playerid"BoomboxObject"))
    {
        
DestroyDynamicObject(GetPVarInt(playerid"BoomboxObject"));
        
DestroyDynamic3DTextLabel(Text3D:GetPVarInt(playerid"author"));
        if(
GetPVarType(playerid"bboxareaid"))
        {
               foreach(new 
Player)
            {
                if(
IsPlayerInDynamicArea(iGetPVarInt(playerid"bboxareaid")))
                {
                    
StopAudioStreamForPlayer(i);
                }
            }
        }
    }
    return 
1;
}
CMD:speaker(playeridparams[])
{
    new 
name[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnamesizeof(name));
    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playeridCOLOR_RED"[GrandProject] Для доступа к данной команде нужен клиренс RCON уровня.");
    new 
string[128];
    if(!
GetPVarType(playerid"BoomboxObject"))
    {
        if(
sscanf(params"s[256]"params)) return SendClientMessage(playeridCOLOR_RED"[SH-SS][Помощь]: /speaker [URL]");
        foreach(new 
Player)
        {
            if(
GetPVarType(i"BoomboxObject"))
            {
                if(
IsPlayerInRangeOfPoint(playerid40.0GetPVarFloat(i"bposX"), GetPVarFloat(i"bposY"), GetPVarFloat(i"bposZ")))
                {
                    
SendClientMessage(playeridCOLOR_GREY"[SH-SS] Рядом где-то уже есть спикер. Поставьте где-нибудь в другом месте.");
                    return 
1;
                }
            }
        }
        new 
Float:xFloat:yFloat:zFloat:a;
        
GetPlayerPos(playeridxyz); GetPlayerFacingAngle(playerida);
        
SetPVarInt(playerid"BoomboxObject"CreateDynamicObject(2103xyz0.00.00.0, .worldid GetPlayerVirtualWorld(playerid), .interiorid GetPlayerInterior(playerid)));
           
format(stringsizeof(string), "{FFFFFF}[SH-SS] Колонку поставил\n{FF0000}куратор %s"name);
        
SetPVarInt(playerid"author"_:CreateDynamic3DTextLabel(string0xFFFFFFFFxy1.020INVALID_PLAYER_IDINVALID_VEHICLE_ID0, .worldid GetPlayerVirtualWorld(playerid), .interiorid GetPlayerInterior(playerid)));
        
SetPVarFloat(playerid"bposX"x); SetPVarFloat(playerid"bposY"y); SetPVarFloat(playerid"bposZ"z);
        
SetPVarInt(playerid"bboxareaid"CreateDynamicSphere(xyz40.0GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid)));
        
format(stringsizeof(string), "[SH-SS] Колонка выставлена на вашей позиции.");
        
SendClientMessage(playeridCOLOR_LIGHTBLUEstring);
        foreach(new 
Player)
        {
            if(
IsPlayerInDynamicArea(iGetPVarInt(playerid"bboxareaid")))
            {
                
PlayAudioStreamForPlayer(iparamsGetPVarFloat(playerid"bposX"), GetPVarFloat(playerid"bposY"), GetPVarFloat(playerid"bposZ"), 30.01);
            }
        }
        
SetPVarString(playerid"BoomboxURL"params);
    }
    else
    {
        
DestroyDynamicObject(GetPVarInt(playerid"BoomboxObject"));
        
DestroyDynamic3DTextLabel(Text3D:GetPVarInt(playerid"author"));
        
DeletePVar(playerid"BoomboxObject"); DeletePVar(playerid"BoomboxURL");
        
DeletePVar(playerid"bposX"); DeletePVar(playerid"bposY"); DeletePVar(playerid"bposZ");
        if(
GetPVarType(playerid"bboxareaid"))
        {
            foreach(new 
Player)
            {
                if(
IsPlayerInDynamicArea(iGetPVarInt(playerid"bboxareaid")))
                {
                    
StopAudioStreamForPlayer(i);
                }
            }
            
DeletePVar(playerid"bboxareaid");
        }
        
SendClientMessage(playeridCOLOR_LIGHTBLUE"[SH-SS] Спикер убран.");
    }
    return 
1;
}
CMD:setmusic(playeridparams[])
{
    new 
name[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnamesizeof(name));
    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playeridCOLOR_RED"[GrandProject] Для доступа к данной команде нужен клиренс RCON уровня.");
    if(!
GetPVarType(playerid"BoomboxObject")) return SendClientMessage(playeridCOLOR_GREY"[SH-SS] У Вас нет спикера.");
    if(
sscanf(params"s[256]"params)) return SendClientMessage(playeridCOLOR_WHITE"[SH-SS][Помощь]: /setmusic [URL]");
    
SendClientMessage(playeridCOLOR_GREY"[SH-SS] Музыка успешно изменена.");
    foreach(new 
Player)
    {
        if(
IsPlayerInDynamicArea(iGetPVarInt(playerid"bboxareaid")))
        {
            
PlayAudioStreamForPlayer(iparamsGetPVarFloat(playerid"bposX"), GetPVarFloat(playerid"bposY"), GetPVarFloat(playerid"bposZ"), 30.01);
        }
    }
    
SetPVarString(playerid"BoomboxURL"params);
    return 
1;
}
public 
OnPlayerEnterDynamicArea(playeridareaid)
{
    foreach(new 
Player)
    {
        if(
GetPVarType(i"bboxareaid"))
        {
            new 
station[256];
            
GetPVarString(i"BoomboxURL"stationsizeof(station));
            if(
areaid == GetPVarInt(i"bboxareaid"))
            {
                
PlayAudioStreamForPlayer(playeridstationGetPVarFloat(i"bposX"), GetPVarFloat(i"bposY"), GetPVarFloat(i"bposZ"), 30.01);
                return 
1;
            }
        }
    }
    return 
1;
}
public 
OnPlayerLeaveDynamicArea(playeridareaid)
{
    foreach(new 
Player)
    {
        if(
GetPVarType(i"bboxareaid"))
        {
            if(
areaid == GetPVarInt(i"bboxareaid"))
            {
                
StopAudioStreamForPlayer(playerid);
                return 
1;
            }
        }
    }
    return 
1;




Re: Audio stream problem. - Zeth - 14.09.2017

To get audio streamed from a URL, you need to add #include <a_http> at the top your script.


Re: Audio stream problem. - BadJih - 14.09.2017

you need the a_http.inc


Re: Audio stream problem. - andrikela - 14.09.2017

Quote:
Originally Posted by Debjit
Посмотреть сообщение
To get audio streamed from a URL, you need to add #include <a_http> at the top your script.
Quote:
Originally Posted by BadJih
Посмотреть сообщение
you need the a_http.inc
Added it, but no result. Still won't work.


Re: Audio stream problem. - Threshold - 15.09.2017

Quote:
Originally Posted by Debjit
Посмотреть сообщение
To get audio streamed from a URL, you need to add #include <a_http> at the top your script.
No you don't...

Quote:
Originally Posted by BadJih
you need the a_http.inc
Oh please, go jump on another bandwagon and increase your post count somewhere else.

With PlayAudioStreamForPlayer, you can stream the audio at a set location (coordinates) or you can simply stream directly to the player. Seeing as you're getting the player's position and then streaming to those coordinates, I can only assume that you're trying to create a direct stream to the player's client. In this case, you don't need to use the coordinate parameters of PlayAudioStreamForPlayer.

Simply change:
PHP код:
PlayAudioStreamForPlayer(iparamsGetPVarFloat(playerid"bposX"), GetPVarFloat(playerid"bposY"), GetPVarFloat(playerid"bposZ"), 30.01); 
To:
PHP код:
PlayAudioStreamForPlayer(iparams); 
If that doesn't change anything, then you need to make sure that you are actually passing all your 'if' statements, and do some debugging to see what is getting called and what isn't.


Re: Audio stream problem. - andrikela - 15.09.2017

Quote:
Originally Posted by Threshold
Посмотреть сообщение
With PlayAudioStreamForPlayer, you can stream the audio at a set location (coordinates) or you can simply stream directly to the player. Seeing as you're getting the player's position and then streaming to those coordinates, I can only assume that you're trying to create a direct stream to the player's client. In this case, you don't need to use the coordinate parameters of PlayAudioStreamForPlayer.

Simply change:
PHP код:
PlayAudioStreamForPlayer(iparamsGetPVarFloat(playerid"bposX"), GetPVarFloat(playerid"bposY"), GetPVarFloat(playerid"bposZ"), 30.01); 
To:
PHP код:
PlayAudioStreamForPlayer(iparams); 
If that doesn't change anything, then you need to make sure that you are actually passing all your 'if' statements, and do some debugging to see what is getting called and what isn't.
I want to make it like this:
There's an object and sound is coming smoothly out from it with 30.0 distance and every player around hear it, but when moving away from object, music starts to go away and then stream stops (OnPlayerLeaveDynamicArea). If player again goes in the dynamic sphere, stream starts for him at place of the object. (OnPlayerEnterDynamicArea). I'm passing all 'if' statements and the music should play if we thing logically. But I don't know why it does not.


Re: Audio stream problem. - andrikela - 15.09.2017

Even removing positions didn't help. Object spawns, 3D text is at it's place, everything is ok. But no sound. Just no sound at all, be it .mp3 link or radio stream.


Re: Audio stream problem. - Kane - 15.09.2017

Stupid question but it's possible. Is your radio sound ON?


Re: Audio stream problem. - andrikela - 15.09.2017

Quote:
Originally Posted by Arthur Kane
Посмотреть сообщение
Stupid question but it's possible. Is your radio sound ON?
Yes, it is maxed out.


Re: Audio stream problem. - Kane - 15.09.2017

Does it work when you first /speaker or is the issue just with entering the area?