Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This file holds an array of defined Trucks, used in the /Truck dialog
- enum TTruck
- {
- TruckName[50], // Holds the name of the Truck
- TruckModel // Holds the model-ID of the Truck
- }
- new ATrucks[][TTruck] =
- {
- {"Roadtrain", 515}, {"Linerunner", 403}, {"Tanker", 514}, {"Flatbed", 455}, // ID 0, 1, 2, 3
- {"DFT-30", 578}, {"Cement Truck", 524} // ID 4, 5
- };
- // This function creates a list of Trucks, starting from the FirstTruck and automatically shows the dialog
- TruckList_Create(playerid)
- {
- // Setup local variables
- new Counter, TruckList[500], DialogTitle[128];
- // Only add 10 Trucks to the list, starting from the FirstTruck
- for (new i = APlayerData[playerid][DialogTruckFirstTruck]; i < sizeof(ATrucks); i++)
- {
- // Increase a counter (which holds the number of Trucks that have been added to the list
- Counter++;
- // Check if the maximum hasn't been reached yet
- if (Counter <= 10)
- {
- // Add the Truckname to the list
- if (strlen(TruckList) == 0) // If this is the start of the list (no Trucks have been added yet)
- format(TruckList, 500, "%s", ATrucks[i][TruckName]); // Add the name of the Truck at the start of the Trucklist
- else
- 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
- }
- else // 10 Trucks have been added to the list (now Counter = 11)
- {
- // Add an empty line and "Next..." to the list to let the player know there are more Trucks to choose from
- format(TruckList, 500, "%s%s%s", TruckList, "\n \n", TXT_DialogEntryNext);
- // Also stop the For-loop
- break;
- }
- }
- // Construct the title for the dialog (to include a page number)
- format(DialogTitle, 128, TXT_DialogTruckTitle, (APlayerData[playerid][DialogTruckFirstTruck] / 10) + 1);
- // Ask which Truck the player wants to have by showing the dialog
- ShowPlayerDialog(playerid, DialogTruck, DIALOG_STYLE_LIST, DialogTitle, TruckList, TXT_DialogButtonSpawn, TXT_DialogButtonCancel);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement