Advertisement
Diego_Bueno

Ppc _Trucks

Jun 2nd, 2023
1,656
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.05 KB | None | 0 0
  1. // This file holds an array of defined Trucks, used in the /Truck dialog
  2.  
  3.  
  4.  
  5. enum TTruck
  6. {
  7.     TruckName[50], // Holds the name of the Truck
  8.     TruckModel // Holds the model-ID of the Truck
  9. }
  10.  
  11. new ATrucks[][TTruck] =
  12. {
  13.     {"Roadtrain", 515},     {"Linerunner", 403},    {"Tanker", 514},    {"Flatbed", 455},       // ID 0, 1, 2, 3
  14.     {"DFT-30", 578},        {"Cement Truck", 524}                                               // ID 4, 5
  15.    
  16. };
  17.  
  18.  
  19. // This function creates a list of Trucks, starting from the FirstTruck and automatically shows the dialog
  20. TruckList_Create(playerid)
  21. {
  22.     // Setup local variables
  23.     new Counter, TruckList[500], DialogTitle[128];
  24.  
  25.     // Only add 10 Trucks to the list, starting from the FirstTruck
  26.     for (new i = APlayerData[playerid][DialogTruckFirstTruck]; i < sizeof(ATrucks); i++)
  27.     {
  28.         // Increase a counter (which holds the number of Trucks that have been added to the list
  29.         Counter++;
  30.  
  31.         // Check if the maximum hasn't been reached yet
  32.         if (Counter <= 10)
  33.         {
  34.             // Add the Truckname to the list
  35.             if (strlen(TruckList) == 0) // If this is the start of the list (no Trucks have been added yet)
  36.                 format(TruckList, 500, "%s", ATrucks[i][TruckName]); // Add the name of the Truck at the start of the Trucklist
  37.             else
  38.                 format(TruckList, 500, "%s%s%s", TruckList, "\n", ATrucks[i][TruckName]); // Add the name of the next Truck to the list on the next line
  39.         }
  40.         else // 10 Trucks have been added to the list (now Counter = 11)
  41.         {
  42.             // Add an empty line and "Next..." to the list to let the player know there are more Trucks to choose from
  43.             format(TruckList, 500, "%s%s%s", TruckList, "\n \n", TXT_DialogEntryNext);
  44.             // Also stop the For-loop
  45.             break;
  46.         }
  47.     }
  48.  
  49.     // Construct the title for the dialog (to include a page number)
  50.     format(DialogTitle, 128, TXT_DialogTruckTitle, (APlayerData[playerid][DialogTruckFirstTruck] / 10) + 1);
  51.     // Ask which Truck the player wants to have by showing the dialog
  52.     ShowPlayerDialog(playerid, DialogTruck, DIALOG_STYLE_LIST, DialogTitle, TruckList, TXT_DialogButtonSpawn, TXT_DialogButtonCancel);
  53.  
  54.     return 1;
  55. }
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement