SA-MP Forums Archive
Dialog 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: Dialog Help. (/showthread.php?tid=615425)



[Assisted] Dialog Help. - alexkeward - 22.08.2016

So im trying to get this wonderful filterscript to merge with my /phone cmd.

filterscript
Код:
// Simple Filterscript - ******* music
// /dmusic = Edinson_Walker / EdinsonWalker.
// /music = jhgr16

#include < a_samp >

public OnFilterScriptInit() {
    print("       /phonemusic /music       ");
    return 1;
}

public OnFilterScriptExit() {
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[]) {
	if (strcmp("/phonemusic", cmdtext, true) == 0) {
		ShowPlayerDialog(playerid, 2016, DIALOG_STYLE_INPUT, "{D6E1EB}*******", "{FFFFFF}Insert the video/music title", "Accept", "Cancel");
		return 1;
	}
	return 0;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
	if(dialogid == 2016) {
		if (!response) return SendClientMessage(playerid, 0xD6E1EBFF, "Dialog music canceled.");
 		if(strlen(inputtext)) {
			new ola[255];
			format(ola, sizeof(ola), "https://6t.pe/?song=%s", inputtext);
			PlayAudioStreamForPlayer(playerid, ola);
		}
	}
    return 0;
}
Phone CMD
Код:
CMD:phone(playerid, params[])
{
	if (!Inventory_HasItem(playerid, "Cellphone"))
	    return SendErrorMessage(playerid, "You don't have a cellphone on you.");

    if (PlayerData[playerid][pHospital] != -1 || PlayerData[playerid][pCuffed] || PlayerData[playerid][pInjured] || !IsPlayerSpawned(playerid))
	    return SendErrorMessage(playerid, "You can't use this command now.");

	static
	    str[32];

	format(str, sizeof(str), "Phone (#%d)", PlayerData[playerid][pPhone]);

	if (PlayerData[playerid][pPhoneOff]) {
		Dialog_Show(playerid, MyPhone, DIALOG_STYLE_LIST, str, "Dial Number\nMy Contacts\nSend Text Message\nTurn On Phone", "Select", "Cancel");
	}
	else {
	    Dialog_Show(playerid, MyPhone, DIALOG_STYLE_LIST, str, "Dial Number\nMy Contacts\nSend Text Message\nTurn Off Phone", "Select", "Cancel");
	}
	return 1;
}
Can someone help me please. <3
Probably would need more of the code but i dont know which parts to include it into.


Re: Dialog Help. - DarkSkull - 22.08.2016

Show Your OnDialogResponse


