Advertisement
Guest User

Untitled

a guest
Oct 12th, 2014
1,152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.07 KB | None | 0 0
  1. //---------------------Thanks to Everyone For Helping--------------"       "   '
  2. //---------------------Very Very Special Thanks to Southclaw------- "     "    '
  3. //-----------------------------------------------------------------  "   "     '
  4. //------------------SA-MP Team/Slice,Y_Less,Incognito--------------   " "      '
  5. //-----------------------------And all who helped------------------    "       '
  6. //----------------------Thanks Twixx appreciate your testings------    "       '
  7. //--------------------------------""""""---------------------------    "       '
  8. //-------------------------------"      "--------------------------    "       '
  9. //------------------------------"        "-------------------------    "       '
  10. //------------------------------"        "-------------------------    "       '
  11. //------------------------------""""""""""-------------------------    "
  12. //------------------Thanks to Everyone Helping SA-MP---------------    "
  13. //------------------------And Making Scripting easier--------------    "
  14. //------------------------Oh And me Too (Script)-------------------    "
  15. //------------------------------------------------------------------------------
  16.  
  17. #include <a_samp>
  18.  
  19.  
  20. new FireShot[MAX_PLAYERS];
  21. new     gRocketObj[MAX_PLAYERS];
  22.  
  23.  
  24. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  25. {
  26.         if(IsPlayerInAnyVehicle(playerid) && FireShot[playerid] == 0 && newkeys & 4 && !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
  27.         {
  28.                 SetPlayerTime(playerid,0,0);
  29.                 new
  30.                 vehicleid = GetPlayerVehicleID(playerid),
  31.                         Float:x,
  32.                         Float:y,
  33.                         Float:z,
  34.                         Float:r,
  35.                         Float:dist = 50.0,
  36.                         Float:tmpang,
  37.                         Float:tmpx,
  38.                         Float:tmpy,
  39.                         Float:tmpz;
  40.  
  41.                 FireShot[playerid] = 1;
  42.         SetTimerEx("ShotFire", 1000, 0, "i", playerid);
  43.                 GetVehiclePos(vehicleid, x, y, z);
  44.             GetVehicleZAngle(vehicleid, r);
  45.                 new rand = random(11);
  46.                 switch(rand)
  47.                 {
  48.                         case 0: gRocketObj[playerid] = CreateObject(18647, x, y, z, 0, 0, r);
  49.                         case 1: gRocketObj[playerid] = CreateObject(18648, x, y, z, 0, 0, r);
  50.                         case 2: gRocketObj[playerid] = CreateObject(18649, x, y, z, 0, 0, r);
  51.                         case 3: gRocketObj[playerid] = CreateObject(18650, x, y, z, 0, 0, r);
  52.                         case 4: gRocketObj[playerid] = CreateObject(18651, x, y, z, 0, 0, r);
  53.                         case 5: gRocketObj[playerid] = CreateObject(18652, x, y, z, 0, 0, r);
  54.             case 6: gRocketObj[playerid] = CreateObject(18647, x, y, z, 0, 0, r+90);
  55.                         case 7: gRocketObj[playerid] = CreateObject(18648, x, y, z, 0, 0, r+90);
  56.                         case 8: gRocketObj[playerid] = CreateObject(18649, x, y, z, 0, 0, r+90);
  57.                         case 9: gRocketObj[playerid] = CreateObject(18650, x, y, z, 0, 0, r+90);
  58.                         case 10: gRocketObj[playerid] = CreateObject(18651, x, y, z, 0, 0, r+90);
  59.                         case 11: gRocketObj[playerid] = CreateObject(18652, x, y, z, 0, 0, r+90);
  60.                 }
  61.                 //Thanks to Southclaw helped me alot
  62.                
  63.                 for(new i;i<MAX_PLAYERS;i++)
  64.                 {
  65.                     if(i == playerid)continue;
  66.                     if(IsPlayerInRangeOfPoint(i, 50.0, x, y, z))
  67.                     {
  68.                         GetPlayerPos(i, tmpx, tmpy, tmpz);
  69.  
  70.                         tmpang = (90-atan2(tmpy-y, tmpx-x));
  71.                         if(tmpang < 0)tmpang = 360.0+tmpang;
  72.                         tmpang = 360.0 - tmpang;
  73.  
  74.                                 if( floatabs(tmpang-r) < 5.0)
  75.                                 {
  76.                                     dist = GetPlayerDistanceFromPoint(i, x, y, z);
  77.                                 }
  78.                     }
  79.                 }
  80.  
  81.             MoveObject(gRocketObj[playerid],x + (dist * floatsin(-r, degrees)),y + (dist * floatcos(-r, degrees)),z,100.0);                             // Nice and fast!
  82.         }
  83. }
  84.  
  85.  
  86.  
  87. forward ShotFire(playerid);
  88. public ShotFire(playerid)
  89. {
  90.         FireShot[playerid] = 0;
  91.         return 1;
  92. }
  93.  
  94. public OnObjectMoved(objectid)
  95. {
  96.         for(new i;i<MAX_PLAYERS;i++)                          
  97.         {
  98.                 if(objectid == gRocketObj[i])              
  99.                 {
  100.                     new
  101.                                 Float:x,
  102.                                 Float:y,
  103.                                 Float:z;
  104.  
  105.                     GetObjectPos(gRocketObj[i], x, y, z);  
  106.                     CreateExplosion(x, y, z, 11, 3.0);      
  107.                     DestroyObject(gRocketObj[i]);          
  108.                 }
  109.         }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement