Advertisement
Southclaw

Southclaw's Vehicular Missile Script

Jul 26th, 2012
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.26 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3. #include <streamer>
  4.  
  5. #undef MAX_PLAYERS
  6. #define MAX_PLAYERS 16 // Shit I forgot to change this value in my 32 slot server...
  7.  
  8.  
  9. new
  10.     bool:gRocketCar[MAX_PLAYERS],   // Is the player using Car Rockets?
  11.     gRocketObj[MAX_PLAYERS];        // Variable to hold the object ID
  12.  
  13. CMD:rocketcar(playerid, params[])
  14. {
  15.     gRocketCar[playerid] = !gRocketCar[playerid];   // Turn it on and off by assigning the opposite (Compliment) of itself to itself.
  16.     return 1;
  17. }
  18.  
  19. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  20. {
  21.     if(
  22.         IsPlayerInAnyVehicle(playerid) &&       // Is the player in a vehicle?
  23.         newkeys & 4 &&                          // Fire key in a vehicle
  24.         !IsValidObject(gRocketObj[playerid]))   // Only run the code if the object doesn't already exist, otherwise more objects will take up gRocketObj and the previous ones won't be deleted
  25.     {
  26.         new
  27.             vehicleid = GetPlayerVehicleID(playerid),   // Initialise variables
  28.             Float:x,
  29.             Float:y,
  30.             Float:z,
  31.             Float:r;
  32.  
  33.         GetVehiclePos(vehicleid, x, y, z);
  34.         GetVehicleZAngle(vehicleid, r);
  35.         gRocketObj[playerid] = CreateObject(18650, x, y, z, 0.0, 0.0, r);       // Create the object inside the vehicle
  36.         MoveObject(
  37.             gRocketObj[playerid],               // Move the object just created
  38.             x + (30.0 * floatsin(-r, degrees)), // Add the sine of the angle onto the X multiplied by the distance (30.0)
  39.             y + (30.0 * floatcos(-r, degrees)), // Do the same for the cosine of the angle, multiply by the same distance and add it to the Y
  40.             z,                                  // The Z doesn't change (It should but that's more complex, it involves getting all angles of the vehicle)
  41.             100.0);                             // Nice and fast!
  42.     }
  43. }
  44.  
  45.  
  46. public OnObjectMoved(objectid)
  47. {
  48.     for(new i;i<MAX_PLAYERS;i++)                    // Loop through players
  49.     {
  50.         if(objectid == gRocketObj[i])               // If this object is one of those player objects
  51.         {
  52.             new
  53.                 Float:x,
  54.                 Float:y,
  55.                 Float:z;
  56.  
  57.             GetObjectPos(gRocketObj[i], x, y, z);   // Get the position of the object
  58.             CreateExplosion(x, y, z, 11, 3.0);      // Create an explosion at this position
  59.             DestroyObject(gRocketObj[i]);           // Destroy the object
  60.         }
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement