Dialog problem
#1

I'm kinda in trouble with my dialog right now

Код:
if(dialogid == 2211)
	{
		if(response)
		{
			new moneys = strval(inputtext);
		    //debug
			new string[40];
			format(string, 40, "%i", (0 - moneys));
			ERROR(playerid, string);
			//end of debug
   			if(moneys > GetPlayerMoney(playerid))
			{
   			 	GivePlayerMoney(playerid, (0 - moneys));
			}
			else return ERROR(playerid, "You don't have enough money");
		}
		else
		{
		    ShowActionTD(playerid);
		}
		return 1;
	}
It doesn't do anything, not even the debug. Am I doing something wrong?
Reply
#2

Make sure that dialogid 2211 is the dialog which shown to the player.
Reply
#3

Well, the dialog id is of no problem. The dialog shows up. What I'm worried about is the result. It's what's not coming out.
Reply
#4

Can you show the ShowPlayerDialog of the id 2211?
Reply
#5

Full code:

Код:
public OnPlayerClickTextDraw(playerid, Text:clickedid)
{
	if(clickedid == ActionChoice[3])
	{
		ShowPlayerDialog(playerid, 2211, DIALOG_STYLE_INPUT, "Give Cash", "Input the amount of cash to give.", "Select", "Back");
		HideActionTD(playerid);
		return 1;
	}
        return 0;
}


public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	if(dialogid == 2211)
	{
		if(response)
		{
			new moneys = strval(inputtext);
		    //debug
			new string[40];
			format(string, 40, "%i", (0 - moneys));
			ERROR(playerid, string);
			//end of debug
   			if(moneys > GetPlayerMoney(playerid))
			{
   			 	GivePlayerMoney(playerid, (0 - moneys));
			}
			else return ERROR(playerid, "You don't have enough money");
		}
		else
		{
		    ShowActionTD(playerid);
		}
		return 1;
	}
	return 0;
}

stock ERROR(playerid,msg[])
{
	new error[128];
	format(error,128,"{FF0000}[ERROR]:{FFFFFF} %s",msg);
	return SendClientMessage(playerid,-1,error);
}
Bit suspicious on
Код:
if(moneys > GetPlayerMoney(playerid))
Should the operation be > or <?
Reply
#6

Why do you use (0 - moneys)?
-moneys would do the same thing - invert the value - and look better.


Should the operation be > or <?
If you want the player's money to be greater than "moneys" then it should be

GetPlayerMoney(playerid) > moneys
OR
moneys < GetPlayerMoney(playerid)
Reply
#7

I'm using this as a filterscript. Should the return value of OnDialogResponse in my main gamemode and filterscript be 0 or 1?
Reply
#8

Always return 0 in the end of it to make sure it gets called in your filterscripts and gamemode too.
This is probably the reason why nothing's happening.
Make sure to do it like this in all of your filterscripts especially.

Example:
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
    if(dialogid == dialognameid1) {
        return 1; return 1 here to stop calling this callback in other scripts.
    }
    if(dialogid == dialognameid2) {
        return 1; return 1 here to stop calling this callback in other scripts.
    }
    return 0; // return 0 here to pass it on to other scripts
}
Quote:

Returning 0 in this callback will pass the dialog to another script in case no matching code were found in your gamemode's callback.

It is always called first in filterscripts so returning 1 there blocks other filterscripts from seeing it.

https://sampwiki.blast.hk/wiki/OnDialogResponse
Reply
#9

So, I tried debugging the OnDialogResponse code through prints. At first, they didn't show. So I tried print on a cmd, and when I used that cmd, the print worked fine. The problem could only be that OnDialogResponse isn't called.

I roamed around my main gamemode and other filterscripts I'm using, and they're return values on the callback is 0.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)