[Ayuda] PlayAudioStreamForPlayer
#1

Tengo un Problema con la radio de los autos en mi servidor, cuando uso el comando /radio sale un dialog con las emisoras que puede sintonizar, al darle click a la emisora, suena bien pero solo suena en el rango donde hice el comando y si me muevo de ese rango "13" se pierde el sonido.

Aqui esta el codigo:
PHP код:
if(listitem == 0)
{
    
StopAudioStreamForPlayer(playerid);
    
PlayerPlaySound(playerid,1056,0.0,0.0,0.0);
    new 
Float:XFloat:YFloat:ZFloat:Distance 13.0;
    
GetPlayerPos(playeridXYZ);
    
PlayAudioStreamForPlayer(playerid"http://188.165.229.150:10500/listen.pls"XYZDistance1);

y Si lo pongo sin los floats el sonido si se escucha al que esta en el auto y a donde se mueva.
PHP код:
if(listitem == 0)
{
    
StopAudioStreamForPlayer(playerid);
    
PlayerPlaySound(playerid,1056,0.0,0.0,0.0);            
    
PlayAudioStreamForPlayer(playerid"http://188.165.229.150:10500/listen.pls");

pero quiero hacer que el sonido se escuche alrededor del auto y que los que esten cerca del auto escuchen el sonido...
Reply
#2

Tenes que estar actualizando las coordenadas X, Y, Z cada ves que se mueva.
GetPlayerPos(playerid, X, Y, Z); en un timer o en onplayerupdate aunque no te lo recomiendo.
Reply
#3

ok gracias voy a probarlo , pero por que no lo recomiendas?
Reply
#4

Quote:
Originally Posted by Enrique_Henriquez
Посмотреть сообщение
ok gracias voy a probarlo , pero por que no lo recomiendas?
no se recomienda por ke al cargar de nuevo la posicion cargara de nuevo PlayAudioStreamForPlayer del comienzo y si te estas moviendo se haga flood de PlayAudioStreamForPlayer y se te lagueara todo
Reply
#5

mmm cierto , y no hay otra forma de hacerlo?
Reply
#6

Quote:
Originally Posted by Enrique_Henriquez
Посмотреть сообщение
mmm cierto , y no hay otra forma de hacerlo?
No, ya que no permite la opciуn de pausar la mъsica y depuйs continuarla por donde iba.

Es mejor usarla sin X,Y,Z. Para un solo user.

Saludos
Reply
#7

Bueno, gracias de todos modos
Reply
#8

encontre esto en un tutorial de PlayAudioStreamForPlayer:
PHP код:
public OnPlayerUpdate(playerid)
{
    if(
IsPlayerInRadioArea(playerid)) // or you can use If(IsPlayerInRangeOfPoint(playerid,range,X,Y,Z)
    
{
            if(!
GetPVarInt(playerid,"spawn")) // we are looking if there as variable with the name 'spawn' present , which we havent created yet
            
{
                
SetPVarInt(playerid,"spawn",1); // since there wasnt , we now create it so that the loop doesnt enter this again n again and create 'lag'
                
PlayAudioStreamForPlayer(playerid,"URL GOES HERE",X,Y,Z,range,1);
                
            }
    }
    else 
// player is not in point range
    
{
        if(
GetPVarInt(playerid,"spawn")) // since we create it before and played the stream , it will be there
        
{
            
DeletePVar(playerid,"spawn");// delete the variable so that next time player goes in range the radio can be started again
            
StopAudioStreamForPlayer(playerid); and stop stream
        
}
    }
    
    return 
1;

segun entiendo la variable spawn es para que no haga el flood que dice bytytus

PHP код:
stock IsPlayerInRadioArea(playerid)
{
    new 
Float:X,Float:Y,Float:Z;
    
GetPlayerPos(playerid,X,Y,Z);
    if(
MINX && MAXX && MINY && MAXY)
    {
        return 
1// if player is in that area , the stock will return 1 or true
    
}
    return 
0// if not then 0 or false

pero no he podido adaptarlo al FS donde tengo la radio, y en OnPlayerUpdate solo hay oportunidad para escuchar una sola emizora, a ver si me ayudan a adaptarlo para que pueda elegir una emisora y que actuen estos codigos.
aqui esta el link del tutorial: https://sampforum.blast.hk/showthread.php?tid=332729
Reply
#9

Quote:
Originally Posted by Enrique_Henriquez
Посмотреть сообщение
encontre esto en un tutorial de PlayAudioStreamForPlayer:
PHP код:
public OnPlayerUpdate(playerid)
{
    if(
IsPlayerInRadioArea(playerid)) // or you can use If(IsPlayerInRangeOfPoint(playerid,range,X,Y,Z)
    
{
            if(!
GetPVarInt(playerid,"spawn")) // we are looking if there as variable with the name 'spawn' present , which we havent created yet
            
{
                
SetPVarInt(playerid,"spawn",1); // since there wasnt , we now create it so that the loop doesnt enter this again n again and create 'lag'
                
PlayAudioStreamForPlayer(playerid,"URL GOES HERE",X,Y,Z,range,1);
                
            }
    }
    else 
// player is not in point range
    
{
        if(
GetPVarInt(playerid,"spawn")) // since we create it before and played the stream , it will be there
        
{
            
DeletePVar(playerid,"spawn");// delete the variable so that next time player goes in range the radio can be started again
            
StopAudioStreamForPlayer(playerid); and stop stream
        
}
    }
    
    return 
1;

segun entiendo la variable spawn es para que no haga el flood que dice bytytus

PHP код:
stock IsPlayerInRadioArea(playerid)
{
    new 
Float:X,Float:Y,Float:Z;
    
GetPlayerPos(playerid,X,Y,Z);
    if(
MINX && MAXX && MINY && MAXY)
    {
        return 
1// if player is in that area , the stock will return 1 or true
    
}
    return 
0// if not then 0 or false

pero no he podido adaptarlo al FS donde tengo la radio, y en OnPlayerUpdate solo hay oportunidad para escuchar una sola emizora, a ver si me ayudan a adaptarlo para que pueda elegir una emisora y que actuen estos codigos.
aqui esta el link del tutorial: https://sampforum.blast.hk/showthread.php?tid=332729
en vez de OnPlayerUpdate colocarlo en un timer y haz un bucle con GetMaxPlayers
Reply
#10

Quote:
Originally Posted by bytytus
Посмотреть сообщение
en vez de OnPlayerUpdate colocarlo en un timer y haz un bucle con GetMaxPlayers
bueno hice el timer y creo que hice bien lo del GetMaxPlayers:
PHP код:
stock IsPlayerInRadioArea(playerid)//Float:minx, Float:maxx, Float:miny, Float:maxy
{
    new 
Float:X,Float:Y,Float:Z;
    
GetPlayerPos(playerid,X,Y,Z);
    if(
minx && maxx && miny && maxy)
    {
        return 
1// if player is in that area , the stock will return 1 or true
    
}
    return 
0// if not then 0 or false
}
//============================================
//========================================
forward Radio(playerid);
public 
Radio(playerid)
{
    
//new Float:X, Float:Y, Float:Z, Float:Distance = 20.0;
    //GetPlayerPos(playerid, X, Y, Z);
    
for(new i<GetMaxPlayers(); i++)
    if(
IsPlayerInRadioArea(playerid)) // or you can use If(IsPlayerInRangeOfPoint(playerid,range,X,Y,Z) Float:minx, Float:maxx, Float:miny, Float:maxy
    
{
            if(!
GetPVarInt(playerid,"spawn")) // we are looking if there as variable with the name 'spawn' present , which we havent created yet
            
{
                
SetPVarInt(playerid,"spawn",1); // since there wasnt , we now create it so that the loop doesnt enter this again n again and create 'lag'
                   //PlayAudioStreamForPlayer(playerid,"http://5133.live.streamtheworld.com/LOS40_COLUMBIA_SC",X,Y,Z,20,1);
            
}
    }
    else 
// player is not in point range
    
{
        if(
GetPVarInt(playerid,"spawn")) // since we create it before and played the stream , it will be there
        
{
            
DeletePVar(playerid,"spawn");// delete the variable so that next time player goes in range the radio can be started again
            
StopAudioStreamForPlayer(playerid);
        }
    }
    return 
1;

Pero ahora me sale este error al compilar:
Код:
C:\Users\user\Desktop\gta\filterscripts\xD.pwn(611) : error 017: undefined symbol "minx"
y esta es la linea 611:
PHP код:
stock IsPlayerInRadioArea(playerid)//Float:minx, Float:maxx, Float:miny, Float:maxy 
pero si le pongo los float de min y max junto con el playerid , asi:
PHP код:
stock IsPlayerInRadioArea(playerid,Float:minxFloat:maxxFloat:minyFloat:maxy
me aparece este error:
Код:
C:\Users\user\Desktop\gta\filterscripts\xD.pwn(625) : error 017: undefined symbol "minx"
y la linea 625:
PHP код:
if(IsPlayerInRadioArea(playeridFloat:minxFloat:maxxFloat:minyFloat:maxy)) 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)