PlayAudioStreamForAll
#1

Hello everyone,
I found a basic function of 'PlayAudioStreamForAll' and I want to combine it with a dialog.
I tried to put the script in 'DialogResponse' public but when i compile I got an error that i don't understand...

PHP код:
stock PlayAudioStreamForAll(url[])
{
    for(new 
ii<GetMaxPlayers(); i++)
    {
        if(
IsPlayerConnected))
        {
            
PlayAudioStreamForPlayer(iurlxyzdistance);
        }
    }
    return 
1;
   
}
    if(
dialogid == DIALOG_MUSIC)
    {
        if(
response)
        {
            
PlayAudioStreamForPlayer(iurlxyzdistance); 
error 017: undefined symbol "i"
Reply
#2

The i is not a global variable, therefore you will have to store it's value into a global variable and use the global variable on the dialog response.

Or just use a new for loop inside the dialog response before the PlayAuidoSteamForPlayer.


EDIT: Change the PlayAuidoStreamForPlayer to PlayAudioStreamForAll at the dialog response?
Reply
#3

Change "i" to player id on that last line.... also I don't recommend playing the audio stream for all players you should have a command so that players can ignore the request. Even with the radio off this function can cause some players FPS lag for some reason.
Reply
#4

All you have to do, is change
pawn Код:
if(dialogid == DIALOG_MUSIC)
    {
        if(response)
        {
            PlayAudioStreamForPlayer(i, url, x, y, z, distance);
to
pawn Код:
if(dialogid == DIALOG_MUSIC)
    {
        if(response)
        {
            PlayAudioStreamForAll(url);
The stock needs to be anywhere outside any callback.
Don't forget to change url to "link here with the quotes, to let the script know you use a string"
Reply
#5

After i did that I got two another errors for the same reasons:

error 017: undefined symbol "x"
error 017: undefined symbol "url"


I'll repeat my explanation, When player opens DIALOG_MUSIC he asked to put a song's link inside of it and all the
people will hear it.

Quote:

Don't forget to change url to "link here with the quotes, to let the script know you use a string"

I want the player to choose any song he wants to play, not a specific one.
Reply
#6

I can't tell you a solution without your updated code!
Please post the code you have now.

If you want the player to choose a song, be sure to format the string with choices or the inputtext of the dialog.
Reply
#7

Quote:
Originally Posted by Jstylezzz
Посмотреть сообщение
I can't tell you a solution without your updated code!
Please post the code you have now.

If you want the player to choose a song, be sure to format the string with choices or the inputtext of the dialog.
PHP код:
stock PlayAudioStreamForAll(url[])
{
    for(new 
ii<GetMaxPlayers(); i++)
    {
        if(
IsPlayerConnected))
        {
            
PlayAudioStreamForPlayer(iurlxyzdistance);
        }
    }
    return 
1;
}
public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    if(
dialogid == DIALOG_MUSIC)
    {
        if(
response)
        {
            
PlayAudioStreamForAll(url);
        }
                return 
1;
    } 
error 017: undefined symbol "x" - the line of the stock
error 017: undefined symbol "url" - the function that i mentioned right now.


I don't want a specific song or a list of some. I want the player to put any link he want.
I guessed that I should format the string but I need some help on doing this!
Reply
#8

pawn Код:
stock PlayAudioStreamForAll(url[])
{
    for(new i; i<MAX_PLAYERS i++)
    {
        if(IsPlayerConnected( i ))
        {
           
            PlayAudioStreamForPlayer(i, url); //removed x,y,z and distance since you won't need that there
        }
    }
    return 1;

}
Copy paste the code above over your old stock, I fixed the first error there.
Now, all you have to do is this:
pawn Код:
if(response)
        {
            PlayAudioStreamForAll(inputtext);//changed the non-existing 'url' to inputtext
        }
This should do the trick.
Reply
#9

error 001: expected token: ";", but found "-identifier-"

PHP код:
for(new ii<MAX_PLAYERS i++) 
Reply
#10

for(new i; i<MAX_PLAYERS; i++)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)