why does this not work OnDialogResponse
#1

why does this not work

this in onplayercommand
Код:
if (strcmp("/stream", cmdtext, true, 10) == 0) //Change this one to whatever you want.
    {
        ShowPlayerDialog(playerid,90100,DIALOG_STYLE_LIST,"Radio List","1. Custom\r\n2. Radio Station 1\r\n3. Radio Station 2","Select", "Cancel");
        //We use the line above to make the Dialog show, and as you notice we want DIALOG_STYLE_LIST because it will be a list so we can choose from.
        //As you notice everytime you add \r\n it adds a new line to the list, which means in our tutorial adds a new radio station to the list.
        //Make sure you change the ID of the Dialog, we don't want it to mix with other dialogs in your server, I set it to 90.
        return 1;
    }
    if (strcmp("/stopradio", cmdtext, true, 10) == 0)
    {
        StopAudioStreamForPlayer(playerid);//This is the function we need to stop the audio from streaming the music.
        return 1;
    }

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 0 && response == 1)
    {
	    new pName[MAX_PLAYER_NAME],gName[MAX_PLAYER_NAME],string[128];
	    new giveplayerid = GetPVarInt(playerid,"ClickedPlayer");
	    GetPlayerName(playerid,pName,sizeof pName);
	    GetPlayerName(giveplayerid,gName,sizeof gName);
	    format(string,sizeof string,"{B0B0B0}[PM]{FF0000}From {B0B0B0}%s[%d]{FF0000}: {E3BB19}%s",pName,playerid,inputtext);
	    SendClientMessage(giveplayerid,0xFFE615D4,string);
	    format(string,sizeof string,"{B0B0B0}[PM]{FF0000}Sent to {B0B0B0}%s{FF0000}: {E3BB19}%s",gName,inputtext);
	    SendClientMessage(playerid,0xFFE615D4,string);
	    PMLog(string);
	    return 1;
    }
	if(dialogid == 90100)
    {
			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://radio02-cn3.akadostream.ru:8814/nrj192.mp3");//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.
					ShowPlayerDialog(playerid, 10200, DIALOG_STYLE_INPUT, "Custom Radio","{FFFFFF}Write the {009BFF}URL{FFFFFF} from Radio Station:", "Okay", "Exit");
					return 1;
                }
                case 1://Case 1 is the second line we put in ShowPlayerDialog (\r\n2.)
                {
                    PlayAudioStreamForPlayer(playerid, "http://www.bbc.co.uk/radio/listen/live/r1_aaclca.pls");//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;
                }
                case 2://Case 2 is the third line we put in ShowPlayerDialog(\r\n3.)
                {
                    PlayAudioStreamForPlayer(playerid, "http://sc.3wk.com:8300/");//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;
                }
                //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..
            }
    }
	if(dialogid == 10200) //
	{
		SendClientMessage(playerid,0x42F3F198,"woop");
		if(response)
		{	
			
			for(new i=0; i<250; i++)
			{
				if(IsPlayerConnected(i))
				{
					PlayAudioStreamForPlayer(i, inputtext);
					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;
				}
			}
		}
	}
	return 0;
}
Reply


Messages In This Thread
why does this not work OnDialogResponse - by cssbart - 01.09.2012, 13:06
Re: why does this not work OnDialogResponse - by Misiur - 01.09.2012, 13:15
Re: why does this not work OnDialogResponse - by cssbart - 01.09.2012, 16:24

Forum Jump:


Users browsing this thread: 1 Guest(s)