Radio Stream Help - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Radio Stream Help (
/showthread.php?tid=347719)
Radio Stream Help -
Toshh - 02.06.2012
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
Re: Radio Stream Help -
mati233 - 02.06.2012
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.
Re: Radio Stream Help -
Toshh - 02.06.2012
I think I understand what you mean, could you put that into code?
Re: Radio Stream Help -
Revo - 02.06.2012
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.
Re: Radio Stream Help -
Toshh - 02.06.2012
Thanks, it worked