mihay111

bhop

Mar 14th, 2020
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. /*
  2. *
  3. * Author: Cheesy Peteza
  4. * Date: 22-Apr-2004 (updated 2-March-2005)
  5. *
  6. *
  7. * Description: Enable bunny hopping in Counter-Strike.
  8. *
  9. * Cvars:
  10. * bh_enabled 1 to enable this plugin, 0 to disable.
  11. * bh_autojump If set to 1 players just need to hold down jump to bunny hop (no skill required)
  12. * bh_showusage If set to 1 it will inform joining players that bunny hopping has been enabled
  13. * and how to use it if bh_autojump enabled.
  14. *
  15. * Requirements: AMXModX 0.16 or greater
  16. *
  17. *
  18. */
  19.  
  20. #include <amxmodx>
  21. #include <engine>
  22.  
  23. #define FL_WATERJUMP (1<<11) // player jumping out of water
  24. #define FL_ONGROUND (1<<9) // At rest / on the ground
  25.  
  26. public plugin_init() {
  27. register_plugin("Super Bunny Hopper", "1.2", "Cheesy Peteza")
  28. register_cvar("sbhopper_version", "1.2", FCVAR_SERVER)
  29.  
  30. register_cvar("bh_enabled", "1")
  31. register_cvar("bh_autojump", "1")
  32. register_cvar("bh_showusage", "1")
  33. }
  34.  
  35. public client_PreThink(id) {
  36. if (!get_cvar_num("bh_enabled"))
  37. return PLUGIN_CONTINUE
  38.  
  39. entity_set_float(id, EV_FL_fuser2, 0.0) // Disable slow down after jumping
  40.  
  41. if (!get_cvar_num("bh_autojump"))
  42. return PLUGIN_CONTINUE
  43.  
  44. // Code from CBasePlayer::Jump (player.cpp) Make a player jump automatically
  45. if (entity_get_int(id, EV_INT_button) & 2) { // If holding jump
  46. new flags = entity_get_int(id, EV_INT_flags)
  47.  
  48. if (flags & FL_WATERJUMP)
  49. return PLUGIN_CONTINUE
  50. if ( entity_get_int(id, EV_INT_waterlevel) >= 2 )
  51. return PLUGIN_CONTINUE
  52. if ( !(flags & FL_ONGROUND) )
  53. return PLUGIN_CONTINUE
  54.  
  55. new Float:velocity[3]
  56. entity_get_vector(id, EV_VEC_velocity, velocity)
  57. velocity[2] += 250.0
  58. entity_set_vector(id, EV_VEC_velocity, velocity)
  59.  
  60. entity_set_int(id, EV_INT_gaitsequence, 6) // Play the Jump Animation
  61. }
  62. return PLUGIN_CONTINUE
  63. }
  64.  
  65. public client_authorized(id)
  66. set_task(30.0, "showUsage", id)
  67.  
  68. public showUsage(id) {
  69. if ( !get_cvar_num("bh_enabled") || !get_cvar_num("bh_showusage") )
  70. return PLUGIN_HANDLED
  71.  
  72. if ( !get_cvar_num("bh_autojump") ) {
  73. client_print(id, print_chat, "[AMX] Bunny hopping is enabled on this server. You will not slow down after jumping.")
  74. } else {
  75. client_print(id, print_chat, "[AMX] Auto bunny hopping is enabled on this server. Just hold down jump to bunny hop.")
  76. }
  77. return PLUGIN_HANDLED
  78. }
Add Comment
Please, Sign In to add comment