Re: Dialog Help. - alexkeward - 22.08.2016

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	switch(dialogid)
	{
		case 12211:
		{
  			if(!response)return 1;
  			else
	    	{
      			new string[128];
	        	format(string, sizeof(string), "[HELPER]: %s is needing some help. Use /assist %d to assist them.", ReturnName(playerid, 0), playerid);
	        	format(string, sizeof(string), "[HELPER]: An assistance request has been received by %s. Use /assist %d to assist them.", ReturnName(playerid, 0), playerid);
				SendHelperMessage(COLOR_NEWGREEN, string);
				format(string, sizeof(string), "[REQUEST] %s %s", inputtext), ReturnName(playerid, 0);
				SendHelperMessage(COLOR_WHITE, string);
				AssistanceNeeded[playerid] = 1;
    		}
		}

		case 12212:
		{
  			if(!response)return 1;
  			else
	    	{
      			new string[128];
	        	format(string, sizeof(string), "[FACTION MANAGEMENT]: %s is requesting their faction name to be changed. Please contact them.", ReturnName(playerid, 0), playerid);
				SendAdminAlert(COLOR_NEWGREEN, string);
				format(string, sizeof(string), "[DETAILS]: %s %s", inputtext), ReturnName(playerid, 0);
				SendAdminAlert(COLOR_WHITE, string);
    		}
		}
		case 12250:
		{
  			if(!response)return 1;
	    	else
		    {
      			switch(listitem)
       			{
          			case 0:
	            	{
               			if(PlayerData[playerid][pMoney] >= 100)
                 		{
	                    	PlayerData[playerid][pMoney] -= 100;
	                    	new id = Inventory_Add(playerid, "Magazine", 2039);

	                    	if (id == -1)
        						return SendErrorMessage(playerid, "You don't have any inventory slots left.");
        						
	                    	SendClientMessage(playerid, COLOR_WHITE, "You have purchased a Magazine from the Black Market for the price of $100.");
						}
						else return SendErrorMessage(playerid, "You don't have enough money to finish the purchase.");
         			}
            		case 1:
		            {
               			if(PlayerData[playerid][pMoney] >= 200)
                 		{
	                    	PlayerData[playerid][pMoney] -= 200;
	                    	new id = Inventory_Add(playerid, "Ammo Cartridge", 2358);

							if (id == -1)
        						return SendErrorMessage(playerid, "You don't have any inventory slots left.");
        						
	                    	SendClientMessage(playerid, COLOR_WHITE, "You have purchased an Ammo Cartridge from the Black Market for the price of $200.");
						}
						else return SendErrorMessage(playerid, "You don't have enough money to finish the purchase.");
            		}
            		case 2:
		            {
               			if(PlayerData[playerid][pMoney] >= 500)
                 		{
                 		    if (Inventory_Count(playerid, "Armored Vest") >= 3)
		                		return SendErrorMessage(playerid, "You have 3 armored vests, you can't buy anymore.");
		                		
                            new id = Inventory_Add(playerid, "Armored Vest", 19142);

							if (id == -1)
        						return SendErrorMessage(playerid, "You don't have any inventory slots left.");
		                		
	                    	PlayerData[playerid][pMoney] -= 500;
	                    	SendClientMessage(playerid, COLOR_WHITE, "You have purchased an Armored Vest from the Black Market for the price of $500.");
						}
						else return SendErrorMessage(playerid, "You don't have enough money to finish the purchase.");
            		}
            		case 3:
		            {
               			if(PlayerData[playerid][pMoney] >= 1000)
                 		{
	                    	PlayerData[playerid][pMoney] -= 1000;
	                    	SetPlayerArmour(playerid, 100.0);
	                    	SendClientMessage(playerid, COLOR_WHITE, "You have purchased a Heavy Armored Vest from the Black Market for the price of $1000.");
						}
						else return SendErrorMessage(playerid, "You don't have enough money to finish the purchase.");
            		}
            		case 4:
		            {
               			if(PlayerData[playerid][pMoney] >= 500)
                 		{
	                    	PlayerData[playerid][pMoney] -= 500;
	                    	new id = Inventory_Add(playerid, "Bomb", 1654);

							if (id == -1)
        						return SendErrorMessage(playerid, "You don't have any inventory slots left.");

	                    	SendClientMessage(playerid, COLOR_WHITE, "You have purchased a Bomb from the Black Market for the price of $500.");
						}
						else return SendErrorMessage(playerid, "You don't have enough money to finish the purchase.");
            		}
   	}
			}
		}
	}
	return 0;
}



Re: Dialog Help. - DarkSkull - 22.08.2016

Where do you handle the dialog for you Phone command?

PHP код:
Dialog_Show(playeridMyPhoneDIALOG_STYLE_LISTstr"Dial Number\nMy Contacts\nSend Text Message\nTurn On Phone""Select""Cancel");
    } 



Re: Dialog Help. - alexkeward - 22.08.2016

All in these kinds of things
Код:
Dialog:Contacts(playerid, response, listitem, inputtext[])
{
	if (response)
	{
	    if (!listitem) {
	        Dialog_Show(playerid, NewContact, DIALOG_STYLE_INPUT, "New Contact", "Please enter the name of the contact below:", "Submit", "Back");
	    }
	    else {
		    PlayerData[playerid][pContact] = ListedContacts[playerid][listitem - 1];

	        Dialog_Show(playerid, ContactInfo, DIALOG_STYLE_LIST, ContactData[playerid][PlayerData[playerid][pContact]][contactName], "Call Contact\nDelete Contact", "Select", "Back");
	    }
	}
	else {
		cmd_phone(playerid, "\1");
	}
	for (new i = 0; i != MAX_CONTACTS; i ++) {
	    ListedContacts[playerid][i] = -1;
	}
	return 1;
}

Dialog:DialNumber(playerid, response, listitem, inputtext[])
{
	if (response)
	{
	    new
	        string[16];

	    if (isnull(inputtext) || !IsNumeric(inputtext))
	        return Dialog_Show(playerid, DialNumber, DIALOG_STYLE_INPUT, "Dial Number", "Please enter the number that you wish to dial below:", "Dial", "Back");

        format(string, 16, "%d", strval(inputtext));
		cmd_call(playerid, string);
	}
	else {
		cmd_phone(playerid, "\1");
	}
	return 1;
}

