PlayAudioStreamForAll -
eldar7393 - 12.04.2013
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 i; i<GetMaxPlayers(); i++)
{
if(IsPlayerConnected( i ))
{
PlayAudioStreamForPlayer(i, url, x, y, z, distance);
}
}
return 1;
}
if(dialogid == DIALOG_MUSIC)
{
if(response)
{
PlayAudioStreamForPlayer(i, url, x, y, z, distance);
error 017: undefined symbol "i"
Re: PlayAudioStreamForAll -
Denying - 12.04.2013
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?
Re: PlayAudioStreamForAll -
Pottus - 12.04.2013
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.
Re: PlayAudioStreamForAll -
Jstylezzz - 12.04.2013
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"
Re: PlayAudioStreamForAll -
eldar7393 - 12.04.2013
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.
Re: PlayAudioStreamForAll -
Jstylezzz - 12.04.2013
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.
Re: PlayAudioStreamForAll -
eldar7393 - 12.04.2013
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 i; i<GetMaxPlayers(); i++)
{
if(IsPlayerConnected( i ))
{
PlayAudioStreamForPlayer(i, url, x, y, z, distance);
}
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
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!
Re: PlayAudioStreamForAll -
Jstylezzz - 12.04.2013
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.
Re: PlayAudioStreamForAll -
eldar7393 - 12.04.2013
error 001: expected token: ";", but found "-identifier-"
PHP код:
for(new i; i<MAX_PLAYERS i++)
Re: PlayAudioStreamForAll -
Denying - 12.04.2013
for(new i; i<MAX_PLAYERS; i++)