JasperM

Sonic Laser's by Rudy_

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