Incognito's Audio Plugin - Radio Streaming: Passengers
#1

Hello there,

I'm trying to achieve this goal here.. I'd like it so a passenger of a vehicle hears the radio when the driver starts one.
Unfortunately, I'm not very succesful, only the driver can hear it.

Here's my code:

Код:
if(listitem == 0)// (1-Jazz Radio)
			{
			    if(pRadio[playerid] == 0)
			    {
           			for(new i; i < MAX_PLAYERS; i++)
					{
		    			new vehicle = GetPlayerVehicleID(playerid);
		    			if(GetPlayerState(i) == PLAYER_STATE_DRIVER || GetPlayerState(i) == PLAYER_STATE_PASSENGER && GetPlayerVehicleID(i) == vehicle)
	    				{
   							Radio[playerid] = Audio_PlayStreamed(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=674096",false,false,false);
   							pRadio[playerid] = 1;
    						pRadioID[playerid] = 0;
						}
					}
				}
				else
				{
				    SendClientMessage(playerid, 0xFF0000AA, "[MUSIC ERROR]: You're already playing a radio station!");
				}
			}
I hope one of you could help me out.
Thanks,
Jack Shred.
Reply
#2

You're using 'playerid' in your loop, replace that with the variable i.

Edit: I noticed you do not use this variable, so i recommend to delete it.

Код:
new vehicle = GetPlayerVehicleID(playerid);
Reply
#3

Ah that was a dumb mistake, I edited playerid to i.
However, it still doesn't work. It only works for the driver.
Reply
#4

pawn Код:
if(listitem == 0)// (1-Jazz Radio)
    {
        if(pRadio[playerid] == 0)
        {
                    new vehicle = GetPlayerVehicleID(playerid);
                    for(new i; i < MAX_PLAYERS; i++)
                    {
                        if(IsPlayerInVehicle(i, vehicle)
                        {
                            if(GetPlayerState(i) == PLAYER_STATE_DRIVER || GetPlayerState(i) == PLAYER_STATE_PASSENGER)
                            {
                                Radio[playerid] = Audio_PlayStreamed(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=674096",false,false,false);
                                pRadio[playerid] = 1;
                                pRadioID[playerid] = 0;
                            }
                        }
                    }
        }
        else
        {
            SendClientMessage(playerid, 0xFF0000AA, "[MUSIC ERROR]: You're already playing a radio station!");
        }
    }
I think this should work.
Reply
#5

Well you corrected a very obvious and huge mistake, but still left in another major issue!
Replace the loop with this:
pawn Код:
for(new i; i < MAX_PLAYERS; i++)
{
    if(IsPlayerInVehicle(i, vehicle))
    {
        Radio[i] = Audio_PlayStreamed(i, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=674096",false,false,false);
        pRadio[i] = 1;
        pRadioID[i] = 0;
    }
}
// edit: left in a small mistake, sorry!
Reply
#6

pawn Код:
Radio[i] = Audio_PlayStreamed(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=674096",false,false,false);
Shouldn't it be like this:
pawn Код:
Radio[i] = Audio_PlayStreamed(i, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=674096",false,false,false);
Reply
#7

Quote:
Originally Posted by Mr4rtur
Посмотреть сообщение
pawn Код:
Radio[i] = Audio_PlayStreamed(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=674096",false,false,false);
Shouldn't it be like this:
pawn Код:
Radio[i] = Audio_PlayStreamed(i, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=674096",false,false,false);
And once again a foolish mistake!
Thanks alot, it works now.
Reply
#8

pawn Код:
if(GetPlayerState(i) == PLAYER_STATE_DRIVER || GetPlayerState(i) == PLAYER_STATE_PASSENGER)
What's the point of this?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)