Guest User

Untitled

a guest
Oct 6th, 2022
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.56 KB | None | 0 0
  1. include <amxmodx>
  2. #include <hamsandwich>
  3. #include <fakemeta>
  4. #include <cstrike>
  5. #include <xs>
  6.  
  7. #define PLUGIN "[DD2] Modele granatow CS:GO"
  8. #define VERSION "1.4"
  9. #define AUTHOR "Leqally"
  10.  
  11. new const grenadeModels[][][] = {
  12. { "models/OnlyDD2_2k21/nades_csgo/w_hegrenade.mdl", "models/OnlyDD2_2k21/nades_csgo/v_hegrenade.mdl", "models/OnlyDD2_2k21/nades_csgo/p_hegrenade.mdl" },
  13. { "models/OnlyDD2_2k21/nades_csgo/w_flashbang.mdl", "models/OnlyDD2_2k21/nades_csgo/v_flashbang.mdl", "models/OnlyDD2_2k21/nades_csgo/p_flashbang.mdl" },
  14. { "models/OnlyDD2_2k21/nades_csgo/w_smokegrenade.mdl", "models/OnlyDD2_2k21/nades_csgo/v_smokegrenade.mdl", "models/OnlyDD2_2k21/nades_csgo/p_smokegrenade.mdl" }
  15. };
  16.  
  17. new const grenadeNames[][] = { "weapon_flashbang", "weapon_hegrenade", "weapon_smokegrenade" };
  18.  
  19. new const Float:velocityMultiplier[] = { 1.0, 0.7, 0.45 };
  20.  
  21. enum { HEGRENADE, FLASHBANG, SMOKEGRENADE };
  22. enum { W_MODEL, V_MODEL, P_MODEL };
  23. enum { NORMAL, MEDIUM, SHORT };
  24.  
  25. new grenadeThrow[1];
  26.  
  27. public plugin_init()
  28. {
  29. register_plugin(PLUGIN, VERSION, AUTHOR);
  30.  
  31. for (new i = 0; i < sizeof grenadeNames; i++) {
  32. RegisterHam(Ham_Item_Deploy, grenadeNames[i], "grenade_deploy_model", true);
  33. RegisterHam(Ham_Weapon_SecondaryAttack, grenadeNames[i], "grenade_secondary_attack", false);
  34. }
  35.  
  36. register_forward(FM_SetModel, "grenade_world_model", false);
  37. }
  38.  
  39. public plugin_precache()
  40. {
  41. for (new i = 0; i < sizeof(grenadeModels); i++) {
  42. for (new j = 0; j < sizeof(grenadeModels); j++) {
  43. precache_model(grenadeModels[i][j]);
  44. }
  45. }
  46. }
  47.  
  48. public grenade_deploy_model(weapon)
  49. {
  50. static id; id = get_pdata_cbase(weapon, 41, 4);
  51.  
  52. if (!is_user_alive(id)) return HAM_IGNORED;
  53.  
  54. switch (cs_get_weapon_id(weapon)) {
  55. case CSW_HEGRENADE: {
  56. set_pev(id, pev_weaponmodel2, grenadeModels[HEGRENADE][P_MODEL]);
  57. set_pev(id, pev_viewmodel2, grenadeModels[HEGRENADE][V_MODEL]);
  58. }
  59. case CSW_FLASHBANG: {
  60. set_pev(id, pev_weaponmodel2, grenadeModels[FLASHBANG][P_MODEL]);
  61. set_pev(id, pev_viewmodel2, grenadeModels[FLASHBANG][V_MODEL]);
  62. }
  63. case CSW_SMOKEGRENADE: {
  64. set_pev(id, pev_weaponmodel2, grenadeModels[SMOKEGRENADE][P_MODEL]);
  65. set_pev(id, pev_viewmodel2, grenadeModels[SMOKEGRENADE][V_MODEL]);
  66. }
  67. }
  68.  
  69. return HAM_IGNORED;
  70. }
  71.  
  72. public grenade_world_model(ent, model[])
  73. {
  74. static id; id = pev(ent, pev_owner);
  75.  
  76. if (!is_user_connected(id)) return FMRES_IGNORED;
  77.  
  78. if (model[0] == 'm' && model[7] == 'w' && model[8] == '_') {
  79. if (contain(model[9], "hegrenade") != -1) {
  80. engfunc(EngFunc_SetModel, ent, grenadeModels[HEGRENADE][W_MODEL]);
  81.  
  82. return FMRES_SUPERCEDE;
  83. } else if (contain(model[9], "flashbang") != -1) {
  84. engfunc(EngFunc_SetModel, ent, grenadeModels[FLASHBANG][W_MODEL]);
  85.  
  86. return FMRES_SUPERCEDE;
  87. } else if (contain(model[9], "smokegrenade") != -1) {
  88. engfunc(EngFunc_SetModel, ent, grenadeModels[SMOKEGRENADE][W_MODEL]);
  89.  
  90. return FMRES_SUPERCEDE;
  91. }
  92. }
  93.  
  94. return FMRES_IGNORED;
  95. }
  96.  
  97. public grenade_secondary_attack(const ent)
  98. {
  99. if (pev_valid(ent)) {
  100. new id = get_pdata_cbase(ent, 41, 4), buttons = pev(id, pev_button);
  101.  
  102. grenadeThrow[id] = (buttons & IN_ATTACK) ? MEDIUM : SHORT;
  103.  
  104. ExecuteHamB(Ham_Weapon_PrimaryAttack, ent);
  105. }
  106. }
  107.  
  108. public grenade_throw(id, ent, weapon)
  109. {
  110. if (pev_valid(ent)) {
  111. new Float:grenadeVelocity[3];
  112.  
  113. pev(ent, pev_velocity, grenadeVelocity);
  114.  
  115. new Float:multiplier = velocityMultiplier[grenadeThrow[id]];
  116.  
  117. xs_vec_mul_scalar(grenadeVelocity, multiplier, grenadeVelocity);
  118.  
  119. set_pev(ent, pev_velocity, grenadeVelocity);
  120.  
  121. grenadeThrow[id] = NORMAL;
  122. }
  123. }
Advertisement
Add Comment
Please, Sign In to add comment