Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2011
2,130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.96 KB | None | 0 0
  1. // Tank minigun script by Mean.
  2. // I don't care about the credits much, but don't
  3. // be self-ish.
  4.  
  5.  
  6. #include < a_samp >
  7. #include < a_npc >
  8.  
  9. #define MAX_MINIGUNS 5
  10. #undef MAX_PLAYERS
  11. #define MAX_PLAYERS 100
  12. new
  13.     mgun[ MAX_MINIGUNS ]
  14.     ,minigunnum = 0
  15.     ,vehhasminigun[ MAX_VEHICLES ]
  16.     ,laser[ MAX_PLAYERS ]
  17. ;
  18.  
  19. #define PUB:%1(%2) forward %1(%2); public %1(%2)
  20.  
  21. GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
  22. {
  23.     new Float:a;
  24.     GetPlayerPos(playerid, x, y, a);
  25.     GetPlayerFacingAngle(playerid, a);
  26.     if (GetPlayerVehicleID(playerid))
  27.     {
  28.         GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
  29.     }
  30.     x += (distance * floatsin(-a, degrees));
  31.     y += (distance * floatcos(-a, degrees));
  32. }
  33.  
  34. public OnFilterScriptInit( ) {
  35.     for( new i = 0; i < MAX_VEHICLES; ++i )
  36.         vehhasminigun[ i ] = 0;
  37.     SetTimer( "check", 5000, 1 );
  38.     SetTimer( "loop", 500, 1 );
  39.     print( "Miniguns on tanks by Mean loaded." );
  40.     return 1;
  41. }
  42.  
  43. PUB:check( ) {
  44.     for( new i = 0; i < MAX_VEHICLES; ++i ) {
  45.         new model = GetVehicleModel( i );
  46.         if( model == 432 ) {
  47.             if( vehhasminigun[ i ] == 0 ) {
  48.                 vehhasminigun[ i ] = 1;
  49.                 mgun[ minigunnum ] = CreateObject( 2985, 0, 0, 0, 0, 0, 0 );
  50.                 AttachObjectToVehicle( mgun[ minigunnum ], i, 0.74, 3.37, -0.25, 0.00, 0.00, 89.47 );
  51.                 minigunnum ++;
  52.             }
  53.         }
  54.     }
  55.     return 1;
  56. }
  57.  
  58. PUB:loop( ) {
  59.     for( new i = 0; i < MAX_PLAYERS; ++i ) {
  60.         if( IsPlayerConnected( i ) ) {
  61.             new vehicleid = GetPlayerVehicleID( i );
  62.             new model = GetVehicleModel( vehicleid );
  63.             if( model == 432 ) {
  64.                 new
  65.                     keys
  66.                     ,ud
  67.                     ,lr
  68.                 ;
  69.                 GetPlayerKeys( i, keys, ud, lr );
  70.                 if( keys & 128 ) {
  71.                     SetPlayerAttachedObject( i, 0, 18695, 1, 0.379999, 1.799999, -2.700000, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000 );
  72.                     laser[ i ] = CreateObject( 19084, 0.75, 3.84, 0.86, 0.00, 0.00, 92.61 );
  73.                     AttachObjectToVehicle( laser[ i ], vehicleid, 0.73, 4.18, 0.86, 0.00, 0.00, 88.03 );
  74.                     PlayerPlaySound( i, 1135, 0.0, 0.0, 0.0 );
  75.                     SetTimerEx( "destroy", 250, 0, "i", i );
  76.                    
  77.                     new
  78.                         Float:x
  79.                         ,Float:y
  80.                         ,Float:z
  81.                         ,Float:x2
  82.                         ,Float:y2
  83.                     ;
  84.                     GetPlayerPos( i, x2, y2, z );
  85.                     #pragma unused x2
  86.                     #pragma unused y2
  87.                     GetXYInFrontOfPlayer( i, x, y, 5.0 );
  88.                     for( new u = 0; u < MAX_PLAYERS; ++u ) {
  89.                         if( IsPlayerInRangeOfPoint( u, 6.0, x, y, z ) && u != i ) {
  90.                             new Float:hp;
  91.                             GetPlayerHealth( u, hp );
  92.                             SetPlayerHealth( u, hp - 5 );
  93.                             PlayerPlaySound( u, 1135, 0.0, 0.0, 0.0 );
  94.                            
  95.                             if( hp < 1 )
  96.                                 CallLocalFunction( "OnPlayerDeath", "ddd", u, i, 38 );
  97.                         }
  98.                     }
  99.                 }
  100.             }
  101.         }
  102.     }
  103.     return 1;
  104. }
  105.  
  106. PUB:destroy( i ) {
  107.     RemovePlayerAttachedObject( i, 0 );
  108.     DestroyObject( laser[ i ] );
  109.     return 1;
  110. }
  111.  
  112. public OnPlayerDeath( playerid, killerid, reason ) {
  113.     // Paste your OnPlayerDeath here!
  114.     return 1;
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement