Originally Posted by PowerPC603
An example of my new class-selection?
You should be able to use the following code directly.
If you get it right, you should have no errors (AFAIK) and you'll have the same class-selection as my current V2.
NOTE that this works with the default V1 (without changes to the classes).
If you already made changes to it, you'll have to redo them of course.
Paste this at the top of the gamemode:
pawn Code:
// Create an array that holds the vehicleid's for vehicles and trailers at class-selection for all players new AClassSelectionVehicles[MAX_PLAYERS][2];
Replace the callback OnPlayerRequestClass with this one:
pawn Code:
// This callback gets called when the player is selecting a class (but hasn't clicked "Spawn" yet) public OnPlayerRequestClass(playerid, classid) { // Setup local variables new LastClass, bool:VehicleSpawned = false;
// Set the virtual world and interior for class-selection SetPlayerVirtualWorld(playerid, 15000 + playerid); SetPlayerInterior(playerid, 0);
// Get the player's current class and set it as LastClass LastClass = APlayerData[playerid][PlayerClass]; // Also check if there is currently a vehicle spawned if (AClassSelectionVehicles[playerid][0] == 0) VehicleSpawned = false; else VehicleSpawned = true;
// Display a short message to inform the player about the class he's about to choose switch (classid) { case 0, 1, 2, 3, 4, 5, 6, 7: // Classes that will be truckdrivers { // Display the name of the class GameTextForPlayer(playerid, TXT_ClassTrucker, 3000, 4); // Store the class for the player (truckdriver) APlayerData[playerid][PlayerClass] = ClassTruckDriver; } case 8, 9: // Classes that will be bus-drivers { // Display the name of the class GameTextForPlayer(playerid, TXT_ClassBusDriver, 3000, 4); // Store the class for the player (busdriver) APlayerData[playerid][PlayerClass] = ClassBusDriver; } case 10: // Classes that will be Pilot { // Display the name of the class GameTextForPlayer(playerid, TXT_ClassPilot, 3000, 4); // Store the class for the player (pilot) APlayerData[playerid][PlayerClass] = ClassPilot; } case 11, 12, 13: // Classes that will be police { // Display the name of the class GameTextForPlayer(playerid, TXT_ClassPolice, 3000, 4); // Store the class for the player (police) APlayerData[playerid][PlayerClass] = ClassPolice; } case 14, 15, 16: // Classes that will be mafia { // Display the name of the class GameTextForPlayer(playerid, TXT_ClassMafia, 3000, 4); // Store the class for the player (mafia) APlayerData[playerid][PlayerClass] = ClassMafia; } case 17, 18: // Classes that will be courier { // Display the name of the class GameTextForPlayer(playerid, TXT_ClassCourier, 3000, 4); // Store the class for the player (courier) APlayerData[playerid][PlayerClass] = ClassCourier; } case 19: // Classes that will be assistance { // Display the name of the class GameTextForPlayer(playerid, TXT_ClassAssistance, 3000, 4); // Store the class for the player (assistance) APlayerData[playerid][PlayerClass] = ClassAssistance; } case 20, 21, 22: // Classes that will be roadworker { // Display the name of the class GameTextForPlayer(playerid, TXT_ClassRoadWorker, 3000, 4); // Store the class for the player (roadworker) APlayerData[playerid][PlayerClass] = ClassRoadWorker; } }
// If the LastClass isn't the same as the current class, delete the current class-selection vehicles if (APlayerData[playerid][PlayerClass] != LastClass) { // Delete both class-selection vehicles if they exist for (new i; i < 2; i++) { if (AClassSelectionVehicles[playerid][i] != 0) { DestroyVehicle(AClassSelectionVehicles[playerid][i]); AClassSelectionVehicles[playerid][i] = 0; } } }
// Determine at which coordinates the player, his camera and a few vehicles should be placed, based on the chosen class switch (APlayerData[playerid][PlayerClass]) { case ClassTrucker: { // Create a Roadtrain truck and a trailer for class-selection, and put the player inside to make them appear if ((APlayerData[playerid][PlayerClass] != LastClass) || (VehicleSpawned == false)) { AClassSelectionVehicles[playerid][0] = Vehicle_CreateCS(playerid, 515, 1457.7, 1005.1, 11.8, 131.0, 1, 2); AClassSelectionVehicles[playerid][1] = Vehicle_CreateCS(playerid, 435, 1466.2, 1009.8, 11.4, 90.0, 1, 2); } SetPlayerPos(playerid, 1459.0, 999.0, 10.82); SetPlayerFacingAngle(playerid, 180.0); SetPlayerCameraPos(playerid, 1459.0, 992.0, 12.0); SetPlayerCameraLookAt(playerid, 1459.0, 1009.0, 10.82); } case ClassBusdriver: { // Create a bus for class-selection, and put the player inside to make it appear if ((APlayerData[playerid][PlayerClass] != LastClass) || (VehicleSpawned == false)) AClassSelectionVehicles[playerid][0] = Vehicle_CreateCS(playerid, 437, 1792.6, -1904.7, 13.53, 203.8, 1, 2); SetPlayerPos(playerid, 1797.8, -1908.5, 13.4); SetPlayerFacingAngle(playerid, 250.0); SetPlayerCameraPos(playerid, 1803.2, -1911.6, 14.6); SetPlayerCameraLookAt(playerid, 1792.6, -1904.7, 13.53); } case ClassPilot: { // Create a shamal for class-selection, and put the player inside to make it appear if ((APlayerData[playerid][PlayerClass] != LastClass) || (VehicleSpawned == false)) AClassSelectionVehicles[playerid][0] = Vehicle_CreateCS(playerid, 519, -1411.5, 81.0, 15.06, 133.5, 1, 2); SetPlayerPos(playerid, -1419.3, 79.5, 14.15); SetPlayerFacingAngle(playerid, 93.0); SetPlayerCameraPos(playerid, -1427.3, 79.4, 15.8); SetPlayerCameraLookAt(playerid, -1411.5, 81.0, 15.06); } case ClassPolice: { // Create a police car and ranger for class-selection, and put the player inside to make them appear if ((APlayerData[playerid][PlayerClass] != LastClass) || (VehicleSpawned == false)) { AClassSelectionVehicles[playerid][0] = Vehicle_CreateCS(playerid, 598, 2284.8, 2422.3, 10.56, 133.4, 1, 0); AClassSelectionVehicles[playerid][1] = Vehicle_CreateCS(playerid, 599, 2292.7, 2422.4, 11.01, 229.0, 1, 0); } SetPlayerPos(playerid, 2288.5, 2420.9, 10.82); SetPlayerFacingAngle(playerid, 180.0); SetPlayerCameraPos(playerid, 2288.0, 2410.0, 10.88); SetPlayerCameraLookAt(playerid, 2288.0, 2422.3, 12.0); } case ClassMafia: { // Create a Sandking for class-selection, and put the player inside to make it appear if ((APlayerData[playerid][PlayerClass] != LastClass) || (VehicleSpawned == false)) AClassSelectionVehicles[playerid][0] = Vehicle_CreateCS(playerid, 495, 2823.7, 921.7, 11.1, 228.0, 0, 0); SetPlayerPos(playerid, 2823.4, 918.0, 10.75); SetPlayerFacingAngle(playerid, 180.0); SetPlayerCameraPos(playerid, 2822.7, 911.5, 10.75); SetPlayerCameraLookAt(playerid, 2823.4, 918.0, 10.75); } case ClassCourier: { // Create a Faggio and Burrito for class-selection, and put the player inside to make them appear if ((APlayerData[playerid][PlayerClass] != LastClass) || (VehicleSpawned == false)) { AClassSelectionVehicles[playerid][0] = Vehicle_CreateCS(playerid, 462, -1855.0, -139.0, 11.49, 51.5, 1, 2); AClassSelectionVehicles[playerid][1] = Vehicle_CreateCS(playerid, 482, -1850.6, -139.0, 12.01, 340.0, 1, 2); } SetPlayerPos(playerid, -1853.3, -138.0, 11.9); SetPlayerFacingAngle(playerid, 15.0); SetPlayerCameraPos(playerid, -1855.0, -130.7, 11.9); SetPlayerCameraLookAt(playerid, -1853.3, -138.0, 11.9); } case ClassAssistance: { // Create a Towtruck for class-selection, and put the player inside to make it appear if ((APlayerData[playerid][PlayerClass] != LastClass) || (VehicleSpawned == false)) AClassSelectionVehicles[playerid][0] = Vehicle_CreateCS(playerid, 525, -1903.9, 271.8, 40.91, 126.0, 1, 2); SetPlayerPos(playerid, -1903.8, 267.4, 41.0); SetPlayerFacingAngle(playerid, 162.0); SetPlayerCameraPos(playerid, -1906.3, 259.8, 40.3); SetPlayerCameraLookAt(playerid, -1903.8, 267.4, 41.0); } case ClassRoadworker: { // Create a xxx for class-selection, and put the player inside to make them appear if ((APlayerData[playerid][PlayerClass] != LastClass) || (VehicleSpawned == false)) { AClassSelectionVehicles[playerid][0] = Vehicle_CreateCS(playerid, 552, -1877.4, -1719.4, 21.43, 59.95, 1, 2); AClassSelectionVehicles[playerid][1] = Vehicle_CreateCS(playerid, 611, -1872.8, -1722.1, 21.4, 59.95, 1, 2); } SetPlayerPos(playerid, -1879.5, -1723.7, 21.75); SetPlayerFacingAngle(playerid, 133.0); SetPlayerCameraPos(playerid, -1886.1, -1729.5, 21.75); SetPlayerCameraLookAt(playerid, -1879.5, -1723.7, 23.0); } }
return 1; }
Add this function below OnPlayerRequestClass:
pawn Code:
// This function is only used during class-selection Vehicle_CreateCS(playerid, vModel, Float:x, Float:y, Float:z, Float:rot, Col1, Col2) { // Create the given vehicle at the given coordinates new vid = CreateVehicle(vModel, x, y, z, rot, Col1, Col2, 60); // Set the vehicle in the player's virtual world for class-selection SetVehicleVirtualWorld(vid, 15000 + playerid); // Put the player inside the vehicle to make it appear PutPlayerInVehicle(playerid, vid, 0); // Return the vehicle-id return vid; }
Finally, Inside the callback OnPlayerRequestSpawn, you'll find this:
pawn Code:
// Spawn the player with his chosen skin at a random location based on his class SetSpawnInfo(playerid, 0, GetPlayerSkin(playerid), x, y, z, Angle, 0, 0, 0, 0, 0, 0); // Send the message to all players (who joined which class) SendClientMessageToAll(0xFFFFFFFF, Msg);
return 1; }
Add this code just above it:
pawn Code:
// Delete both class-selection vehicles if they exist for (new i; i < 2; i++) { if (AClassSelectionVehicles[playerid][i] != 0) { DestroyVehicle(AClassSelectionVehicles[playerid][i]); AClassSelectionVehicles[playerid][i] = 0; } }
Then compile the gamemode.
It should work without errors.
If you get errors, please let me know.
|