Dialog Issues
#1

On a dialog, How can i detect if a player pressed "cancel" ? I want it so, if a player pressed cancel, the dialog closes (which it does) but i want a message to appear for them too. How can i do that?


This is part of my dialog:

pawn Код:
if(dialogid==WEAPONDEALER_DIALOG) {
        if(response) {
            ShowPlayerDialog(playerid,WEAPONDEALER_DIALOG,2,"Weapon Dealers List","Silenced 9mm\t\t $2500\nTec9\t\t\t $1000\nS/O Shotgun\t\t $3500\nSniper Rifle\t\t $15000\nAK47\t\t\t $8000\nArmour\t\t\t $500\n3 Blocks Of C4\t\t $3500\nParachute\t\t $10000\nM4\t\t\t $1000\nRifle\t\t\t $7000\nDesert Eagle\t\t $5000","Buy","Cancel");
Reply
#2

Quote:
Originally Posted by SA-MP Wiki
response 1 for first button and 0 for second button
Wiki helps
Reply
#3

Thanks for the quick response, but i don't understand lol.
Reply
#4

Код:
if(!response) return SendClientMessage(playerid,0xffffffaa,"Selection canceled");

ShowPlayerDialog(playerid,WEAPONDEALER_DIALOG,2,"Weapon Dealers List","Silenced 9mm\t\t $2500\nTec9\t\t\t $1000\nS/O Shotgun\t\t $3500\nSniper Rifle\t\t $15000\nAK47\t\t\t $8000\nArmour\t\t\t $500\n3 Blocks Of C4\t\t $3500\nParachute\t\t $10000\nM4\t\t\t $1000\nRifle\t\t\t $7000\nDesert Eagle\t\t $5000","Buy","Cancel");
Код:
if(!response)
checks if you clicked on the second button (which obviously has to say "Cancel")

Код:
if(response)
checks if you clicked on the first button which in this case is "Buy".

You won't need both of them together.
Reply
#5

I need both them together though....



I want it so when I press Buy, the dialog appears again. If the player presses cancel, i want it so i can make something happen
Reply
#6

if(!response){
// Make something happen (if he pressed cancel)
}else{
// If he pressed buy
}
Reply
#7

How can i do it for this?

pawn Код:
if(dialogid==WEAPONDEALER_DIALOG) {
        if(response) {
            ShowPlayerDialog(playerid,WEAPONDEALER_DIALOG,2,"Weapon Dealers List","Silenced 9mm\t\t $2500\nTec9\t\t\t $1000\nS/O Shotgun\t\t $3500\nSniper Rifle\t\t $15000\nAK47\t\t\t $8000\nArmour\t\t\t $500\n3 Blocks Of C4\t\t $3500\nParachute\t\t $10000\nM4\t\t\t $1000\nRifle\t\t\t $7000\nDesert Eagle\t\t $5000","Buy","Cancel");

            new workername[24];
            new playername[24];
            new giveplayerid;
            GetPlayerName(playerid,workername, 24);
            GetPlayerName(giveplayerid, playername, 24);
            if(listitem==0) {
            if(GetPlayerMoney(giveplayerid) <= 2499) {
                SendClientMessage(giveplayerid, 0xA9A9A9AA, "|_Weapon Sale Failed_|");
                format(szstring, sizeof(szstring), "You cannot afford a Silenced 9mm for $2500");
                SendClientMessage(giveplayerid, COLOR_ERROR, szstring);
                return 1;
            }
            GivePlayerWeapon(giveplayerid,23,100);
            GivePlayerMoney(giveplayerid, -2500);
            SendClientMessage(giveplayerid, 0xA9A9A9AA, "|_Weapon Purchased_|");
            format(szstring, sizeof(szstring), "You have bought a Silenced 9mm weapon with 100 Ammo for $2500");
            SendClientMessage(giveplayerid, 0x00C7FFAA, szstring);
        }
            if(listitem==1) {
            if(GetPlayerMoney(giveplayerid) <= 999) {
                SendClientMessage(giveplayerid, 0xA9A9A9AA, "|_Weapon Sale Failed_|");
                format(szstring, sizeof(szstring), "You cannot afford a Tec9 for $1000");
                SendClientMessage(giveplayerid, COLOR_ERROR, szstring);
                SendClientMessage(playerid, COLOR_ERROR, szstring);
                return 1;
            }
            GivePlayerWeapon(giveplayerid,32,500);
            GivePlayerMoney(giveplayerid, -1000);
            SendClientMessage(giveplayerid, 0xA9A9A9AA, "|_Weapon Purchased_|");
            format(szstring, sizeof(szstring), "You have bought a Tec9 weapon with 500 Ammo for $1000");
            SendClientMessage(giveplayerid, 0x00C7FFAA, szstring);
        }
            if(listitem==2) {
            if(GetPlayerMoney(giveplayerid) <= 3499) {
                SendClientMessage(giveplayerid, 0xA9A9A9AA, "|_Weapon Sale Failed_|");
                format(szstring, sizeof(szstring), "You cannot afford a Sawnoff Shotgun for $3500");
                SendClientMessage(giveplayerid, COLOR_ERROR, szstring);
                return 1;
            }
            GivePlayerWeapon(giveplayerid,26,30);
            GivePlayerMoney(giveplayerid, -3500);
            SendClientMessage(giveplayerid, 0xA9A9A9AA, "|_Weapon Purchased_|");
            format(szstring, sizeof(szstring), "You have bought a Sawnoff Shotgun weapon with 30 Ammo for $3500");
            SendClientMessage(giveplayerid, 0x00C7FFAA, szstring);

        }
            if(listitem==3) {
            if(GetPlayerMoney(giveplayerid) <= 14999) {
                SendClientMessage(giveplayerid, 0xA9A9A9AA, "|_Weapon Sale Failed_|");
                format(szstring, sizeof(szstring), "You cannot afford a Sniper Rifle for $15000");
                SendClientMessage(giveplayerid, COLOR_ERROR, szstring);

                return 1;
            }
            GivePlayerWeapon(giveplayerid,34,30);
            GivePlayerMoney(giveplayerid, -15000);
            SendClientMessage(giveplayerid, 0xA9A9A9AA, "|_Weapon Purchased_|");
            format(szstring, sizeof(szstring), "You have bought a Sniper Rifle weapon with 30 Ammo for $15000");
            SendClientMessage(giveplayerid, 0x00C7FFAA, szstring);

        }
            if(listitem==4) {
            if(GetPlayerMoney(giveplayerid) <= 7999) {
                SendClientMessage(giveplayerid, 0xA9A9A9AA, "|_Weapon Sale Failed_|");
                format(szstring, sizeof(szstring), "You cannot afford a AK47 for $8000");
                SendClientMessage(giveplayerid, COLOR_ERROR, szstring);
                return 1;
            }
            GivePlayerWeapon(giveplayerid,30,200);
            GivePlayerMoney(giveplayerid, -8000);
            SendClientMessage(giveplayerid, 0xA9A9A9AA, "|_Weapon Purchased_|");
            format(szstring, sizeof(szstring), "You have bought a AK47 with 200 Ammo for $8000");
            SendClientMessage(giveplayerid, 0x00C7FFAA, szstring);

        }
            if(listitem==5) {
            if(GetPlayerMoney(giveplayerid) <= 499) {
                SendClientMessage(giveplayerid, 0xA9A9A9AA, "|_Weapon Sale Failed_|");
                format(szstring, sizeof(szstring), "You cannot afford Armor for $500");
                SendClientMessage(giveplayerid, COLOR_ERROR, szstring);

                return 1;
            }
            SetPlayerArmour(giveplayerid, 100);
            GivePlayerMoney(giveplayerid, -500);
            SendClientMessage(giveplayerid, 0xA9A9A9AA, "|_Weapon Purchased_|");
            format(szstring, sizeof(szstring), "You have bought Armor for $500");
            SendClientMessage(giveplayerid, 0x00C7FFAA, szstring);

        }
            if(listitem==6) {
            if(GetPlayerMoney(giveplayerid) <= 3499) {
                SendClientMessage(giveplayerid, 0xA9A9A9AA, "|_Weapon Sale Failed_|");
                format(szstring, sizeof(szstring), "You cannot afford 3 Blocks of C4 for $3500");
                SendClientMessage(giveplayerid, COLOR_ERROR, szstring);

                return 1;
            }
            if(HasC4[giveplayerid] == 1) {
                SendClientMessage(giveplayerid, 0xA9A9A9AA, "|_Weapon Sale Failed_|");
                format(szstring, sizeof(szstring), "You already have enough C4");
                SendClientMessage(giveplayerid, COLOR_ERROR, szstring);
                return 1;
            }
            HasC4[giveplayerid] =1;
            GivePlayerMoney(giveplayerid, -3500);
            SendClientMessage(giveplayerid, 0xA9A9A9AA, "|_Weapon Purchased_|");
            format(szstring, sizeof(szstring), "You have bought 3 Blocks of C4 for $3500");
            SendClientMessage(giveplayerid, 0x00C7FFAA, szstring);

        }
            if(listitem==7) {
            if(GetPlayerMoney(giveplayerid) <= 9999) {
                SendClientMessage(giveplayerid, 0xA9A9A9AA, "|_Weapon Sale Failed_|");
                format(szstring, sizeof(szstring), "You cannot afford a Parachute for $10000");
                SendClientMessage(giveplayerid, COLOR_ERROR, szstring);

                return 1;
            }
            GivePlayerWeapon(giveplayerid, 46, 500);
            GivePlayerMoney(giveplayerid, -10000);
            SendClientMessage(giveplayerid, 0xA9A9A9AA, "|_Weapon Purchased_|");
            format(szstring, sizeof(szstring), "You have bought A Parachute for $10000");
            SendClientMessage(giveplayerid, 0x00C7FFAA, szstring);
        }
            if(listitem==8) {
              if(GetPlayerMoney(giveplayerid) <= 999) {
                SendClientMessage(giveplayerid, 0xA9A9A9AA, "|_Weapon Sale Failed_|");
                format(szstring, sizeof(szstring), "You cannot afford a M4 for $1000");
                SendClientMessage(giveplayerid, COLOR_ERROR, szstring);
                return 1;
            }
            GivePlayerWeapon(giveplayerid, 31, 50);
            GivePlayerMoney(giveplayerid, -1000);
            SendClientMessage(giveplayerid, 0xA9A9A9AA, "|_Weapon Purchased_|");
            format(szstring, sizeof(szstring), "You have bought a M4 for $1000");
            SendClientMessage(giveplayerid, 0x00C7FFAA, szstring);

        }
            if(listitem==9) {
            if(GetPlayerMoney(giveplayerid) <= 6999) {
                SendClientMessage(giveplayerid, 0xA9A9A9AA, "|_Weapon Sale Failed_|");
                format(szstring, sizeof(szstring), "You cannot afford a Rifle for $7000");
                SendClientMessage(giveplayerid, COLOR_ERROR, szstring);
                return 1;
            }
            GivePlayerWeapon(giveplayerid, 33, 50);
            GivePlayerMoney(giveplayerid, -7000);
            SendClientMessage(giveplayerid, 0xA9A9A9AA, "|_Weapon Purchased_|");
            format(szstring, sizeof(szstring), "You have bought A Rifle for $7000");
            SendClientMessage(giveplayerid, 0x00C7FFAA, szstring);
        }
            if(listitem==10) {
            if(GetPlayerMoney(giveplayerid) <= 4999) {
                SendClientMessage(giveplayerid, 0xA9A9A9AA, "|_Weapon Sale Failed_|");
                format(szstring, sizeof(szstring), "You cannot afford a Desert Eagle for $5000");
                SendClientMessage(giveplayerid, COLOR_ERROR, szstring);

                return 1;
            }
            GivePlayerWeapon(giveplayerid, 24, 50);
            GivePlayerMoney(giveplayerid, -10000);
            SendClientMessage(giveplayerid, 0xA9A9A9AA, "|_Weapon Purchased_|");
            format(szstring, sizeof(szstring), "You have bought A Desert Eagle for $5000");
            SendClientMessage(giveplayerid, 0x00C7FFAA, szstring);

        }
        }
    }
Reply
#8

Anyone? Please.
Reply
#9

Can someone please help me out?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)