OnDialogResponse responds to everything -
dusk - 28.01.2013
When i choose an item from the DIALOG_WEAPONS it writes text into the player.txt from DIALOG_REGISTER. Please help.
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_REGISTER)
{
if(response)
{
new File:players=fopen("players.txt", io_append);
fwrite(players,inputtext);
fclose(players);
}
if(response==1)
{
SendClientMessage(playerid,0xFF0000FF," nu");
}
}
if(dialogid == DIALOG_WEAPONS)
{
if(response)
{
if(listitem == 0)
{
if(money > 999)
{
GivePlayerMoney(playerid, -1000);
GivePlayerWeapon(playerid,46, 1); //Parachute
SendClientMessage(playerid, 0xFF0000FF, "You bought a parachute.");
}
else
{
SendClientMessage(playerid, 0xFF0000FF, "Insufficient funds.");
}
}
if(listitem == 1)
{
if(money > 499)
{
GivePlayerMoney(playerid, -500);
GivePlayerWeapon(playerid, 22, 120); //9mm
SendClientMessage(playerid, 0xFF0000FF, "You bought a 9mm pistol.");
}
else
{
SendClientMessage(playerid, 0xFF0000FF, "Insufficient funds.");
}
}
}
}
}
Re: OnDialogResponse responds to everything -
Scenario - 28.01.2013
It seems like under DIALOG_REGISTER you are trying to use OnDialogReponse as a variable, not a bool.
Proper usage to check for a response is:
pawn Код:
if(response == true) // can also use if(response)
OR
pawn Код:
if(response == false) // can also use if(!response)
It's also best to use a switch statement for the list items. So for example:
pawn Код:
case DIALOG_DEFINE:
{
if(response)
{
switch(listitem)
{
case 0: // same effect as if(listitem == 0)
case 1: // same effect as if(listitem == 1)
case 2: // same effect as if(listitem == 2)
case 3: // same effect as if(listitem == 3)
}
}
}
You can do the same with the dialog ID's, as well.
Re: OnDialogResponse responds to everything -
Bakr - 28.01.2013
The only problem I can see for that happening is you defined the two dialogs with the same ID.
Also note that
and
equate to the same thing.
Re: OnDialogResponse responds to everything -
dusk - 29.01.2013
Quote:
Originally Posted by RealCop228
It seems like under DIALOG_REGISTER you are trying to use OnDialogReponse as a variable, not a bool.
Proper usage to check for a response is:
pawn Код:
if(response == true) // can also use if(response)
OR
pawn Код:
if(response == false) // can also use if(!response)
It's also best to use a switch statement for the list items. So for example:
pawn Код:
case DIALOG_DEFINE: { if(response) { switch(listitem) { case 0: // same effect as if(listitem == 0) case 1: // same effect as if(listitem == 1) case 2: // same effect as if(listitem == 2) case 3: // same effect as if(listitem == 3) } } }
You can do the same with the dialog ID's, as well. 
|
If i use if(response==true) or if(response==false),i get this:
pawn Код:
warning 213: tag mismatch
Thanks for the case stuff,its really easier
Re: OnDialogResponse responds to everything -
SilverKiller - 29.01.2013
Or
Copy one of them and no more warnings.
Re: OnDialogResponse responds to everything -
dusk - 29.01.2013
Quote:
Originally Posted by SilverKiller
Or
Copy one of them and no more warnings.
|
I copied, got this:
pawn Код:
C:\Users\Justas\Desktop\TestServer\gamemodes\test3.pwn(247) : warning 213: tag mismatch
C:\Users\Justas\Desktop\TestServer\gamemodes\test3.pwn(247) : error 036: empty statement
Re: OnDialogResponse responds to everything -
SilverKiller - 29.01.2013
Then use
If your code still not working, check your dialog ID , it may be mixed up with something else.
Re: OnDialogResponse responds to everything -
dusk - 29.01.2013
Quote:
Originally Posted by SilverKiller
Then use
If your code still not working, check your dialog ID , it may be mixed up with something else.
|
Then im back to my original problem, when i choose items from DIALOG_WEAPONS it writes to my file palyers.txt
Re: OnDialogResponse responds to everything -
SilverKiller - 29.01.2013
Show us your DIALOG_REGISTER And DIALOG_WEAPONS defines.
Re: OnDialogResponse responds to everything -
YesYesYes - 29.01.2013
EDIT: didn't noticed your post correctly, as mentioned, if (response) and if(response == 1) are same thing, so problem is there,or in your Dialog id. check your #define of those ids