dialogs doesnt work.Strange server warnings or errors.
#1

Hello guys!

im trying to make everything in dialogs but it seems that it cant work properly.
  • You can always just lock house but not unlock
  • You cant take or put money
Why whats wrong?

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	switch(dialogid)
	{
		case DIALOG_HOUSE_COMMANDS:
		{
			if(response)
			{
				switch(listitem)
				{
					case 0:
					{
						for(new i = 0; i < sizeof(ApartmentInfo); i++)
						{
							if(ApartmentInfo[i][sLocked] == 0)
							{
								ShowPlayerDialog(playerid, DIALOG_HOUSE_LOCK, DIALOG_STYLE_MSGBOX, "House Lock", "Do you want to lock you house?", "Lock", "Cancel");
							}
							else if(ApartmentInfo[i][sLocked] == 1)
							{
								ShowPlayerDialog(playerid, DIALOG_HOUSE_UNLOCK, DIALOG_STYLE_MSGBOX, "House Unlock", "Do you want to unlock your house?", "Unlock", "Cancel");
							}
						}
					}
					case 1:
					{
						for(new i = 0; i < sizeof(ApartmentInfo); i++)
						{	
							new pName[MAX_PLAYER_NAME];
							GetPlayerName(playerid, pName, sizeof(pName));
							if(IsPlayerInRangeOfPoint(playerid, 10,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]) && strcmp(ApartmentInfo[i][sOwner], pName, false ) == 0)
							{
								ShowPlayerDialog(playerid, DIALOG_HOUSE_TAKE_MONEY, DIALOG_STYLE_INPUT, "House Money Storage", "How much money you want to take?", "Take", "Cancel");
							}
							else return SendClientMessage(playerid,WHITE,"Turi buti namuose!");
						}
					}
					case 2:
					{
						for(new i = 0; i < sizeof(ApartmentInfo); i++)
						{	
							new pName[MAX_PLAYER_NAME];
							GetPlayerName(playerid, pName, sizeof(pName));
							if(IsPlayerInRangeOfPoint(playerid, 10,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]) && strcmp(ApartmentInfo[i][sOwner], pName, false ) == 0)
							{
								ShowPlayerDialog(playerid, DIALOG_HOUSE_PUT_MONEY, DIALOG_STYLE_INPUT, "House Money Storage", "How much money you want to put?", "Put", "Cancel");
							}
							else return SendClientMessage(playerid,WHITE,"Turi buti namuose!");
						}
					}
					case 3:
					{
						for(new i = 0; i < sizeof(ApartmentInfo); i++)
						{	
							new pName[MAX_PLAYER_NAME];
							GetPlayerName(playerid, pName, sizeof(pName));
							if(IsPlayerInRangeOfPoint(playerid, 3,ApartmentInfo[i][sEnterx], ApartmentInfo[i][sEntery], ApartmentInfo[i][sEnterz]))
							{
								if(strcmp(ApartmentInfo[i][sOwner], pName, false ) == 0)
								{
									strmid(ApartmentInfo[i][sOwner], "State", 0, strlen("State"), 255);
									ApartmentInfo[i][sOwned] = 0;
									ApartmentInfo[i][sLocked] = 1;
									GivePlayerMoney(playerid,ApartmentInfo[i][sPrice]);
									SendClientMessage(playerid, WHITE, "Sekmingai pardavei savo buta!");
									LabelIPickup(i);
									SaugomNamus(i);
									return 1;
								}
							}
							else
							{ 
								return SendClientMessage(playerid,WHITE,"Turi buti prie namo duru!");
							}
						}
					}
					case 4:
					{	
						new string[128], islocked[4];
						for(new i = 0; i < sizeof(ApartmentInfo); i++)
						{
							new pName[MAX_PLAYER_NAME];
							GetPlayerName(playerid, pName, sizeof(pName));
							if(IsPlayerInRangeOfPoint(playerid, 10,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]) && strcmp(ApartmentInfo[i][sOwner], pName, false ) == 0)
							{
								if(ApartmentInfo[i][sLocked] == 1)
								{
									islocked = "Yes";
								}
								else if(ApartmentInfo[i][sLocked] == 0)
								{
									islocked = "No";
								}
								format(string,sizeof(string),"Money in house: %d LT\nLocked: %s",ApartmentInfo[i][sMoney],islocked);
								ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,"House Information",string,"Okay","");
							}
							else
							{
								return SendClientMessage(playerid,GREY,"Turi savo buti namuose");
							}
						}
					}
				}
			}
		}
		case DIALOG_HOUSE_LOCK:
		{
			if(response)
			{
				for(new i = 0; i < sizeof(ApartmentInfo); i++)
				{
					if(IsPlayerInRangeOfPoint(playerid, 25,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]) || IsPlayerInRangeOfPoint(playerid, 3,ApartmentInfo[i][sEnterx], ApartmentInfo[i][sEntery], ApartmentInfo[i][sEnterz]))
					{
						new pName[MAX_PLAYER_NAME];
						GetPlayerName(playerid, pName, sizeof(pName));
						if(strcmp(ApartmentInfo[i][sOwner], pName, false ) == 0)
						{
							GameTextForPlayer(playerid, "~r~Uzrakinta", 5000, 6);
							ApartmentInfo[i][sLocked] = 1;
							return 1;
						}
					}
					else return SendClientMessage(playerid, WHITE,"Turi buti prie namo!"); 
				}
			}
		}
		case DIALOG_HOUSE_UNLOCK:
		{
			if(response)
			{
				for(new i = 0; i < sizeof(ApartmentInfo); i++)
				{
					if(IsPlayerInRangeOfPoint(playerid, 25,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]) || IsPlayerInRangeOfPoint(playerid, 3,ApartmentInfo[i][sEnterx], ApartmentInfo[i][sEntery], ApartmentInfo[i][sEnterz]))
					{
						new pName[MAX_PLAYER_NAME];
						GetPlayerName(playerid, pName, sizeof(pName));
						if(strcmp(ApartmentInfo[i][sOwner], pName, false ) == 0)
						{
							GameTextForPlayer(playerid, "~r~Atrakinta", 5000, 6);
							ApartmentInfo[i][sLocked] = 0;
							return 1;
						}
					}
					else return SendClientMessage(playerid, WHITE,"Turi buti prie namo!");
				}
			}
		}
		case DIALOG_HOUSE_TAKE_MONEY:
		{
			for(new i = 0; i < sizeof(ApartmentInfo); i++)
			{
				new pName[MAX_PLAYER_NAME] , string[40];
				GetPlayerName(playerid, pName, sizeof(pName));
				if(IsPlayerInRangeOfPoint(playerid, 10,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]) && strcmp(ApartmentInfo[i][sOwner], pName, false ) == 0)
				{
					if(!IsNumeric(inputtext[10])) return ShowPlayerDialog(playerid, DIALOG_HOUSE_TAKE_MONEY, DIALOG_STYLE_INPUT, "House Money Storage", "You can only write numbers!\nHow much money you want to take?", "Take", "Cancel");
					if(ApartmentInfo[i][sMoney] < inputtext[10]) return ShowPlayerDialog(playerid, DIALOG_HOUSE_TAKE_MONEY, DIALOG_STYLE_INPUT, "House Money Storage", "You don't have that many in your house!\nHow much money you want to take?", "Take", "Cancel");
					ApartmentInfo[i][sMoney] -= inputtext[10];
					GivePlayerMoney(playerid,inputtext[10]);
					format(string, sizeof(string), "Pasiemei %d LT , dabar namuose: %d LT", inputtext[10], ApartmentInfo[i][sMoney]);
					ShowPlayerDialog(playerid,DIALOG_HOUSE_MONEY_INFO,DIALOG_STYLE_MSGBOX,"House Money Storage",string,"Okay","");
					SaugomNamus(i);
					return 1;
				}
				else return SendClientMessage(playerid,GREY,"Tu ne savo namuose!"); 
			}
		}
		case DIALOG_HOUSE_PUT_MONEY:
		{
			for(new i = 0; i < sizeof(ApartmentInfo); i++)
			{
				new pName[MAX_PLAYER_NAME] , string[40];
				GetPlayerName(playerid, pName, sizeof(pName));
				if(IsPlayerInRangeOfPoint(playerid, 10,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]) && strcmp(ApartmentInfo[i][sOwner], pName, false ) == 0)
				{
					if(!IsNumeric(inputtext[10])) return ShowPlayerDialog(playerid, DIALOG_HOUSE_PUT_MONEY, DIALOG_STYLE_INPUT, "House Money Storage", "You can only write numbers!\nHow much money you want to put?", "Put", "Cancel");
					if(GetPlayerMoney(playerid) < inputtext[10]) return ShowPlayerDialog(playerid, DIALOG_HOUSE_PUT_MONEY, DIALOG_STYLE_INPUT, "House Money Storage", "You don't have that many in your pocket!\nHow much money you want to put?", "Put", "Cancel");
					ApartmentInfo[i][sMoney] += inputtext[10];
					GivePlayerMoney(playerid,-inputtext[10]);
					format(string, sizeof(string), "Padejai %d LT , dabar namuose: %d LT", inputtext[10], ApartmentInfo[i][sMoney]);
					ShowPlayerDialog(playerid,DIALOG_HOUSE_MONEY_INFO,DIALOG_STYLE_MSGBOX,"House Money Storage",string,"Okay","");
					SaugomNamus(i);
					return 1;
				}
				else return SendClientMessage(playerid,GREY,"Tu ne savo namuose!"); 
			}
		}
	}
    return 1;
}
Код:
CMD:nkomandos(playerid, params[])
{
	ShowPlayerDialog(playerid, DIALOG_HOUSE_COMMANDS, DIALOG_STYLE_LIST, "House Commands", "Lock or Unlock\nTake Money\nPut Money\nSell House\nHouse Info", "Choose", "Cancel");
	return 1;
}
Server log:

Код:
[debug] Run time error 5: "Invalid memory access"
[17:35:10] [debug] AMX backtrace:
[17:35:10] [debug] #0 00019444 in ?? (0x00000000, 0x00000007, 0x00000001, 0xffffffff, 0x0109ab30) from rrp.amx
[17:35:10] [debug] #1 00008430 in public OnDialogResponse (0x00000000, 0x00000007, 0x00000001, 0xffffffff, 0x0109ab30) from rrp.amx
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)