Dialog:SendText(playerid, response, listitem, inputtext[])
{
	if (response)
	{
	    new number = strval(inputtext);

	    if (isnull(inputtext) || !IsNumeric(inputtext))
	        return Dialog_Show(playerid, SendText, DIALOG_STYLE_INPUT, "Send Text Message", "Please enter the number that you wish to send a text message to:", "Dial", "Back");

        if (GetNumberOwner(number) == INVALID_PLAYER_ID)
            return Dialog_Show(playerid, SendText, DIALOG_STYLE_INPUT, "Send Text Message", "Error: That number is not online right now.\n\nPlease enter the number that you wish to send a text message to:", "Dial", "Back");

		PlayerData[playerid][pContact] = GetNumberOwner(number);
		Dialog_Show(playerid, TextMessage, DIALOG_STYLE_INPUT, "Text Message", "Please enter the message to send to %s:", "Send", "Back", ReturnName(PlayerData[playerid][pContact], 0));
	}
	else {
		cmd_phone(playerid, "\1");
	}
	return 1;
}

Dialog:TextMessage(playerid, response, listitem, inputtext[])
{
	if (response)
	{
		if (isnull(inputtext))
			return Dialog_Show(playerid, TextMessage, DIALOG_STYLE_INPUT, "Text Message", "Error: Please enter a message to send.\n\nPlease enter the message to send to %s:", "Send", "Back", ReturnName(PlayerData[playerid][pContact], 0));

		new targetid = PlayerData[playerid][pContact];

		if (!IsPlayerConnected(targetid) || !PlayerData[targetid][pPhone])
		    return SendErrorMessage(playerid, "The specified phone number went offline.");

		GiveMoney(playerid, -1);
		ShowPlayerFooter(playerid, "You've been ~r~charged~w~ $1 to send a text.");

		SendClientMessageEx(targetid, COLOR_YELLOW, "[TEXT]: %s - %s (%d)", inputtext, ReturnName(playerid, 0), PlayerData[playerid][pPhone]);
		SendClientMessageEx(playerid, COLOR_YELLOW, "[TEXT]: %s - %s (%d)", inputtext, ReturnName(playerid, 0), PlayerData[playerid][pPhone]);

        PlayerPlaySoundEx(targetid, 21001);
		SendNearbyMessage(playerid, 30.0, COLOR_PURPLE, "** %s takes out their phone and sends a text.", ReturnName(playerid, 0));
	}
	else {
        Dialog_Show(playerid, SendText, DIALOG_STYLE_INPUT, "Send Text Message", "Please enter the number that you wish to send a text message to:", "Submit", "Back");
	}
	return 1;
}

Dialog:MyPhone(playerid, response, listitem, inputtext[])
{
	if (response)
	{
		switch (listitem)
		{
		    case 0:
		    {
		        if (PlayerData[playerid][pPhoneOff])
		            return SendErrorMessage(playerid, "Your phone must be powered on.");

				Dialog_Show(playerid, DialNumber, DIALOG_STYLE_INPUT, "Dial Number", "Please enter the number that you wish to dial below:", "Dial", "Back");
			}
			case 1:
			{
			    if (PlayerData[playerid][pPhoneOff])
		            return SendErrorMessage(playerid, "Your phone must be powered on.");

			    ShowContacts(playerid);
			}
		    case 2:
		    {
		        if (PlayerData[playerid][pPhoneOff])
		            return SendErrorMessage(playerid, "Your phone must be powered on.");

		        Dialog_Show(playerid, SendText, DIALOG_STYLE_INPUT, "Send Text Message", "Please enter the number that you wish to send a text message to:", "Dial", "Back");
			}
			case 3:
			{
			    if (!PlayerData[playerid][pPhoneOff])
			    {
           			if (PlayerData[playerid][pCallLine] != INVALID_PLAYER_ID) {
			        	CancelCall(playerid);
					}
					PlayerData[playerid][pPhoneOff] = 1;
			        SendNearbyMessage(playerid, 30.0, COLOR_PURPLE, "** %s has powered off their cellphone.", ReturnName(playerid, 0));
				}
				else
				{
				    PlayerData[playerid][pPhoneOff] = 0;
			        SendNearbyMessage(playerid, 30.0, COLOR_PURPLE, "** %s has powered on their cellphone.", ReturnName(playerid, 0));
				}
			}
		}
	}
	return 1;
}



Re: Dialog Help. - DarkSkull - 22.08.2016

