SA-MP Forums Archive
[solved]Whats wrong with my dialog? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [solved]Whats wrong with my dialog? (/showthread.php?tid=134357)



[solved]Whats wrong with my dialog? - ruckfules99 - 16.03.2010

Whats wrong with my dialog box? When i press cancel, it buy's the first thing in the list and then closes the dialog instead of just closeing it...




heres part of it:


Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == STORE_DIALOG)
{
if(response)//If player pressed not cancel
{
ShowPlayerDialog(playerid,STORE_DIALOG,DIALOG_STYLE_LIST,"24/7 STORE","Chainsaw ($1500)\nFlowers ($5)\nBaseball bat ($100)\nBeer ($20)\nWallet ($1000)\nParachute($500)\nCork($1000)","Choose","Cancel");
}
if(listitem == 0)
{
if(GetPlayerMoney(playerid) <= 1499) {
SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase Failed_|");
SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to buy a Chainsaw ($1500)");
return 1;
}
GivePlayerMoney(playerid,-1500);
SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase_|");
SendClientMessage(playerid, 0x00C7FFAA, "You have bought a Chainsaw. You were charged $1500");
GivePlayerWeapon(playerid,9,1);
return 1;
}



Re: Whats wrong with my dialog? - Torran - 16.03.2010

Because all you have for response is ShowPlayerDialog,
You ended if(response) before you put anything else in


Re: Whats wrong with my dialog? - ruckfules99 - 17.03.2010

Quote:
Originally Posted by Joe Torran C
Because all you have for response is ShowPlayerDialog,
You ended if(response) before you put anything else in
So can you, or someone explain to me what exactly to do


Re: Whats wrong with my dialog? - differo - 17.03.2010

try this ...
pawn Код:
if(dialogid == STORE_DIALOG)
{
if(response == 0)
{
ShowPlayerDialog(playerid,STORE_DIALOG,DIALOG_STYLE_LIST,"24/7 STORE","Chainsaw ($1500)\nFlowers ($5)\nBaseball bat ($100)\nBeer ($20)\nWallet ($1000)\nParachute($500)\nCork($1000)","Choose","Cancel");
}
if(response)
{
if(listitem == 0)
{
if(GetPlayerMoney(playerid) <= 1499) {
SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase Failed_|");
SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to buy a Chainsaw ($1500)");
return 1;
}
GivePlayerMoney(playerid,-1500);
SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase_|");
SendClientMessage(playerid, 0x00C7FFAA, "You have bought a Chainsaw. You were charged $1500");
GivePlayerWeapon(playerid,9,1);
return 1;
}
}
return 1;
}



Re: Whats wrong with my dialog? - ruckfules99 - 17.03.2010

Quote:
Originally Posted by Teneckz
try this ...
pawn Код:
if(dialogid == STORE_DIALOG)
{
if(response == 0)
{
ShowPlayerDialog(playerid,STORE_DIALOG,DIALOG_STYLE_LIST,"24/7 STORE","Chainsaw ($1500)\nFlowers ($5)\nBaseball bat ($100)\nBeer ($20)\nWallet ($1000)\nParachute($500)\nCork($1000)","Choose","Cancel");
}
if(response)
{
if(listitem == 0)
{
if(GetPlayerMoney(playerid) <= 1499) {
SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase Failed_|");
SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to buy a Chainsaw ($1500)");
return 1;
}
GivePlayerMoney(playerid,-1500);
SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase_|");
SendClientMessage(playerid, 0x00C7FFAA, "You have bought a Chainsaw. You were charged $1500");
GivePlayerWeapon(playerid,9,1);
return 1;
}
}
return 1;
}
That didn't fix it, That just made it so if I press "cancel" it doesn't close the dialog.


I need it so if i press cancel, it closes the dialog. But when i press cancel with my normal code it says "cannot afford to buy a chainsaw"





Re: Whats wrong with my dialog? - differo - 17.03.2010

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == STORE_DIALOG)
{
if(response)//If player pressed not cancel
{
ShowPlayerDialog(playerid,STORE_DIALOG,DIALOG_STYLE_LIST,"24/7 STORE","Chainsaw ($1500)\nFlowers ($5)\nBaseball bat ($100)\nBeer ($20)\nWallet ($1000)\nParachute($500)\nCork($1000)","Choose","Cancel");
}
if(listitem == 0)
{
if(GetPlayerMoney(playerid) <= 1499) {
SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase Failed_|");
SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to buy a Chainsaw ($1500)");
return 1;
}
else
{
GivePlayerMoney(playerid,-1500);
SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase_|");
SendClientMessage(playerid, 0x00C7FFAA, "You have bought a Chainsaw. You were charged $1500");
GivePlayerWeapon(playerid,9,1);
return 1;
}
}
return 1;
}



Re: Whats wrong with my dialog? - ruckfules99 - 17.03.2010

It still does what it's not suppose to.



I press cancel on the dialog, It closes but it buys the first item in my menu


Re: Whats wrong with my dialog? - ruckfules99 - 17.03.2010

Quote:
Originally Posted by Joe Torran C
Because all you have for response is ShowPlayerDialog,
You ended if(response) before you put anything else in

I finally figured out what you ment lol Omg im slow.


[solved]