Help plx
#1

Hello Guys... Can you tell me that when i put the URL then why the music only plays to me i want it to play for everyone in server. Here's the coding...
pawn Код:
#include <a_samp>
#include <zcmd>

#define FILTERSCRIPT
#define DIALOG_MUSIC 1

#define COLOUR_WHITE 0xFFFFFFFF


public OnFilterScriptInit()
{
    print("\n----------------------------");                          
    print(" Music Player");
    print("-----------------------------\n");                          
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{

    if(dialogid == DIALOG_MUSIC)
    {
           if(response)
           {
               new string[126];
               format(string, sizeof(string), "%s", inputtext);
               PlayAudioStreamForPlayer(playerid, string);
           }
           else
           {
               HideMenuForPlayer(DIALOG_MUSIC, playerid);
           }
    }  

}

CMD:play(playerid, params[])
{
    ShowPlayerDialog(playerid, DIALOG_MUSIC , DIALOG_STYLE_INPUT, "Enter the music URL", "Enter the music url", "Play", "Cancel");
    return 1;
}

CMD:stop(playerid, params[])
{
    StopAudioStreamForPlayer(playerid);
    return 1;
}
Reply
#2

Learn to use Foreach

Код:
foreach(Player,i)
{
PlayAudioStreamForPlayer(i, string);
}
Reply
#3

Use:
pawn Код:
foreach(new i : Player)
{
     PlayAudioStreamForPlayer(i, string);
      // your message
}
I don't think that you would even need to format a string, you could do directly inputtext..

If you don't want to use the foreach include use

for(new i = 0; i < MAX_PLAYERS; i++)

Any feedback would be appreciated!
Reply
#4

I'll give you feedback Stanford but please can you give me the fixed version of that whole coding. Ty
Reply
#5

Here
pawn Код:
if(dialogid == DIALOG_MUSIC)
    {
           if(response)
           {
               foreach( new i : Player)
               {
                    PlayAudioStreamForPlayer(playerid, inputtext);
                    SendClientMessage(playerid, -1, "new music is playing..");
               }
           }
           else
           {
               HideMenuForPlayer(DIALOG_MUSIC, playerid);
           }
     }
Download foreach and in top of your gamemode #include <foreach>
Reply
#6

I got 4 errors in compiling it. :/ ... I have +REPed you coz you helped me. But i wish that you make those error go and when i do now /play so everyone in server can hear the music
these are errors
Код:
(31) : error 017: undefined symbol "foreach"
(31) : error 029: invalid expression, assumed zero
(31) : error 017: undefined symbol "i"
(31) : fatal error 107: too many error messages on one line
And yea i added #include <foreach> in the top
Reply
#7

You have to make Dialogs for adding more song
PHP код:
CMD:airoplanebob(playeridparams[])
    {
        for(new 
0MAX_PLAYERSi++)
        
PlayAudioStreamForPlayer(i"http://angelnaina.mobile9.com/download/media/3/asaddsafdb_hpm3nlom.mp3");
        return 
1;
    } 
Reply
#8

You need to have the file of foreach..
If you don't have it then replace the foreach line with this:

pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
And it will work.
Reply
#9

Still same result neither playing music to me nor to other players. Just the dialogue comes and I insert the link but nothing plays :/
Reply
#10

It should work right now:

pawn Код:
if(dialogid == DIALOG_MUSIC)    
{          
     if(response)          
     {              
        for(new i = 0; i < MAX_PLAYERS; i++)              
        {                    
             PlayAudioStreamForPlayer(i, inputtext);
             SendClientMessage(i, -1, "new music is playing..");              
        }          
   }          
   else          
   {              
       HideMenuForPlayer(DIALOG_MUSIC, playerid);          
   }    
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)