OnDialogResponse - something wrong.
#1

Hi there.
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
  if(dialogid == 555)
  {
    if (!strcmp(inputtext, amount[playerid]))
    {
        SetPlayerChatBubble(npcid,"Thank you, Sir! Enjoy your drink.",0xFFFFFFAA,20,4000);
		SetPlayerSpecialAction(playerid,SPECIAL_ACTION_DRINK_BEER);
		return 1;
	}
  }
  return 0;
}
The amount[playerid] is ALWAYS a digit, for example 7. Why is this not working?
Reply
#2

You are comparing string to integer.
Try:
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
  if(dialogid == 555)
  {
    new beer;
    if(strlen(inputtext) < 2)
    {
      beer = strval(inputtext);
      if (beer == amount[playerid])
      {
        SetPlayerChatBubble(npcid,"Thank you, Sir! Enjoy your drink.",0xFFFFFFAA,20,4000);
        SetPlayerSpecialAction(playerid,SPECIAL_ACTION_DRINK_BEER);
        return 1;
      }  
    }
  }
  return 0;
}
Reply
#3

Thanks man, although I get a error:

Код:
error 029: invalid expression, assumed zero
at this line:

Код:
if(beer == amount[playerid]))
//EDIT: Ah nevermind, there was one ) too much. Thank you!
Reply
#4

Quote:
Originally Posted by Mo3
Код:
if(beer == amount[playerid]))
Should be:
Код:
if(beer == amount[playerid])
Reply
#5

Not working this way - nothing happens.
Reply
#6

What are you typing in the dialog box?
Reply
#7

For example "8".
Reply
#8

Nevermind Iґve used the wrong dialog ID

Thank you all.
Reply
#9


Should be:
Код:
if(beer == amount[playerid])
[/quote]
I changed this to:

if (beer == amount(playerid)) It made the error go away, I'm not sure if it works.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)