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



Dialog help :D - Kruno88 - 18.06.2015

Код:
	if (newkeys & KEY_WALK)
	{
	new M4A1[32], AssaultAmmoEquiped[32],total[64];

	if(PlayerInfo[playerid][pM4A1] > 0)
	{
	format(M4A1, sizeof(M4A1), "M4A1: %d", PlayerInfo[playerid][pM4A1]);
	}
	if(PlayerInfo[playerid][pAssaultAmmoEquiped] > 0)
	{
	format(AssaultAmmoEquiped, sizeof(AssaultAmmoEquiped), "(%d)", PlayerInfo[playerid][pAssaultAmmoEquiped]);
	}
	format(total, sizeof(total), "%s %s", M4A1,  AssaultAmmoEquiped);
	ShowPlayerDialog(playerid, DIALOG_INVENTORY, DIALOG_STYLE_LIST, "Inventory", total, "Select", "Cancel");
        return 1;
	}
	if (newkeys & KEY_CROUCH)
	{
		if(IsValidObject(LootObjects[0]) && IsPlayerInRangeOfPoint(playerid,2.0,2384.59448,-1674.36279,13.74557))
		{
	       	PlayerInfo[playerid][pM4A1] ++;
        	SendClientMessage(playerid, COLOR_GREEN, "* 1 M4A1 has been added to your inventory");
        	DestroyObject(LootObjects[0]);
        }
 	}
My script.This is my invetory script,there are ofcourse more items than M4A1.When I have,for example,Medkit,M4A1,blood bag.And M4A1 is on the 2rd slot of the dialog.How do I detect if the player cliked on M4A1 and not Medkit.Because M4A1 can be on any place(like 3rd or 1rst) and I can't just pre-set it.


Re: Dialog help :D - Lajko1 - 18.06.2015

Well you can use listitem function at that callback..

pawn Код:
switch(listitem)
{
    case 0:
        {
         // abc
    }
}
Or I think you could use smth like that.. but I'm not so sure about that try it ^^

pawn Код:
if(listitem = M4A1)



Re: Dialog help :D - AndySedeyn - 18.06.2015

Quote:
Originally Posted by Lajko1
Посмотреть сообщение
Well you can use listitem function at that callback..

pawn Код:
switch(listitem)
{
    case 0:
        {
         // abc
    }
}
Or I think you could use smth like that.. but I'm not so sure about that try it ^^

pawn Код:
if(listitem = M4A1)
That's correct. Rather than doing case 0, you can use case M4A1 if and only if M4A1 is defined as an integer. But in case of his code, it is not possible to do so.

PHP код:
#define M4A1    31
switch(listitem)
{
    case 
M4A1:
    {
    }

To answer the thread creator's question. In case of your dialog, the M4A1 is shown as the only item. Thus, there can only be one case and that's zero.

PHP код:
case 0



Re: Dialog help :D - nezo2001 - 18.06.2015

The easier way to do is case
PHP код:
switch(listitem)
{
    case 
0//Item 1
    
{
        
//Your Code
    
}
    case 
1//Item 2
    
{
        
//Your Code
    
}
    
//etc. 



Re: Dialog help :D - Kruno88 - 18.06.2015

Non of this helps -_- only Andy understud me.But how can I define them as integer.And M4A1 is not the only item.There are more,as I said.


Re: Dialog help :D - Lajko1 - 18.06.2015

Well we didn't understand ... than tell us what's up, you want to store M4A1 in inventory? Where's the problem, when you're taking it out?


Re: Dialog help :D - Ritzy2K - 18.06.2015

Hello!
you can try
pawn Код:
if(listitem == pM4A1)



Re: Dialog help :D - AndySedeyn - 18.06.2015

Quote:
Originally Posted by [ND]xXZeusXx.
Посмотреть сообщение
Hello!
you can try
pawn Код:
if(listitem == pM4A1)
Where are you getting 'pM4A1' from? If you could elaborate more on the actual problem and perhaps show us some more of your code, because I have troubles understanding what you are trying to do.


Re: Dialog help :D - Kruno88 - 19.06.2015

Nvm.Solved.