HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1.  
  2. #include <amxmodx>
  3. #include <amxmisc>
  4. #include <fakemeta>
  5. #include <hamsandwich>
  6.  
  7. #define VERSION "0.0.5"
  8. #define PLUGIN "Weapons MaxSpeed"
  9.  
  10. #define MAX_WEAPONS CSW_P90
  11.  
  12. #define XO_WEAPON 4
  13. #define m_pPlayer 41
  14. #define m_iId 43
  15.  
  16. #define XO_PLAYER 5
  17. #define m_iFOV 363
  18. #define OFFSET_SHIELD 510
  19. #define HAS_SHIELD (1<<24)
  20. #define USES_SHIELD (1<<16)
  21. const HAS_AND_USES_SHIELD = HAS_SHIELD|USES_SHIELD
  22.  
  23. #define SHIELD_WEAPONS_BITSUM ((1<<CSW_P228)|(1<<CSW_HEGRENADE)|(1<<CSW_SMOKEGRENADE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_FLASHBANG)|(1<<CSW_DEAGLE)|(1<<CSW_KNIFE))
  24.  
  25. enum _:MaxSpeedType {
  26. Float:DefaultMaxSpeed,
  27. Float:ZoomedMaxSpeed,
  28. Float:ShieldMaxSpeed
  29. }
  30.  
  31. new HamHook:g_iHhForwards[MAX_WEAPONS+1]
  32. new Float:g_flMaxSpeed[MAX_WEAPONS+1][MaxSpeedType]
  33.  
  34. public plugin_init()
  35. {
  36. register_plugin(PLUGIN, VERSION, "ConnorMcLeod")
  37.  
  38. register_concmd("amx_weapon_maxspeed", "ConsoleCommand_WeaponSpeed", ADMIN_CFG, "<weapon shortname> <maxspeed> [zoom maxspeed] [shield maxspeed]")
  39. }
  40.  
  41. public ConsoleCommand_WeaponSpeed(id, lvl, cid)
  42. {
  43. if( cmd_access(id, lvl, cid, 2) )
  44. {
  45. new szWeapon[32] = "weapon_"
  46. read_argv(1, szWeapon[7], charsmax(szWeapon)-7)
  47.  
  48. new iId = get_weaponid(szWeapon)
  49.  
  50. if( iId )
  51. {
  52. new iArgs = read_argc()
  53. if( iArgs == 2 )
  54. {
  55. Get_Weapon_State(id, iId, szWeapon)
  56. return PLUGIN_HANDLED
  57. }
  58.  
  59. new szMaxSpeed[5]
  60. read_argv(2, szMaxSpeed, charsmax(szMaxSpeed))
  61. g_flMaxSpeed[iId][DefaultMaxSpeed] = floatmax(str_to_float(szMaxSpeed), 0.0)
  62. if( !g_flMaxSpeed[iId][DefaultMaxSpeed] )
  63. {
  64. if( g_iHhForwards[iId] )
  65. {
  66. DisableHamForward( g_iHhForwards[iId] )
  67. Get_Weapon_State(id, iId, szWeapon)
  68. }
  69. return PLUGIN_HANDLED
  70. }
  71.  
  72. if( iArgs > 3 )
  73. {
  74. read_argv(3, szMaxSpeed, charsmax(szMaxSpeed))
  75. g_flMaxSpeed[iId][ZoomedMaxSpeed] = floatmax(str_to_float(szMaxSpeed), 0.0)
  76. }
  77. else
  78. {
  79. g_flMaxSpeed[iId][ZoomedMaxSpeed] = 0.0
  80. }
  81.  
  82. if( iArgs > 4 && SHIELD_WEAPONS_BITSUM & 1<<iId )
  83. {
  84. read_argv(4, szMaxSpeed, charsmax(szMaxSpeed))
  85. g_flMaxSpeed[iId][ShieldMaxSpeed] = floatmax(str_to_float(szMaxSpeed), 0.0)
  86. }
  87. else
  88. {
  89. g_flMaxSpeed[iId][ShieldMaxSpeed] = 0.0
  90. }
  91.  
  92. if( g_iHhForwards[iId] )
  93. {
  94. EnableHamForward( g_iHhForwards[iId] )
  95. }
  96. else
  97. {
  98. RegisterHam(Ham_CS_Item_GetMaxSpeed, szWeapon, "Item_GetMaxSpeed")
  99. }
  100. Get_Weapon_State(id, iId, szWeapon)
  101. }
  102. }
  103. return PLUGIN_HANDLED
  104. }
  105.  
  106. Get_Weapon_State(id, iId, szWeapon[])
  107. {
  108. if( !g_flMaxSpeed[iId][DefaultMaxSpeed] )
  109. {
  110. console_print(id, "%s A maxspeed az alapértelmezett, a plugin nem aktív ezen a fegyveren!", szWeapon)
  111. }
  112. else
  113. {
  114. console_print(id, "%s a maximális sebesség a(z) %.1f", szWeapon, g_flMaxSpeed[iId][DefaultMaxSpeed])
  115. if( g_flMaxSpeed[iId][ZoomedMaxSpeed] )
  116. {
  117. console_print(id, "%s A pajzzsal maximális sebesség ezen a fegyveren a(z) %.1f", szWeapon, g_flMaxSpeed[iId][ZoomedMaxSpeed])
  118. }
  119. if( g_flMaxSpeed[iId][ShieldMaxSpeed] )
  120. {
  121. console_print(id, "%s A zoom-mal maximális sebesség ezen a fegyveren a(z) %.1f", szWeapon, g_flMaxSpeed[iId][ShieldMaxSpeed])
  122. }
  123. }
  124. }
  125.  
  126. public Item_GetMaxSpeed( iWeapon )
  127. {
  128. new iId = get_pdata_int(iWeapon, m_iId, XO_WEAPON)
  129.  
  130. // alter m_flWeaponSpeed would be less efficient
  131. if( g_flMaxSpeed[iId][ShieldMaxSpeed]
  132. && get_pdata_int(get_pdata_cbase(iWeapon, m_pPlayer, XO_WEAPON), OFFSET_SHIELD, XO_PLAYER) & HAS_AND_USES_SHIELD == HAS_AND_USES_SHIELD )
  133. {
  134. SetHamReturnFloat( g_flMaxSpeed[iId][ShieldMaxSpeed] )
  135. }
  136. else if( g_flMaxSpeed[iId][ZoomedMaxSpeed]
  137. && get_pdata_int(get_pdata_cbase(iWeapon, m_pPlayer, XO_WEAPON), m_iFOV, XO_PLAYER) != 90 )
  138. {
  139. SetHamReturnFloat( g_flMaxSpeed[iId][ZoomedMaxSpeed] )
  140. }
  141. else
  142. {
  143. SetHamReturnFloat( g_flMaxSpeed[iId][DefaultMaxSpeed] )
  144. }
  145. return HAM_SUPERCEDE
  146. }
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.