02.05.2013, 23:44
Okay, i have really big problem with buying dialog. When i click 'cancel' button it have the same function like 'select' button, so when i try to close this dialog it buys a item. How to fix that? My code:
OnDialogResponse:
CMD:buy
OnDialogResponse:
pawn Код:
if(dialogid == 40)
{
if(!response)
{
}
switch(listitem)
{
case 0:
{
new string[128];
if(server_GetCash(playerid) >= 5)
{
SendClientMessage(playerid, COLOR_WHITE, "You've purchased a sprunk!");
server_GiveCash(playerid, -5);
PlayerInfo[playerid][pSprunk]= PlayerInfo[playerid][pSprunk]+1;
GameTextForPlayer(playerid, "~r~$-5", 1000,1);
format(string, sizeof(string), "* %s has bought a sprunk for $5.", GetName(playerid));
ProxDetector(10.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
else
{
SendClientMessage(playerid, COLOR_RED, "Not enough money!");
}
}
pawn Код:
CMD:buy(playerid, params[])
{
if(IsPlayerInRangeOfPoint(playerid, 5, -27.6207,-89.9443,1003.5469))
{
ShowPlayerDialog(playerid, 40, DIALOG_STYLE_LIST, "General Store Items", "Sprunk - $5\nRope - $20\nFirst Aid Kit - $65\nBaseball Bat - $200\nFlowers - $25\nPacket of Cigars - $25", "Select", "Cancel");
}
return 1;
}