11.01.2013, 07:04
Help! Ive made an IG radio streaming, but if leaving car the radio keeps playing!
Everything works, except, if you leave the vehicle, the radio keeps playing...
I am a newbie, please fix the code for me! I will give creds!
CODE:
Everything works, except, if you leave the vehicle, the radio keeps playing...
I am a newbie, please fix the code for me! I will give creds!

CODE:
Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/startradio", cmdtext, true, 10) == 0)
if(IsPlayerInAnyVehicle(playerid)) {
ShowPlayerDialog(playerid,90,DIALOG_STYLE_LIST,"Radio stations list","1. Dubstep.FM\r\n2. Radio Gold - Israeli Music\r\n3. Radio Kol Akko","Select", "Cancel");
}
else
{
SendClientMessage(playerid,0x00FF00AA,"You're not in a vehicle.");
}
}
if (strcmp("/stopradio", cmdtext, true, 10) == 0)
{
SendClientMessage(playerid,0x00FF00AA,"You have stopped the radio.");
StopAudioStreamForPlayer(playerid);
return 1;
}
return 0;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case 90:
{
if(!response)
SendClientMessage(playerid, 0x42F3F198, "You canceled the dialog.");//This one sends a message when you close the dialog using (Cancel).
return 1;
}
switch(listitem)
{
case 0://Case 0 is basically the first line we made in ShowPlayerDialog (1.)
{
PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=148196");//This function will play our desired radio. So we have to put the url between its brackets.
SendClientMessage(playerid, 0x42F3F198, "Type /stopradio to stop audio streaming."); //This line sends a message to the listener that he can stop it using /stopradio.
}
case 1://Case 1 is the second line we put in ShowPlayerDialog (\r\n2.)
{
PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=1267208");//This function will play our desired radio. So we have to put the url between its brackets.
SendClientMessage(playerid, 0x42F3F198, "Type /stopradio to stop audio streaming.");//This line sends a message to the listener that he can stop it using /stopradio.
}
case 2://Case 2 is the third line we put in ShowPlayerDialog(\r\n3.)
{
PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=79683");//This function will play our desired radio. So we have to put the url between its brackets.
SendClientMessage(playerid, 0x42F3F198, "Type /stopradio to stop audio streaming.");//This line sends a message to the listener that he can stop it using /stopradio.
}
}
}
}
return 1;
}


