Dialog Help [+REP]
#1

Код:
CMD:sellfish(playerid, params[])
{
	new
	id = -1,
	fish[5],
	string[128];
	
	if ((id = Business_Inside(playerid)) != -1)
	{
		if (BusinessData[id][bizLocked] != 0 || !BusinessData[id][bizOwner])
		return SendErrorMessage(playerid, "This business is closed!");

		if (BusinessData[id][bizType] == 8)
		{
			switch(PlayerData[playerid][pFish1])
  			{
    			case 0: fish[0] = strval("None");
			    case 1: fish[0] = strval("Carp");
			    case 2: fish[0] = strval("Cod");
			    case 3: fish[0] = strval("Mackrel");
			}
			switch(PlayerData[playerid][pFish2])
		    {
			    case 0: fish[1] = strval("None");
			    case 1: fish[1] = strval("Carp");
			    case 2: fish[1] = strval("Cod");
			    case 3: fish[1] = strval("Mackrel");
			}
			switch(PlayerData[playerid][pFish3])
		    {
			    case 0: fish[2] = strval("None");
			    case 1: fish[2] = strval("Carp");
			    case 2: fish[2] = strval("Cod");
			    case 3: fish[2] = strval("Mackrel");
			}
			switch(PlayerData[playerid][pFish4])
		    {
			    case 0: fish[3] = strval("None");
			    case 1: fish[3] = strval("Carp");
			    case 2: fish[3] = strval("Cod");
			    case 3: fish[3] = strval("Mackrel");
			}
			switch(PlayerData[playerid][pFish5])
		    {
			    case 0: fish[4] = strval("None");
			    case 1: fish[4] = strval("Carp");
			    case 2: fish[4] = strval("Cod");
			    case 3: fish[4] = strval("Mackrel");
			}

			format(string, sizeof(string), "%s\n%s\n%s\n%s\n%s",
			fish[0],
			fish[1],
			fish[2],
			fish[3],
			fish[4]);
			Dialog_Show(playerid, SellFish, DIALOG_STYLE_LIST, "Sell Your Fish", string, "Purchase", "Cancel");
		}
		else
		{
		    SendErrorMessage(playerid, "You are not in a fish market to sell your fishes.");
		}
	}
	else
	{
		SendErrorMessage(playerid, "You are not in a fish market to sell your fishes.");
	}
	return 1;
}
Код:
Dialog:SellFish(playerid, response, listitem, inputtext[])
{
	static
	bizid = -1;
    if((bizid = Business_Inside(playerid)) != -1 && response)
    {
		if (BusinessData[bizid][bizType] == 8)
		{
			switch (listitem)
		    {
		        case 0:
		        {
		            switch(PlayerData[playerid][pFish1])
	       			{
	 		    		case 0:{
						SendErrorMessage(playerid, "You don't have any fishes on this solt.");
	     				}
				    	case 1:{
					 	GiveMoney(playerid, 20);
					 	SendErrorMessage(playerid, "You have sold your Carp for 20$.");
	      				}
				    	case 2:{
						GiveMoney(playerid, 25);
						SendErrorMessage(playerid, "You have sold your Cod for 25$.");
	     				}
				    	case 3:{
						GiveMoney(playerid, 35);
						SendErrorMessage(playerid, "You have sold your Mackrel for 35$.");
					 	}
					}
		        }
		        case 1:
		        {
		            switch(PlayerData[playerid][pFish2])
			    	{
				    	case 0:{
						SendErrorMessage(playerid, "You don't have any fishes on this solt.");
	     				}
				    	case 1:{
					 	GiveMoney(playerid, 20);
					 	SendErrorMessage(playerid, "You have sold your Carp for 20$.");
	      				}
				    	case 2:{
						GiveMoney(playerid, 25);
						SendErrorMessage(playerid, "You have sold your Cod for 25$.");
					 	}
				    	case 3:{
						GiveMoney(playerid, 35);
						SendErrorMessage(playerid, "You have sold your Mackrel for 35$.");
	    				}
					}
		        }
		        case 2:
		        {
		            switch(PlayerData[playerid][pFish3])
			    	{
				    	case 0:{
						SendErrorMessage(playerid, "You don't have any fishes on this solt.");
					 	}
				    	case 1:{
					 	GiveMoney(playerid, 20);
					 	SendErrorMessage(playerid, "You have sold your Carp for 20$.");
	 				 	}
				    	case 2:{
						GiveMoney(playerid, 25);
						SendErrorMessage(playerid, "You have sold your Cod for 25$.");
						 }
				    	case 3:{
						GiveMoney(playerid, 35);
						SendErrorMessage(playerid, "You have sold your Mackrel for 35$.");
	    				}
					}
		        }
		        case 3:
		        {
		            switch(PlayerData[playerid][pFish4])
			    	{
				    	case 0:{
						SendErrorMessage(playerid, "You don't have any fishes on this solt.");
	    				}
				    	case 1:{
					 	GiveMoney(playerid, 20);
					 	SendErrorMessage(playerid, "You have sold your Carp for 20$.");
	     				}
				    	case 2:{
						GiveMoney(playerid, 25);
						SendErrorMessage(playerid, "You have sold your Cod for 25$.");
	    				}
				    	case 3:{
						GiveMoney(playerid, 35);
						SendErrorMessage(playerid, "You have sold your Mackrel for 35$.");
	    				}
					}
		        }
		        case 4:
		        {
		            switch(PlayerData[playerid][pFish5])
			    	{
				    	case 0:{
						SendErrorMessage(playerid, "You don't have any fishes on this solt.");
	    				}
				    	case 1:{
					 	GiveMoney(playerid, 20);
					 	SendErrorMessage(playerid, "You have sold your Carp for 20$.");
	     				}
				    	case 2:{
						GiveMoney(playerid, 25);
						SendErrorMessage(playerid, "You have sold your Cod for 25$.");
	    				}
				    	case 3:{
						GiveMoney(playerid, 35);
						SendErrorMessage(playerid, "You have sold your Mackrel for 35$.");
						}
  					}
				}
    		}
    	}
	}
	return 1;
}
So, the thing I got here is when the dialog opens its clear , nothing in and if I pressed Enter , it 'd say you have sold your carp for 20$ and it wont end.

Also while editing it. It gave me an error before.

Код:
[00:26:54] [debug] Run time error 4: "Array index out of bounds"
[00:26:54] [debug]  Accessing element at negative index -1
[00:26:54] [debug] AMX backtrace:
[00:26:54] [debug] #0 0017ac0c in public dialog_SellFish (0x00000000, 0x00000001, 0x00000000, 0x008874ac) from RLRP.amx
[00:26:54] [debug] #1 native CallLocalFunction () [00474110] from samp-server.exe
[00:26:54] [debug] #2 000029e4 in public OnDialogResponse (0x00000000, 0x00007fbc, 0x00000001, 0x00000000, 0x008874a8) from RLRP.amx
Reply
#2

You better check how to use strval. Of course you have problems with your code. Strval will give you the value from your string. And if your string got no value (like in your case) it will give some freaking stuff.
Reply
#3

Thanks bro,

I edited something on the dialog response and it worked but no texts.

and then I made the texts in normal strings and it worked full fine.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)