Replace you phone cmd with this
PHP код:
CMD:phone(playeridparams[])
{
    if (!
Inventory_HasItem(playerid"Cellphone"))
        return 
SendErrorMessage(playerid"You don't have a cellphone on you.");
    if (
PlayerData[playerid][pHospital] != -|| PlayerData[playerid][pCuffed] || PlayerData[playerid][pInjured] || !IsPlayerSpawned(playerid))
        return 
SendErrorMessage(playerid"You can't use this command now.");
    static
        
str[32];
    
format(strsizeof(str), "Phone (#%d)"PlayerData[playerid][pPhone]);
    if (
PlayerData[playerid][pPhoneOff]) {
        
Dialog_Show(playeridMyPhoneDIALOG_STYLE_LISTstr"Dial Number\nMy Contacts\nSend Text Message\nMusic\nTurn On Phone""Select""Cancel");
    }
    else {
        
Dialog_Show(playeridMyPhoneDIALOG_STYLE_LISTstr"Dial Number\nMy Contacts\nSend Text Message\nMusic\nTurn Off Phone""Select""Cancel");
    }
    return 
1;

Replace your Dialog:MyPhone with this
PHP код:
Dialog:MyPhone(playeridresponselistiteminputtext[])
{
    if (
response)
    {
        switch (
listitem)
        {
            case 
0:
            {
                if (
PlayerData[playerid][pPhoneOff])
                    return 
SendErrorMessage(playerid"Your phone must be powered on.");
                
Dialog_Show(playeridDialNumberDIALOG_STYLE_INPUT"Dial Number""Please enter the number that you wish to dial below:""Dial""Back");
            }
            case 
1:
            {
                if (
PlayerData[playerid][pPhoneOff])
                    return 
SendErrorMessage(playerid"Your phone must be powered on.");
                
ShowContacts(playerid);
            }
            case 
2:
            {
                if (
PlayerData[playerid][pPhoneOff])
                    return 
SendErrorMessage(playerid"Your phone must be powered on.");
                
Dialog_Show(playeridSendTextDIALOG_STYLE_INPUT"Send Text Message""Please enter the number that you wish to send a text message to:""Dial""Back");
            }
            case 
3: {
                
ShowPlayerDialog(playerid2016DIALOG_STYLE_INPUT"{D6E1EB}*******""{FFFFFF}Insert the video/music title""Accept""Cancel");
            }
            case 
4:
            {
                if (!
PlayerData[playerid][pPhoneOff])
                {
                       if (
PlayerData[playerid][pCallLine] != INVALID_PLAYER_ID) {
                        
CancelCall(playerid);
                    }
                    
PlayerData[playerid][pPhoneOff] = 1;
                    
SendNearbyMessage(playerid30.0COLOR_PURPLE"** %s has powered off their cellphone."ReturnName(playerid0));
                }
                else
                {
                    
PlayerData[playerid][pPhoneOff] = 0;
                    
SendNearbyMessage(playerid30.0COLOR_PURPLE"** %s has powered on their cellphone."ReturnName(playerid0));
                }
            }
        }
    }
    return 
1;

Add this to OnDialogResponse
PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[]) {
    if(
dialogid == 2016) {
        if (!
response) return SendClientMessage(playerid0xD6E1EBFF"Dialog music canceled.");
         if(
strlen(inputtext)) {
            new 
ola[255];
            
format(olasizeof(ola), "https://6t.pe/?song=%s"inputtext);
            
PlayAudioStreamForPlayer(playeridola);
        }
    }
    return 
0;

I haven't tested this but this should work.


Re: Dialog Help. - alexkeward - 22.08.2016

Ignore this, Thanks for the help man. Much appreciated. <3


Re: Dialog Help. - DarkSkull - 22.08.2016

Sorry, I thought you had empty callback. Here you go.
PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch(
dialogid)
    {
        case 
12211:
        {
              if(!
response)return 1;
              else
            {
                  new 
string[128];
                
format(stringsizeof(string), "[HELPER]: %s is needing some help. Use /assist %d to assist them."ReturnName(playerid0), playerid);
                
format(stringsizeof(string), "[HELPER]: An assistance request has been received by %s. Use /assist %d to assist them."ReturnName(playerid0), playerid);
                
SendHelperMessage(COLOR_NEWGREENstring);
                
format(stringsizeof(string), "[REQUEST] %s %s"inputtext), ReturnName(playerid0);
                
SendHelperMessage(COLOR_WHITEstring);
                
AssistanceNeeded[playerid] = 1;
            }
        }

        case 
12212:
        {
              if(!
response)return 1;
              else
            {
                  new 
string[128];
                
format(stringsizeof(string), "[FACTION MANAGEMENT]: %s is requesting their faction name to be changed. Please contact them."ReturnName(playerid0), playerid);
                
SendAdminAlert(COLOR_NEWGREENstring);
                
format(stringsizeof(string), "[DETAILS]: %s %s"inputtext), ReturnName(playerid0);
                
SendAdminAlert(COLOR_WHITEstring);
            }
        }
        case 
12250:
        {
              if(!
response)return 1;
            else
            {
                  switch(
listitem)
                   {
                      case 
0:
                    {
                           if(
PlayerData[playerid][pMoney] >= 100)
                         {
                            
PlayerData[playerid][pMoney] -= 100;
                            new 
id Inventory_Add(playerid"Magazine"2039);

                            if (
id == -1)
                                return 
SendErrorMessage(playerid"You don't have any inventory slots left.");
                                
                            
SendClientMessage(playeridCOLOR_WHITE"You have purchased a Magazine from the Black Market for the price of $100.");
                        }
                        else return 
SendErrorMessage(playerid"You don't have enough money to finish the purchase.");
                     }
                    case 
1:
                    {
                           if(
PlayerData[playerid][pMoney] >= 200)
                         {
                            
PlayerData[playerid][pMoney] -= 200;
                            new 
id Inventory_Add(playerid"Ammo Cartridge"2358);

                            if (
id == -1)
                                return 
SendErrorMessage(playerid"You don't have any inventory slots left.");
                                
                            
SendClientMessage(playeridCOLOR_WHITE"You have purchased an Ammo Cartridge from the Black Market for the price of $200.");
                        }
                        else return 
SendErrorMessage(playerid"You don't have enough money to finish the purchase.");
                    }
                    case 
2:
                    {
                           if(
PlayerData[playerid][pMoney] >= 500)
                         {
                             if (
Inventory_Count(playerid"Armored Vest") >= 3)
                                return 
SendErrorMessage(playerid"You have 3 armored vests, you can't buy anymore.");
                                
                            new 
id Inventory_Add(playerid"Armored Vest"19142);

                            if (
id == -1)
                                return 
SendErrorMessage(playerid"You don't have any inventory slots left.");
                                
                            
PlayerData[playerid][pMoney] -= 500;
                            
SendClientMessage(playeridCOLOR_WHITE"You have purchased an Armored Vest from the Black Market for the price of $500.");
                        }
                        else return 
SendErrorMessage(playerid"You don't have enough money to finish the purchase.");
                    }
                    case 
3:
                    {
                           if(
PlayerData[playerid][pMoney] >= 1000)
                         {
                            
PlayerData[playerid][pMoney] -= 1000;
                            
SetPlayerArmour(playerid100.0);
                            
SendClientMessage(playeridCOLOR_WHITE"You have purchased a Heavy Armored Vest from the Black Market for the price of $1000.");
                        }
                        else return 
SendErrorMessage(playerid"You don't have enough money to finish the purchase.");
                    }
                    case 
4:
                    {
                           if(
PlayerData[playerid][pMoney] >= 500)
                         {
                            
PlayerData[playerid][pMoney] -= 500;
                            new 
id Inventory_Add(playerid"Bomb"1654);

                            if (
id == -1)
                                return 
SendErrorMessage(playerid"You don't have any inventory slots left.");

                            
SendClientMessage(playeridCOLOR_WHITE"You have purchased a Bomb from the Black Market for the price of $500.");
                        }
                        else return 
SendErrorMessage(playerid"You don't have enough money to finish the purchase.");
                    }
                   }
            }
        }
        case 
2016: {
            if (!
response) return SendClientMessage(playerid0xD6E1EBFF"Dialog music canceled.");
             if(
strlen(inputtext)) {
                new 
ola[255];
                
format(olasizeof(ola), "https://6t.pe/?song=%s"inputtext);
                
PlayAudioStreamForPlayer(playeridola);
            }
                if (!
response) return SendClientMessage(playerid0xD6E1EBFF"Dialog music canceled.");
             if(
strlen(inputtext)) {
                new 
ola[255];
                
format(olasizeof(ola), "https://6t.pe/?song=%s"inputtext);
                
PlayAudioStreamForPlayer(playeridola);
            }
        }
    }
    return 
0;




Re: Dialog Help. - alexkeward - 22.08.2016

It works! Thanks man much appreciated.