HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1.  
  2.  
  3. #include <amxmodx>
  4. #include <amxmisc>
  5.  
  6. #define PLUGIN "Snipers Crosshairs"
  7. #define AUTHOR "ConnorMcLeod"
  8. #define VERSION "0.0.3"
  9.  
  10. #define MAX_PLAYERS 32
  11.  
  12. #define HasSniperCrosshair(%1) ( g_iFlags & (1<<%1) )
  13.  
  14. const WEAPONS_9MM = (1<<CSW_ELITE)|(1<<CSW_GLOCK18)|(1<<CSW_MP5NAVY)|(1<<CSW_TMP)
  15.  
  16. new g_iCurWeapon[MAX_PLAYERS+1]
  17. new g_bInZoom[MAX_PLAYERS+1]
  18. new g_bFake[MAX_PLAYERS+1]
  19.  
  20. new g_338magnum[MAX_PLAYERS+1]
  21. new g_9mm[MAX_PLAYERS+1]
  22.  
  23. new gmsgCurWeapon, gmsgAmmoX
  24.  
  25. new g_iFlags
  26.  
  27. public plugin_init()
  28. {
  29. register_plugin(PLUGIN, VERSION, AUTHOR)
  30.  
  31. register_concmd("amx_snipers_crosshair", "AdminCommand_Crosshair", ADMIN_CFG, "amx_snipers_crosshair <flags>")
  32.  
  33. register_event("CurWeapon", "Event_CurWeapon", "be", "1=1")
  34. register_event("AmmoX", "Event_AmmoX", "be", "1=1", "1=10")
  35. register_event("SetFOV", "Event_SetFOV", "be")
  36.  
  37. gmsgCurWeapon = get_user_msgid("CurWeapon")
  38. gmsgAmmoX = get_user_msgid("AmmoX")
  39. }
  40.  
  41. public AdminCommand_Crosshair(id, level, cid)
  42. {
  43. if( !cmd_access(id, level, cid, 2) )
  44. {
  45. return PLUGIN_HANDLED
  46. }
  47.  
  48. new szFlags[5]
  49. read_argv(1, szFlags, charsmax(szFlags))
  50.  
  51. static const iSnipersIds[] = {CSW_SCOUT, CSW_SG550, CSW_AWP, CSW_G3SG1}
  52. new i, cLetter, iVal
  53. g_iFlags = 0
  54.  
  55. while( (cLetter = szFlags[i++]) )
  56. {
  57. iVal = cLetter - 'a'
  58. if( 0 <= iVal < sizeof(iSnipersIds) )
  59. {
  60. g_iFlags |= (1<<iSnipersIds[iVal])
  61. }
  62. }
  63.  
  64. new iPlayers[MAX_PLAYERS], iNum, iPlayer
  65. new iClip, iBpAmmo, iWeaponId
  66.  
  67. get_players(iPlayers, iNum, "a")
  68.  
  69. for(new i; i<iNum; i++)
  70. {
  71. iPlayer = iPlayers[i]
  72. if( g_bInZoom[iPlayer] )
  73. {
  74. continue
  75. }
  76. iWeaponId = get_user_weapon(iPlayer, iClip, iBpAmmo)
  77. if( HasSniperCrosshair(iWeaponId) )
  78. {
  79. emessage_begin(MSG_ONE_UNRELIABLE, gmsgCurWeapon, _, iPlayer)
  80. ewrite_byte(1)
  81. ewrite_byte(iWeaponId)
  82. ewrite_byte(iClip)
  83. emessage_end()
  84. }
  85. }
  86.  
  87. return PLUGIN_HANDLED
  88. }
  89.  
  90. public Event_SetFOV( id )
  91. {
  92. g_bInZoom[id] = ( 0 < read_data(1) < 55 )
  93. }
  94.  
  95. public Event_CurWeapon(id)
  96. {
  97. new iCurWeapon = read_data(2)
  98.  
  99. if( iCurWeapon == g_iCurWeapon[id] )
  100. {
  101. if( HasSniperCrosshair(iCurWeapon) )
  102. {
  103. if( g_bInZoom[id] )
  104. {
  105. return
  106. }
  107. }
  108. else
  109. {
  110. return
  111. }
  112. }
  113. else
  114. {
  115. g_iCurWeapon[id] = iCurWeapon
  116.  
  117. if( !HasSniperCrosshair(iCurWeapon) )
  118. {
  119. if( WEAPONS_9MM & (1<<iCurWeapon) && g_bFake[id] )
  120. {
  121. Send_AmmoX(id, 0)
  122. }
  123. return
  124. }
  125.  
  126. if( g_bInZoom[id] )
  127. {
  128. return
  129. }
  130. }
  131.  
  132. new iWeapon
  133. switch( iCurWeapon )
  134. {
  135. case CSW_SG550:iWeapon = CSW_GALIL
  136. case CSW_AWP:iWeapon = CSW_ELITE
  137. default:iWeapon = CSW_AK47
  138. }
  139.  
  140. message_begin(MSG_ONE_UNRELIABLE, gmsgCurWeapon, _, id)
  141. write_byte(1)
  142. write_byte(iWeapon)
  143. write_byte(read_data(3))
  144. message_end()
  145.  
  146. if( iWeapon == CSW_ELITE && !g_bFake[id] )
  147. {
  148. Send_AmmoX(id, 1)
  149. }
  150. }
  151.  
  152. public Event_AmmoX(id)
  153. {
  154. if( read_data(1) == 1)
  155. {
  156. g_338magnum[id] = read_data(2)
  157. }
  158. else
  159. {
  160. g_9mm[id] = read_data(2)
  161. }
  162.  
  163. if( g_iCurWeapon[id] == CSW_AWP && !g_bInZoom[id] )
  164. {
  165. Send_AmmoX(id, 1)
  166. }
  167. }
  168.  
  169. Send_AmmoX(id, fake)
  170. {
  171. g_bFake[id] = fake
  172.  
  173. message_begin(MSG_ONE_UNRELIABLE, gmsgAmmoX, _, id)
  174. write_byte(10)
  175. write_byte(fake ? g_338magnum[id] : g_9mm[id])
  176. message_end()
  177. }