Guest User

Anti-2Shoot by WaJeeH

a guest
Jun 17th, 2015
584
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.21 KB | None | 0 0
  1. //-----------------------------Anti-2Shoot By WaJeeH--------------------------------------------
  2. //-----------------------------Running in Server:198.100.144.190:6572---------------------------
  3. //-----------------------------Enjoy and do not remove credits :) ------------------------------
  4. #include <a_samp>
  5. #include <YSI\y_ini>
  6. #define FREEZE_TIME (650) // The time a player will get froze after evading reload and switching back.
  7. #define PUNISH_THRESOLD (2500) // If the player doesn't switch back the weapon in <PUNISH_THRESOLD> ms, ignore it.
  8. #define iPlayer playerid
  9.  
  10. #define COLOR_ERROR 0xFF0000FF
  11.  
  12. #pragma tabsize 0
  13.  
  14. new
  15. BitArray:g_abIsSawnoffClipUsed< MAX_PLAYERS >,
  16. BitArray:g_abThisBitchDidntReload< MAX_PLAYERS >,
  17. g_iReloadEvadeTime[ MAX_PLAYERS ],
  18. g_iSawnoffAmmo[ MAX_PLAYERS ],
  19. g_cFiredShots[ MAX_PLAYERS char ],
  20. g_cPreviousWeapon[ MAX_PLAYERS char ]
  21. ;
  22.  
  23. public OnPlayerSpawn( iPlayer )
  24. {
  25. g_iSawnoffAmmo[ iPlayer ] = -1;
  26. g_cFiredShots{ iPlayer } = 0;
  27. g_cPreviousWeapon{ iPlayer } = 0;
  28.  
  29. Bit_Vet( g_abIsSawnoffClipUsed, iPlayer );
  30. Bit_Vet( g_abThisBitchDidntReload, iPlayer );
  31. }
  32.  
  33. public OnPlayerUpdate( iPlayer )
  34. {
  35. static
  36. s_iState,
  37. s_iSpecialAction
  38. ;
  39.  
  40. s_iState = GetPlayerState( iPlayer );
  41. s_iSpecialAction = GetPlayerSpecialAction( iPlayer );
  42.  
  43. if ( s_iState == PLAYER_STATE_ONFOOT && ( s_iSpecialAction == SPECIAL_ACTION_NONE || s_iSpecialAction == SPECIAL_ACTION_DUCK ) )
  44. {
  45. static
  46. s_iWeapon,
  47. s_iAmmo
  48. ;
  49.  
  50. s_iWeapon = GetPlayerWeapon( iPlayer );
  51. s_iAmmo = GetPlayerAmmo( iPlayer );
  52.  
  53. if ( g_cPreviousWeapon{ iPlayer } != s_iWeapon )
  54. {
  55. if ( g_cPreviousWeapon{ iPlayer } == WEAPON_SAWEDOFF )
  56. {
  57. if ( Bit_Get( g_abIsSawnoffClipUsed, iPlayer ) )
  58. {
  59. static
  60. s_iWeaponState
  61. ;
  62.  
  63. s_iWeaponState = GetPlayerWeaponState( iPlayer );
  64.  
  65. if ( ( s_iWeaponState == WEAPONSTATE_MORE_BULLETS || s_iWeaponState == WEAPONSTATE_LAST_BULLET ) && g_cFiredShots{ iPlayer } != 4 )
  66. {
  67. Bit_Let( g_abThisBitchDidntReload, iPlayer );
  68.  
  69. g_iReloadEvadeTime[ iPlayer ] = GetTickCount( );
  70. }
  71. }
  72.  
  73. g_cFiredShots{ iPlayer } = 0;
  74. }
  75. else if ( s_iWeapon == WEAPON_SAWEDOFF )
  76. {
  77. if ( Bit_Get( g_abThisBitchDidntReload, iPlayer ) )
  78. {
  79. if ( GetTickCount( ) - g_iReloadEvadeTime[ iPlayer ] < PUNISH_THRESOLD )
  80. {
  81. new
  82. Float:fVX,
  83. Float:fVY,
  84. Float:fVZ
  85. ;
  86.  
  87. GetPlayerVelocity( iPlayer, fVX, fVY, fVZ );
  88.  
  89. if ( floatabs( fVZ ) < 0.15 )
  90. {
  91. ClearAnimations( iPlayer, 1 );
  92.  
  93. ApplyAnimation( playerid, "PED", "XPRESSscratch", 0.0, 1, 0, 0, 0, FREEZE_TIME, 1 );
  94. SendClientMessage(playerid,COLOR_ERROR,"2-Shoot is not allowed in this server.Type /rules!");
  95. GameTextForPlayer( iPlayer ," ~r~ 2-Shoot Detected!", FREEZE_TIME, 4);
  96. }
  97. }
  98.  
  99. Bit_Vet( g_abThisBitchDidntReload, iPlayer );
  100. }
  101. }
  102.  
  103. g_cPreviousWeapon{ iPlayer } = s_iWeapon;
  104. }
  105.  
  106. if ( s_iWeapon == WEAPON_SAWEDOFF )
  107. {
  108. if ( g_iSawnoffAmmo[ iPlayer ] == -1 )
  109. g_iSawnoffAmmo[ iPlayer ] = GetPlayerAmmo( iPlayer );
  110. else
  111. {
  112. if ( GetPlayerWeaponState( iPlayer ) == WEAPONSTATE_RELOADING )
  113. {
  114. if ( Bit_Get( g_abIsSawnoffClipUsed, iPlayer ) )
  115. Bit_Vet( g_abIsSawnoffClipUsed, iPlayer );
  116. }
  117. else
  118. {
  119. if ( g_iSawnoffAmmo[ iPlayer ] != s_iAmmo )
  120. {
  121. if ( s_iAmmo < g_iSawnoffAmmo[ iPlayer ] )
  122. {
  123. Bit_Let( g_abIsSawnoffClipUsed, iPlayer );
  124.  
  125. g_cFiredShots{ iPlayer } += g_iSawnoffAmmo[ iPlayer ] - s_iAmmo;
  126. }
  127. else
  128. {
  129. g_cFiredShots{ iPlayer } = 0;
  130.  
  131. Bit_Vet( g_abIsSawnoffClipUsed, iPlayer );
  132. }
  133.  
  134. g_iSawnoffAmmo[ iPlayer ] = s_iAmmo;
  135. }
  136. }
  137. }
  138. }
  139. else if ( g_iSawnoffAmmo[ iPlayer ] != -1 || Bit_Get( g_abIsSawnoffClipUsed, iPlayer ) )
  140. {
  141. g_iSawnoffAmmo[ iPlayer ] = -1;
  142.  
  143. Bit_Vet( g_abIsSawnoffClipUsed, iPlayer );
  144.  
  145. g_cFiredShots{ iPlayer } = 0;
  146. }
  147. }
  148. else if ( g_iSawnoffAmmo[ iPlayer ] != -1 || Bit_Get( g_abIsSawnoffClipUsed, iPlayer ) )
  149. {
  150. g_iSawnoffAmmo[ iPlayer ] = -1;
  151.  
  152. Bit_Vet( g_abIsSawnoffClipUsed, iPlayer );
  153.  
  154. g_cFiredShots{ iPlayer } = 0;
  155. }
  156.  
  157. return 1;
  158. }
Advertisement
Add Comment
Please, Sign In to add comment