how to do this?
#1

Well, I happen to have this function:

Код:
stock MostrarInventario(playerid)
{
	new name_item[1024];
	format(name_item, sizeof(name_item), "{ECEE89}Item\t{ECEE89}Cantidad\t{ECEE89}Peso de item {FFFFFF}(KG)\n");
	for(new i = 0; i < MAX_ITEMS; i++)
	{
		if(pInfo[playerid][jItem][i] > 0)
		{
			new Float:peso = PesoItem(i);
			format(name_item, sizeof(name_item), "%s%s\t%i\t%.2f\n", name_item, ItemName[i], pInfo[playerid][jItem][i], peso);
			pInfo[playerid][jItemDispoible][i] = true;
		}
		else pInfo[playerid][jItemDispoible][i] = false;
	}
	SPD(playerid, DG_INVENTARIO_1, DIALOG_STYLE_TABLIST_HEADERS, "{54FF52}Inventario", name_item, "Aceptar", "Salir");
	return true;
}
The question is this: suppose there are 20 items, then the function does is check whether the user has items available then show up in inventory, problem or question for me is like for example, if the user has no items the id 0 to 18 but 19 yes.., I would like to detect it in the callback OnDialogResponse with the variable "pInfo[playerid][jItemDispoible][i]"? in this case, the item 19.., thanks
Reply
#2

Код:
if(pInfo[playerid][jItem][i] > 0)
{
	new Float:peso = PesoItem(i);
	format(name_item, sizeof(name_item), "%s%s\t%i\t%.2f\n", name_item, ItemName[i], pInfo[playerid][jItem][i], peso);
	pInfo[playerid][jItemDispoible][i] = true;
}
else
{
	pInfo[playerid][jItemDispoible][i] = false;
}
If I understood correctly, this means that you are setting so that if there is an item on spot pInfo[playerid][jItem][i], you will set itse Dispoible to true, which means that there is an item on spot "i". However if not, it will set it to false. Basically you are already doing what you are intending to do just on another place (if I understood what you meant by your question). So simply create a for-loop in OnDialogResponse just like you have created here and run through the items something similar to this:
Код:
for(new x = 0; x < MAX_ITEMS; x++) 
{
	if (pInfo[playerid][jItemDispoible][x]) // true
	{
		// do something as the item exists
	}
	else // false
	{
		// do something as the item doesn't exist
	}
}
Sorry if this wasn't helpful or if this didn't answer your question - in that case I must have misunderstood your intentions.
Reply
#3

There are various ways of doing that, one easy way is putting the index in the list's text, when a player clicks on one, get the number returned with inputtext (split the text).
Reply
#4

The next time you make a thread in the Scripting Help section, please choose an appropriate title.

Information: https://sampforum.blast.hk/showthread.php?tid=574725
Reply
#5

#Hansrutger.

thanks for the support, but not what I want.

#SickAttack.

Thanks for the idea, man.

Код:
buscar_item(playerid, string[])
{
	if(!strcmp(string, ItemName[ITEM_GANZUA])) return SCM(playerid, -1, "Item ganzъa.");
	if(!strcmp(string, ItemName[ITEM_MANZANA])) return SCM(playerid, -1, "Item manzana.");
	SCM(playerid, -1, "Not found.");
	return true;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
    	case DG_INVENTARIO_1:
    	{
    		if(!response) return true;
    		buscar_item(playerid, inputtext);
    	}
    }
    return true;
}
#Abagail

If you're going to comment stupid things in my publications, you better go to sleep.
Reply
#6

Quote:
Originally Posted by LatinZ
Посмотреть сообщение
#Hansrutger.

thanks for the support, but not what I want.

#SickAttack.

Thanks for the idea, man.

Код:
buscar_item(playerid, string[])
{
	if(!strcmp(string, ItemName[ITEM_GANZUA])) return SCM(playerid, -1, "Item ganzъa.");
	if(!strcmp(string, ItemName[ITEM_MANZANA])) return SCM(playerid, -1, "Item manzana.");
	SCM(playerid, -1, "Not found.");
	return true;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
    	case DG_INVENTARIO_1:
    	{
    		if(!response) return true;
    		buscar_item(playerid, inputtext);
    	}
    }
    return true;
}
#Abagail

If you're going to comment stupid things in my publications, you better go to sleep.
I hope you were joking? Please don't be rude enough to call someone stupid, when you yourself have done the stupid and not followed the rules, at this time you are the one in the wrong. Please do not attack people who are willing enough to spend there time helping you.

Abagail is a huge part of this community, and should be treated with the respect they deserve.
Reply
#7

Quote:
Originally Posted by azzerking
Посмотреть сообщение
I hope you were joking? Please don't be rude enough to call someone stupid, when you yourself have done the stupid and not followed the rules, at this time you are the one in the wrong. Please do not attack people who are willing enough to spend there time helping you.

Abagail is a huge part of this community, and should be treated with the respect they deserve.
The title of this thread is more than appropriate (acceptable), though.
Reply
#8

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
The title of this thread is more than appropriate (acceptable), though.
Nope, it's too general. It is against the rules. It's not monitored much, but it is a rule.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)