Audio stream problem.
#1

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;

Reply


Messages In This Thread
Audio stream problem. - by andrikela - 14.09.2017, 17:54
Re: Audio stream problem. - by Zeth - 14.09.2017, 18:07
Re: Audio stream problem. - by BadJih - 14.09.2017, 18:09
Re: Audio stream problem. - by andrikela - 14.09.2017, 18:38
Re: Audio stream problem. - by Threshold - 15.09.2017, 01:42
Re: Audio stream problem. - by andrikela - 15.09.2017, 09:46
Re: Audio stream problem. - by andrikela - 15.09.2017, 09:50
Re: Audio stream problem. - by Kane - 15.09.2017, 09:56
Re: Audio stream problem. - by andrikela - 15.09.2017, 10:11
Re: Audio stream problem. - by Kane - 15.09.2017, 10:16

Forum Jump:


Users browsing this thread: 2 Guest(s)