HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /*================================================================================
  2.  
  3. Deagle Sniper
  4. Copyright (C) 2009 by fezh
  5.  
  6. This program is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with this program. If not, see <http://www.gnu.org/licenses/>.
  18.  
  19. In addition, as a special exception, the author gives permission to
  20. link the code of this program with the Half-Life Game Engine ("HL
  21. Engine") and Modified Game Libraries ("MODs") developed by Valve,
  22. L.L.C ("Valve"). You must obey the GNU General Public License in all
  23. respects for all of the code used other than the HL Engine and MODs
  24. from Valve. If you modify this file, you may extend this exception
  25. to your version of the file, but you are not obligated to do so. If
  26. you do not wish to do so, delete this exception statement from your
  27. version.
  28.  
  29. =================================================================================*/
  30.  
  31. #include <amxmodx>
  32. #include <fakemeta>
  33. #include <hamsandwich>
  34.  
  35. #define PLUGIN_VERSION "0.1.3"
  36.  
  37. const m_iFOV = 363
  38. const m_iPlayer = 41
  39. const m_iClipAmmo = 51
  40. const m_iExtraOffsetLinux = 4
  41. const m_iExtraOffsetWindows = 0
  42.  
  43. #pragma semicolon 1
  44.  
  45. new model_deagle_sniper[] = "models/v_deagle_new.mdl";
  46.  
  47. new gAlive[33];
  48. new gZoom[33];
  49. new gReloading[33];
  50.  
  51. public plugin_precache()
  52. engfunc(EngFunc_PrecacheModel, model_deagle_sniper);
  53.  
  54. public plugin_init()
  55. {
  56. register_plugin("Deagle Sniper", PLUGIN_VERSION, "fezh");
  57.  
  58. register_forward(FM_CmdStart, "fwCmdStart");
  59.  
  60. RegisterHam(Ham_Spawn, "player", "fwPlayerSpawnPost", 1);
  61. RegisterHam(Ham_Killed, "player", "fwPlayerKilled");
  62. RegisterHam(Ham_Weapon_Reload, "weapon_deagle", "fwWeaponReload");
  63. RegisterHam(Ham_Item_Deploy, "weapon_deagle", "fwItemDeployPost", 1);
  64.  
  65. register_cvar("deagle_sniper", PLUGIN_VERSION, FCVAR_SERVER|FCVAR_SPONLY);
  66. }
  67.  
  68. public fwCmdStart(id, uc_handle, seed)
  69. {
  70. if (!gAlive[id]) return FMRES_IGNORED;
  71.  
  72. static button, oldbuttons, weapon;
  73. button = get_uc(uc_handle, UC_Buttons);
  74. oldbuttons = pev(id, pev_oldbuttons);
  75. weapon = get_user_weapon(id);
  76.  
  77. if ((button & IN_ATTACK2) && !(oldbuttons & IN_ATTACK2))
  78. {
  79. if (weapon == CSW_DEAGLE)
  80. {
  81. if (!gZoom[id] && !gReloading[id])
  82. {
  83. gZoom[id] = true;
  84. set_pdata_int(id, m_iFOV, 35, 5);
  85. emit_sound(id, CHAN_ITEM, "weapons/zoom.wav", 0.20, 2.40, 0, 100);
  86. }
  87. else
  88. {
  89. if (gZoom[id])
  90. {
  91. gZoom[id] = false;
  92. set_pdata_int(id, m_iFOV, 90, 5);
  93. }
  94. }
  95. }
  96. }
  97. return FMRES_IGNORED;
  98. }
  99.  
  100. public fwPlayerSpawnPost(id) if (is_user_alive(id)) gAlive[id] = true;
  101.  
  102. public fwPlayerKilled(victim, attacker, shouldgib) gAlive[victim] = false;
  103.  
  104. public fwWeaponReload(weapon)
  105. {
  106. if (fm_get_weapon_ammo(weapon) != 7)
  107. {
  108. static id;
  109. id = get_pdata_cbase(weapon, m_iPlayer, 4);
  110.  
  111. set_pdata_int(id, m_iFOV, 90, 5);
  112.  
  113. gReloading[id] = true;
  114. set_task(2.3, "taskWeaponReloaded", id);
  115. }
  116. }
  117.  
  118. public taskWeaponReloaded(id)
  119. gReloading[id] = false;
  120.  
  121. public fwItemDeployPost(weapon)
  122. {
  123. static id;
  124. id = get_pdata_cbase(weapon, m_iPlayer, 4);
  125.  
  126. set_pev(id, pev_viewmodel2, model_deagle_sniper);
  127. }
  128.  
  129. // cs_to_fm
  130. stock fm_get_weapon_ammo(weapon)
  131. return get_pdata_int(weapon, m_iClipAmmo, is_linux_server() ? m_iExtraOffsetLinux : m_iExtraOffsetWindows);