Radio Stream Help
#1

Hey guys,

I made a few commands so players could listen to a radio station in a vehicle.

Example:
Код:
if(strcmp(cmdtext, "/setstation1", true))
    {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,"You need to be in a vehicle to listen to the radio.");
		PlayAudioStreamForPlayer(playerid, "http://72.233.84.175:80");
		SendClientMessage(playerid,0xFFFFFFFF,"You are now listening to DUBSTEP.FM");
	}
	if(strcmp(cmdtext, "/setstation2", true))
	{
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,"You need to be in a vehicle to listen to the radio.");
		PlayAudioStreamForPlayer(playerid, "http://scfire-mtc-aa04.stream.aol.com:80/stream/1030");
		SendClientMessage(playerid,0xFFFFFFFF,"You are now listening to RADIOUP.COM - THE HITLIST.");
	}
But what I need help with is when a player leaves a vehicle and enters the vehicle again, I want it to play the station they were listening to before they left the vehicle. I have no idea how to do it.

Thanks again
Reply
#2

Create a simple var to the vehicles, like: Vehicle[vehicleid][STATION]=1;
Then, when the player enters the vehicle you check the value Vehicle[vehicleid][STATION], and restart the correct streaming.
Reply
#3

I think I understand what you mean, could you put that into code?
Reply
#4

pawn Код:
new LastRadioStation[MAX_PLAYERS]
pawn Код:
if(strcmp(cmdtext, "/setstation1", true))
    {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,"You need to be in a vehicle to listen to the radio.");
        PlayAudioStreamForPlayer(playerid, "http://72.233.84.175:80");
        SendClientMessage(playerid,0xFFFFFFFF,"You are now listening to DUBSTEP.FM");
                LastRadioStation[playerid] = 1;
    }
    if(strcmp(cmdtext, "/setstation2", true))
    {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,"You need to be in a vehicle to listen to the radio.");
        PlayAudioStreamForPlayer(playerid, "http://scfire-mtc-aa04.stream.aol.com:80/stream/1030");
        SendClientMessage(playerid,0xFFFFFFFF,"You are now listening to RADIOUP.COM - THE HITLIST.");
                LastRadioStation[playerid] = 2;
    }
pawn Код:
OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
  if (LastRadioStation[playerid] == 1)
  {  
    //code..
  }
  if (LastRadioStation[playerid] == 2)
  {
    //code..
  }
}
I hope you understand it like this! I haven't tested it myself but it should work.
Reply
#5

Thanks, it worked
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)