SA-MP Forums Archive
Why dialog is not working? - 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: Why dialog is not working? (/showthread.php?tid=634843)



Why dialog is not working? - akib - 27.05.2017

Hi,

In top:
Код:
enum
{
	DIALOG_UNUSED,

	DIALOG_LOGIN,
	DIALOG_REGISTER,
	DIALOG_WEAPONS
};
This is my dialog cmd:
Код:
CMD:build(playerid, params[])
{
    if(IsPlayerInRangeOfPoint(playerid, 1.0, 2795.5701,2793.7720,17.6763))
    {
        ShowPlayerDialog(playerid, DIALOG_WEAPONS, DIALOG_STYLE_LIST, "Weapons", "Knife\nBaseball Bat\nAk-47\nMP5\nGrenade\nSniper", "Build", "Cancel");
    }
	return 1;
}
This is my dialog response code:
Код:
	if(dialogid == DIALOG_WEAPONS)
		{
	  			switch(listitem)
	  			{
	  			    case 0:
	  			    {
	  			        InventoryWeapon[playerid][Knife]++;
                                        SendClientMessage(playerid,-1,"Knife Given!");
	  			    }
	  			    case 1:
	  			    {
	  			        InventoryWeapon[playerid][BaseballBat]++;
	  			    }
	  			    case 2:
	  			    {
	  			        InventoryWeapon[playerid][Ak47]++;
	  			    }
	  			    case 3:
	  			    {
	  			        InventoryWeapon[playerid][MP5]++;
	  			    }
	  			    case 4:
	  			    {
	  			        InventoryWeapon[playerid][Grenade]++;
	  			    }
	  			    case 5:
	  			    {
	  			        InventoryWeapon[playerid][Sniper]++;
	  			    }
			}
Only this dialog is showing but not giving things


Re: Why dialog is not working? - Wary - 27.05.2017

Use
PHP код:
#define DIALOG_WEAPON 1
//or something like that. 
and don't use enum


Re: Why dialog is not working? - CodeStyle175 - 27.05.2017

Wary, use enums for that, it'll auto increace numbers.
akib, you only change InventoryWeapon value, but you didn't use anywhere GivePlayerWeapon, to give weapon for player.


Re: Why dialog is not working? - akib - 27.05.2017

Quote:
Originally Posted by Wary
Посмотреть сообщение
Use
PHP код:
#define DIALOG_WEAPON 1
//or something like that. 
and don't use enum
still not working


Re: Why dialog is not working? - Deroxi - 27.05.2017

How are you giving players the actual item? From what I can see you only 'give' it to them inside the User file


Re: Why dialog is not working? - akib - 27.05.2017

Quote:
Originally Posted by CodeStyle175
Посмотреть сообщение
Wary, use enums for that, it'll auto increace numbers.
akib, you only change InventoryWeapon value, but you didn't use anywhere GivePlayerWeapon, to give weapon for player.
bro u can see my code:

Код:
if(dialogid == DIALOG_WEAPONS)
		{
	  			switch(listitem)
	  			{
	  			    case 0:
	  			    {
	  			        InventoryWeapon[playerid][Knife]++;
                                        SendClientMessage(playerid,-1,"Knife Given!");
	  			    }
	  			    case 1:
	  			    {
	  			        InventoryWeapon[playerid][BaseballBat]++;
	  			    }
	  			    case 2:
	  			    {
	  			        InventoryWeapon[playerid][Ak47]++;
	  			    }
	  			    case 3:
	  			    {
	  			        InventoryWeapon[playerid][MP5]++;
	  			    }
	  			    case 4:
	  			    {
	  			        InventoryWeapon[playerid][Grenade]++;
	  			    }
	  			    case 5:
	  			    {
	  			        InventoryWeapon[playerid][Sniper]++;
	  			    }
			}
it should give a client message when i buy knife? but it is not giving if it is not giving then how it can give weapon to player?


Re: Why dialog is not working? - adri[4]Life - 27.05.2017

Remove Params Cause You're not using it, And instead of wasting Your time on enums, Just Use defines

P.S: in enums the ID Will be generated Randomly So It can Cause a bug :P (it can Generate Same IDs For 2 Dialogs)
Код:
#define DIALOG_UNUSED 0
#define DIALOG_LOGIN 1
#define DIALOG_REGISTER 2
#define DIALOG_WEAPONS 3
And for the dialog & Cmd Use this :
Код:
CMD:build(playerid)
{
      if(!IsPlayerInRangeOfPoint(playerid, 1.0, 2795.5701,2793.7720,17.6763)) return SendClientMessage(playerid, -1, "You Cannot Use This CMD While You Are Not In Range !");
      new str[2500];
      format(str, sizeof str, "Knife\nBaseball Bat\nAk-47\nMP5\nGrenade\nSniper");      
      ShowPlayerDialog(playerid, DIALOG_WEAPONS, DIALOG_STYLE_LIST, "Weapons", str, "Build", "cancel");
      return 1;
}



Re: Why dialog is not working? - akib - 27.05.2017

Quote:
Originally Posted by adrianlouise
Посмотреть сообщение
Remove Params Cause You're not using it, And instead of wasting Your time on enums, Just Use defines

P.S: in enums the ID Will be generated Randomly So It can Cause a bug :P (it can Generate Same IDs For 2 Dialogs)
Код:
#define DIALOG_UNUSED 0
#define DIALOG_LOGIN 1
#define DIALOG_REGISTER 2
#define DIALOG_WEAPONS 3
And for the dialog & Cmd Use this :
Код:
CMD:build(playerid)
{
      if(!IsPlayerInRangeOfPoint(playerid, 1.0, 2795.5701,2793.7720,17.6763)) return SendClientMessage(playerid, -1, "You Cannot Use This CMD While You Are Not In Range !");
      new str[2500];
      format(str, sizeof str, "Knife\nBaseball Bat\nAk-47\nMP5\nGrenade\nSniper");      
      ShowPlayerDialog(playerid, DIALOG_WEAPONS, DIALOG_STYLE_LIST, "Weapons", str, "Build", "cancel");
      return 1;
}
not worked


Re: Why dialog is not working? - iLearner - 27.05.2017

Lol this dude thinks saying weapon given will actually give user weapon.

You have to give the weapon using GivePlayerWeapon.


Re: Why dialog is not working? - akib - 28.05.2017

Quote:
Originally Posted by iLearner
Посмотреть сообщение
Lol this dude thinks saying weapon given will actually give user weapon.

You have to give the weapon using GivePlayerWeapon.
Dude i think u r newbie.... i am giving weapon to their inventory but why the clientmessage no showing? -_-