1
0

PPC_DefTrailers.inc 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // This file holds an array of defined Trailers, used in the /Trailer dialog
  2. enum TTrailer
  3. {
  4. TrailerName[50], // Holds the name of the Trailer
  5. TrailerModel // Holds the model-ID of the Trailer
  6. }
  7. new ATrailers[][TTrailer] =
  8. {
  9. {"Article Trailer", 435}, {"Article Trailer 2", 450}, {"Article Trailer 3", 591}, {"Baggage Trailer A", 606}, // ID 0, 1, 2, 3
  10. {"Baggage Trailer B", 607}, {"Farm Trailer", 610}, {"Petrol Trailer", 584}, {"Stairs Trailer", 608}, // ID 4, 5, 6, 7
  11. {"Utility Trailer", 611} // ID 8
  12. };
  13. // This function creates a list of Trailers, starting from the FirstTrailer and automatically shows the dialog
  14. TrailerList_Create(playerid)
  15. {
  16. // Setup local variables
  17. new Counter, TrailerList[500], DialogTitle[128];
  18. // Only add 10 Trailers to the list, starting from the FirstTrailer
  19. for (new i = APlayerData[playerid][DialogTrailerFirstTrailer]; i < sizeof(ATrailers); i++)
  20. {
  21. // Increase a counter (which holds the number of Trailers that have been added to the list
  22. Counter++;
  23. // Check if the maximum hasn't been reached yet
  24. if (Counter <= 10)
  25. {
  26. // Add the Trailername to the list
  27. if (strlen(TrailerList) == 0) // If this is the start of the list (no Trailers have been added yet)
  28. format(TrailerList, 500, "%s", ATrailers[i][TrailerName]); // Add the name of the Trailer at the start of the Trailerlist
  29. else
  30. format(TrailerList, 500, "%s%s%s", TrailerList, "\n", ATrailers[i][TrailerName]); // Add the name of the next Trailer to the list on the next line
  31. }
  32. else // 10 Trailers have been added to the list (now Counter = 11)
  33. {
  34. // Add an empty line and "Next..." to the list to let the player know there are more Trailers to choose from
  35. format(TrailerList, 500, "%s%s%s", TrailerList, "\n \n", TXT_DialogEntryNext);
  36. // Also stop the For-loop
  37. break;
  38. }
  39. }
  40. // Construct the title for the dialog (to include a page number)
  41. format(DialogTitle, 128, TXT_DialogTrailerTitle, (APlayerData[playerid][DialogTrailerFirstTrailer] / 10) + 1);
  42. // Ask which Trailer the player wants to have by showing the dialog
  43. ShowPlayerDialog(playerid, DialogTrailer, DIALOG_STYLE_LIST, DialogTitle, TrailerList, TXT_DialogButtonSpawn, TXT_DialogButtonCancel);
  44. return 1;
  45. }