SA-MP Forums Archive
How to keep the dialog after buying weap. - 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: How to keep the dialog after buying weap. (/showthread.php?tid=638958)



How to keep the dialog after buying weap. - Rohit12 - 09.08.2017

Hey in my weapon shop script, im not able to keep the dialog after purchasing the weapon.
If i select buy,then automatically it goes n i have to reuse the cmd to open the dialog. There must be some lines to make it reappear even after the purchase unless we press ESC or cancel.
Please Help


Re: How to keep the dialog after buying weap. - Toroi - 09.08.2017

Make it show again when they click the 'buy' button.


Re: How to keep the dialog after buying weap. - BiosMarcel - 09.08.2017

Like Toroi said,an option would be, to just show it again.

But you might aswell not use a dialog instead, because that is usually now, what you'd expect a dialog to do.
Another option would be using textdraws or combining a menu with dialogs for each buy action.


Re: How to keep the dialog after buying weap. - MiyuUchiha - 09.08.2017

Код:
if(dialogid == [dialog id])
{
   if(response)
   {
      //do things 
      ShowPlayerDialog(playerid, [dialog id], [dialog style]..... -> and more)
   }
}



Re: How to keep the dialog after buying weap. - Rohit12 - 09.08.2017

Quote:
Originally Posted by MiyuUchiha
Посмотреть сообщение
Код:
if(dialogid == [dialog id])
{
   if(response)
   {
      //do things 
      ShowPlayerDialog(playerid, [dialog id], [dialog style]..... -> and more)
   }
}
Well please tell me where to add this since I also have switch(listitem) in my code im not pretty familiar with this!

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/shop", cmdtext, true, 10) == 0)
	{
	 ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "WoF - Weapon Shop",
	 	"Pistol						{FF8000}2000$\n\
		 Silenced Pistol					{FF8000}3000$\n\
		 Desert Eagle					{FF8000}4500$\n\
		 Shotgun					{FF8000}3000$\n\
		 Sawnn-off Shotgun				{FF8000}7000$\n\
		 Combat Shotgun				{FF8000}6500$\n\
		 MP5						{FF8000}4000$\n\
		 Tec-9						{FF8000}5000$\n\
		 AK-47						{FF8000}6000$\n\
		 M4						{FF8000}6500$\n\
		 Armour						{FF8000}12000$\n\
		 Health						{FF8000}10000$\n\
		 Grenade					{FF8000}5000$",
		 "Buy","Cancel");
	 return 1;
	}
 	return 0;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
		if(dialogid ==2 && response)
		{
		        switch(listitem)
		        {
		            case 0:
		            {
                  ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "WoF - Weapon Shop",
	 	"Pistol						{FF8000}2000$\n\
		 Silenced Pistol					{FF8000}3000$\n\
		 Desert Eagle					{FF8000}4500$\n\
		 Shotgun					{FF8000}3000$\n\
		 Sawnn-off Shotgun			{FF8000}7000$\n\
		 Combat Shotgun						{FF8000}6500$\n\
		 MP5						{FF8000}4000$\n\
		 Tec-9						{FF8000}5000$\n\
		 AK-47						{FF8000}6000$\n\
		 M4							{FF8000}6500$\n\
		 Armour						{FF8000}12000$\n\
		 Health						{FF8000}10000$\n\
		 Grenade						{FF8000}5000$",
		 "Buy","Cancel");
              		}
			  }
  		}
  		if(dialogid == 1 && response)
  		{
  		        switch(listitem)
  		        {
  		                case 0:
  		                {
  		                if(GetPlayerMoney(playerid) < 2000) return SendClientMessage(playerid, COLOR_RED, "{FF0000}You don't have enough cash.");
 	        			GivePlayerMoney(playerid, -2000);
  		                GivePlayerWeapon(playerid, 22, 200); return SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have purchased {FFFFFF}Pistol!");
  		                }
  		                case 1:.
...
...
...

                    	{



Re: How to keep the dialog after buying weap. - Rohit12 - 14.08.2017

Please , i want the dialog to remain as it is after buying a weap or double clicking an option!


Respuesta: Re: How to keep the dialog after buying weap. - Miguelch1312 - 18.08.2017

Quote:
Originally Posted by Rohit12
Посмотреть сообщение
Please , i want the dialog to remain as it is after buying a weap or double clicking an option!
I recommend you to do this for showing the dialog:
Код:
WeaponDialog(playerid)
{
 ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "WoF - Weapon Shop",
 	"Pistol						{FF8000}2000$\n\
	 Silenced Pistol					{FF8000}3000$\n\
	 Desert Eagle					{FF8000}4500$\n\
	 Shotgun					{FF8000}3000$\n\
	 Sawnn-off Shotgun				{FF8000}7000$\n\
	 Combat Shotgun				{FF8000}6500$\n\
	 MP5						{FF8000}4000$\n\
	 Tec-9						{FF8000}5000$\n\
	 AK-47						{FF8000}6000$\n\
	 M4						{FF8000}6500$\n\
	 Armour						{FF8000}12000$\n\
	 Health						{FF8000}10000$\n\
	 Grenade					{FF8000}5000$",
	 "Buy","Cancel");
 return 1;
}
So, you now can show the dialog now using only "WeaponDialog(playerid);"
And in your command you can do this:


Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/shop", cmdtext, true, 10) == 0)
	{
         WeaponDialog(playerid);
	}
 	return 0;
}
[WeaponDialog(playerid);] -> This just show you the dialog that we made
And for the dialog response:


Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
		if(dialogid ==2 && response)
		{
		        switch(listitem)
		        {
		            case 0:
		            {
			        WeaponDialog(playerid);
              		    }
			  }
  		}
  		if(dialogid == 1 && response)
  		{
  		        switch(listitem)
  		        {
  		                case 0:
  		                {
  		                if(GetPlayerMoney(playerid) < 2000) return SendClientMessage(playerid, COLOR_RED, "{FF0000}You don't have enough cash.");
 	        			GivePlayerMoney(playerid, -2000);
  		                GivePlayerWeapon(playerid, 22, 200); return SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have purchased {FFFFFF}Pistol!");
  		                WeaponDialog(playerid);
  		                }
  		                case 1:.
  		                {
  		                //The action goes here
                                WeaponDialog(playerid);
                    	        }
So if you know, the "WeaponDialog(playerid);" action is here, so, you can buy the weapon and the dialog will appear another time, and put "WeaponDialog(playerid);" in all the cases, like in case 0, and you have made it, and this can reduce your script code, If you need more help say what you need


Re: Respuesta: Re: How to keep the dialog after buying weap. - Rohit12 - 25.08.2017

Quote:
Originally Posted by Miguelch1312
Посмотреть сообщение
I recommend you to do this for showing the dialog:
Код:
WeaponDialog(playerid)
{
 ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "WoF - Weapon Shop",
 	"Pistol						{FF8000}2000$\n\
	 Silenced Pistol					{FF8000}3000$\n\
	 Desert Eagle					{FF8000}4500$\n\
	 Shotgun					{FF8000}3000$\n\
	 Sawnn-off Shotgun				{FF8000}7000$\n\
	 Combat Shotgun				{FF8000}6500$\n\
	 MP5						{FF8000}4000$\n\
	 Tec-9						{FF8000}5000$\n\
	 AK-47						{FF8000}6000$\n\
	 M4						{FF8000}6500$\n\
	 Armour						{FF8000}12000$\n\
	 Health						{FF8000}10000$\n\
	 Grenade					{FF8000}5000$",
	 "Buy","Cancel");
 return 1;
}
So, you now can show the dialog now using only "WeaponDialog(playerid);"
And in your command you can do this:


Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/shop", cmdtext, true, 10) == 0)
	{
         WeaponDialog(playerid);
	}
 	return 0;
}
[WeaponDialog(playerid);] -> This just show you the dialog that we made
And for the dialog response:


Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
		if(dialogid ==2 && response)
		{
		        switch(listitem)
		        {
		            case 0:
		            {
			        WeaponDialog(playerid);
              		    }
			  }
  		}
  		if(dialogid == 1 && response)
  		{
  		        switch(listitem)
  		        {
  		                case 0:
  		                {
  		                if(GetPlayerMoney(playerid) < 2000) return SendClientMessage(playerid, COLOR_RED, "{FF0000}You don't have enough cash.");
 	        			GivePlayerMoney(playerid, -2000);
  		                GivePlayerWeapon(playerid, 22, 200); return SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have purchased {FFFFFF}Pistol!");
  		                WeaponDialog(playerid);
  		                }
  		                case 1:.
  		                {
  		                //The action goes here
                                WeaponDialog(playerid);
                    	        }
So if you know, the "WeaponDialog(playerid);" action is here, so, you can buy the weapon and the dialog will appear another time, and put "WeaponDialog(playerid);" in all the cases, like in case 0, and you have made it, and this can reduce your script code, If you need more help say what you need
Well i tried it but it didn't work. I also tried without making it [ WeaponDialog(playerid); ]
Both didn't work. I understood that when we add that line in dialog response, it gives the player a weapon, it also gives him the dialog back. Thats what supposed to come if we add ShowPlayerDialog to the cases. But I don't know why it isn't working in mine. Someone please help me out

Rohit


Respuesta: Re: Respuesta: Re: How to keep the dialog after buying weap. - Miguelch1312 - 26.08.2017

Quote:
Originally Posted by Rohit12
Посмотреть сообщение
Well i tried it but it didn't work. I also tried without making it [ WeaponDialog(playerid); ]
Both didn't work. I understood that when we add that line in dialog response, it gives the player a weapon, it also gives him the dialog back. Thats what supposed to come if we add ShowPlayerDialog to the cases. But I don't know why it isn't working in mine. Someone please help me out

Rohit
Why you don't try removing the "&& response" ?


Re: Respuesta: Re: Respuesta: Re: How to keep the dialog after buying weap. - Rohit12 - 26.08.2017

Quote:
Originally Posted by Miguelch1312
Посмотреть сообщение
Why you don't try removing the "&& response" ?
I tried it , but didn't work so I changed to another shop dialog. And still this problem exist. Please check my post above.