remove variable with input dialog.
#1

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	new string[128];
	if(dialogid == DIALOG_SHOP)
	{
	    if(!response)
	    {
	        SendClientMessage(playerid, -1, "Thank you for visiting the store!");
  	    }
		else
		{
		    switch(listitem)
		    {
				case 0:
				{
				    ShowPlayerDialog(playerid, DIALOG_SELLGOLD, DIALOG_STYLE_INPUT, "Sell your gold:","Enter amount:", "OK", "CANCEL");
				}
				case 1:
				{
					ShowPlayerDialog(playerid, DIALOG_SELLIRON, DIALOG_STYLE_INPUT, "Sell your gold:","Enter amount:", "OK", "CANCEL");
				}
		    }
		}
		return 1;
	}
	if(dialogid == DIALOG_SELLGOLD)
	{
 		if(!response)
	    {
	        SendClientMessage(playerid, -1, "Thank you for visiting the store!");
  	    }
  	    else
  	    {
  	        //if(gold[playerid]<inputtext[DIALOG_SELLGOLD]) return SendClientMessage(playerid, -1, "You dont have that much gold!");
			gold[playerid] -= inputtext[2];
			format(string, sizeof(string),"You sold %i gold for %i", inputtext[2],gold[playerid]*2500);
			SendClientMessage(playerid, -1, string);
		}
	}
	if(dialogid == DIALOG_SELLIRON)
	{
 		if(!response)
	    {
	        SendClientMessage(playerid, -1, "Thank you for visiting the store!");
  	    }
  	    else
  	    {
  	        if(inputtext[playerid] > gold[playerid]) return SendClientMessage(playerid, -1, "You dont have that much iron!");
			gold[playerid] -= inputtext[playerid];
			format(string, sizeof(string),"You sold %i iron for %i", inputtext[playerid],gold[playerid]*500);
			SendClientMessage(playerid, -1, string);
		}
	}
	return 0;
}
and it minus' nothing from my gold, nor does it send the message.

Im lost
Reply
#2

inputtext[DIALOG_SELLGOLD]
No no no, inputtext is an array of characters, if I send the amount of 12345 in your dialog, inputtext[0] = 1, inputtext[1] = 2, ..., inputtext[5] is not valid. You would want to replace that inputtext[DIALOG_SELLGOLD] with strval(inputtext). Same applies to inputtext[2], it has to be replaced with strval(inputtext).

Make the same modifications to sell iron too.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)