Jump to content
  • 0

Problema dialog dealership (nu afiseaza ID-ul masinii)


Question

8 answers to this question

Recommended Posts

  • 0
Posted

Trebuie si cod sursa, dialog-ul cand il arati i.e ShowPlayerDialog si integrarea adica ce ai la OnDialogResponse

asgood.ro

 

 

 

  • 0
Posted

                case 1: {
                    new szDialog2[1024], szTitle[50], xx;
                    strcat(szDialog2, "Vehicle Name\tPrice\tStock\n");
                    for(new j = 0; j < MAX_PERSONAL_VEH; j++) {
                        if(DSInfo[j][dsPrice] > 45000 && DSInfo[j][dsPrice] <= 1500000) {
                            format(szDialog, sizeof(szDialog), "%s\t$%s\t%d\n", DSInfo[j][dsVehicleName], FormatNumber(DSInfo[j][dsPrice]), DSInfo[j][dsStock]);
                            strcat(szDialog2, szDialog);
                            xx++;
                        }
                    }
                    format(szTitle, sizeof(szTitle), "Expensive Vehicles: %d", xx);
                    ShowPlayerDialog(playerid, DIALOG_DEALERSHIP2, DIALOG_STYLE_TABLIST_HEADERS, szTitle, szDialog2, "Select", "Close");

                }

 

 

 

        case DIALOG_DEALERSHIP2: {
            if(!response) return 1;

            new cheapcars;
            for(new xf = 0; xf < MAX_PERSONAL_VEH; xf++)
            {
                if(DSInfo[xf][dsPrice] > 0 && DSInfo[xf][dsPrice] <= 1500000)
                {
                    cheapcars = xf;
                }
            }
        //    new num = listitem + cheapcars + 1;
            new num = listitem + 2;
             BuyCar[playerid] = num;
            new string33[256], stringtitle[256];
            format(stringtitle, sizeof(stringtitle), "%s ($%s) - %s available", DSInfo[num][dsVehicleName], FormatNumber(DSInfo[num][dsPrice]), FormatNumber(DSInfo[num][dsStock]));
            format(string33, sizeof(string33), "Vehicle name: %s\nVehicle price: %s\nNumber of cars available: %s", DSInfo[num][dsVehicleName], FormatNumber(DSInfo[num][dsPrice]), FormatNumber(DSInfo[num][dsStock]));
            ShowPlayerDialog(playerid, DIALOG_BUYCAR, DIALOG_STYLE_MSGBOX, stringtitle, string33, "Buy car", "Back");
        }

  • 0
Posted

        case DIALOG_BUYCAR: {
            if(!response) return 1;

            new num = BuyCar[playerid];
            if(PlayerInfo[playerid][pCashMoney] >= DSInfo[num][dsPrice]) {
                if(DSInfo[num][dsStock] > 0) {
                    GiveVehicle(playerid, num);    
                    DSInfo[num][dsStock] --;
                    mysql_format(SQL, query, sizeof(query), "UPDATE `dealership` SET `Stock`='%d' WHERE `ID`='%d'", DSInfo[num][dsStock], num);
                    mysql_tquery(SQL, query, "", "");
                }
                else {
                    new stringg[1000];
                    format(stringg,sizeof(stringg),"Aceasta masina numai este disponibila in Dealership. Stoc epuizat.\nYou can't buy this vehicle from the dealership. Out of stock.");
                     ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, "Out of stock", stringg, "Close","");
                }
            }
            else return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money to purchase this vehicle.");
        }

  • 0
Posted

Codul asta n-are niciun sens. Hai sa-l facem cum trebuie ca sa-ti mearga expensive vehicles

Fa o variabila globala expensiveVehicles[MAX_PERSONAL_VEH] cred.

Ca sa nu stricam varianta cu cheapcars fa o variabila openedExpensive[MAX_PLAYERS]

La login / connect o setezi pe 0

 for(new j = 0; j < MAX_PERSONAL_VEH; j++) {
   if(DSInfo[j][dsPrice] > 45000 && DSInfo[j][dsPrice] <= 1500000) {
     format(szDialog, sizeof(szDialog), "%s\t$%s\t%d\n", DSInfo[j][dsVehicleName], FormatNumber(DSInfo[j][dsPrice]), DSInfo[j][dsStock]);
     strcat(szDialog2, szDialog);
     xx++;
   }
 }
in foru asta transforma-l in asta
  
 for(new j = 0; j < MAX_PERSONAL_VEH; j++) {
   if(DSInfo[j][dsPrice] > 45000 && DSInfo[j][dsPrice] <= 1500000) {
     format(szDialog, sizeof(szDialog), "%s\t$%s\t%d\n", DSInfo[j][dsVehicleName], FormatNumber(DSInfo[j][dsPrice]), DSInfo[j][dsStock]);
     strcat(szDialog2, szDialog);
     expensiveVehicles[xx] = j;
     openedExpensive[playerid] = 1;
     xx++;
   }
 }

In cod-ul de la dialog-ul asta:

case DIALOG_DEALERSHIP2: {
            if(!response) {
              openedExpensive[playerid] = 0; // si linia asta
              return 1;
            }

            new cheapcars;
            for(new xf = 0; xf < MAX_PERSONAL_VEH; xf++)
            {
                if(DSInfo[xf][dsPrice] > 0 && DSInfo[xf][dsPrice] <= 1500000)
                {
                    cheapcars = xf;
                }
            }
        //    new num = listitem + cheapcars + 1;
            new num = listitem + 2;
             BuyCar[playerid] = num;
            if(openedExpensive[playerid] != 0) BuyCar[playerid] = num = expensiveVehicles[listitem]; // liniile astea le-am adaugat
  			openedExpensive[playerid] = 0; //
            new string33[256], stringtitle[256];
            format(stringtitle, sizeof(stringtitle), "%s ($%s) - %s available", DSInfo[num][dsVehicleName], FormatNumber(DSInfo[num][dsPrice]), FormatNumber(DSInfo[num][dsStock]));
            format(string33, sizeof(string33), "Vehicle name: %s\nVehicle price: %s\nNumber of cars available: %s", DSInfo[num][dsVehicleName], FormatNumber(DSInfo[num][dsPrice]), FormatNumber(DSInfo[num][dsStock]));
            ShowPlayerDialog(playerid, DIALOG_BUYCAR, DIALOG_STYLE_MSGBOX, stringtitle, string33, "Buy car", "Back");
        }

Eventual poti sa mai adaugi si la dialogu principal sa faca openedExpensive[playerid] = 0;

  • Like 1

asgood.ro

 

 

 

  • 0
Posted

Este si o varianta mai buna, dar trebuie rescris cu totul, pe Iteratori si te poti folosi de metodele iteratorilor i.e Iter_Index

  • Like 1

asgood.ro

 

 

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.