Need assistance with radiostation
#1

Command: /Radiostation

Expectation: Well I am trying to create a vehicle based command, the command"radiostation" is expected to work only in a vehicle, lets say i wanted to listen to Hot108Jams I can only listen to it in a vehicle, if i exit the vehicle the music should stop also during the playing of audio/music the ingamesounds should not disable.


Problem Facing: the games audio seems to be disabled I am a Self-thought scripter, who is still in his infant stage XD.

pawno information:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/radiostation", cmdtext, true, 10) == 0)
{
if(!IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid, 0xDBED15,"Error: You Need to Be in a VEHICLE to utilize this command!");
StopAudioStreamForPlayer(playerid);
}
else
{
ShowPlayerDialog(playerid,90,DIALOG_STYLE_LIST,"My Radio list","1. Hot 108 Jamz\r\n2. Country Music\r\n3.R&B","Select", "Cancel");
}
return 1;
}
return 0;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(!IsPlayerInAnyVehicle(playerid))
{
StopAudioStreamForPlayer(playerid);
}
else
{
SendClientMessage(playerid, 0xDBED15,"You can listen to Online Radio Stations by using /radiostation");
}

return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case 90: //Remember the ID we changed in ShowPlayerDialog? (90) That's how the DialogResponse will get to know which Dialog it's going to use.
{
if(!response)// This one is used for option 2 which we changed to (Cancel).
{
SendClientMessage(playerid, 0x42F3F198, "You canceled the dialog.");//This one sends a message when you close the dialog using (Cancel).
return 1;
}

switch(listitem)//This one will list the items.
{
case 0://Case 0 is basically the first line we made in ShowPlayerDialog (1.)
{

PlayAudioStreamForPlayer(playerid, "http://www.powerhitz.com/hot108jamz.pls");//This function will play our desired radio. So we have to put the url between its brackets.

}
case 1://Case 1 is the second line we put in ShowPlayerDialog (\r\n2.)
{
PlayAudioStreamForPlayer(playerid, "http://www.powerhitz.com/country.pls");//This function will play our desired radio. So we have to put the url between its brackets.

}
case 2://Case 2 is the third line we put in ShowPlayerDialog(\r\n3.)
{
PlayAudioStreamForPlayer(playerid, "http://streaming.q-music.be/QBE_HI");//This function will play our desired radio. So we have to put the url between its brackets.
}
//You can continue cases here but make sure you make a new line in the ShowPlayerDialog on /myradio command \r\n4. 4th \r\n5. 5th channel etc..
}
}
}
return 1;
}



THANKYOU FOR READING!!!



"for Less confussion on my bbehalf please use this format below.
Response:

Solution:

pawno Information:


Additional Information:"
Reply
#2

just use
PHP код:
public OnPlayerExitVehicle(playeridvehicleid)
{
     
StopAudioStreamForPlayer(playerid);
     return 
1;

this will stop the music when he exit the car
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)