HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <engine>
  3.  
  4. #define PLUGIN "Jump Menu"
  5. #define VERSION "2.0"
  6. #define AUTHOR "v3x"
  7.  
  8. #define MAX_PLAYERS 33
  9.  
  10. static const CVAR_MAX_JUMPS[] = "amx_maxjumps";
  11. static const CVAR_WJ_STRENGTH[] = "walljump_strength";
  12. static const CVAR_WJ_NUM[] = "walljump_num";
  13. static const CVAR_WJ_TEAM[] = "walljump_team";
  14.  
  15. new PCVAR_MAX_JUMPS;
  16. new PCVAR_WJ_STRENGTH;
  17. new PCVAR_WJ_NUM;
  18. new PCVAR_WJ_TEAM;
  19.  
  20. new bool:caughtJump[MAX_PLAYERS];
  21. new bool:doWJump[MAX_PLAYERS];
  22. new Float:jumpVeloc[MAX_PLAYERS][3];
  23. new newButton[MAX_PLAYERS];
  24. new numJumps[MAX_PLAYERS];
  25. new team[MAX_PLAYERS];
  26. new wallteam;
  27.  
  28. public plugin_init()
  29. {
  30. register_plugin(PLUGIN , VERSION , AUTHOR);
  31.  
  32. register_clcmd("say /ugrasmenu" , "ClCmd_JumpMenu");
  33. register_clcmd("ugrasmenu" , "ClCmd_JumpMenu");
  34.  
  35. if(!cvar_exists(CVAR_MAX_JUMPS))
  36. PCVAR_MAX_JUMPS = register_cvar(CVAR_MAX_JUMPS , "2");
  37. else
  38. PCVAR_MAX_JUMPS = -1;
  39.  
  40. PCVAR_WJ_STRENGTH = register_cvar(CVAR_WJ_STRENGTH , "300.0");
  41. PCVAR_WJ_NUM = register_cvar(CVAR_WJ_NUM , "3");
  42. PCVAR_WJ_TEAM = register_cvar(CVAR_WJ_TEAM , "0");
  43.  
  44. register_touch("player" , "worldspawn" , "Touch_World");
  45. register_touch("player" , "func_wall" , "Touch_World");
  46. register_touch("player" , "func_breakable" , "Touch_World");
  47. }
  48.  
  49. enum
  50. {
  51. JUMP_REGULAR = 0,
  52. JUMP_MULTI,
  53. JUMP_BUNNY,
  54. JUMP_WALL
  55. }
  56.  
  57. new g_iJumpType[33];
  58. new jumpnum[33];
  59. new bool:dojump[33];
  60.  
  61. public client_putinserver(id)
  62. {
  63. g_iJumpType[id] = JUMP_MULTI;
  64. jumpnum[id] = 0;
  65. dojump[id] = false;
  66. }
  67.  
  68. public client_disconnect(id)
  69. {
  70. jumpnum[id] = 0;
  71. dojump[id] = false;
  72.  
  73. caughtJump[id] = false;
  74. doWJump[id] = false;
  75. for(new x = 0; x < 3; x++)
  76. jumpVeloc[id][x] = 0.0;
  77. newButton[id] = 0;
  78. numJumps[id] = 0;
  79. }
  80.  
  81. public ClCmd_JumpMenu(id)
  82. {
  83. new menu = menu_create("Valasz ugras tipust:" , "menuHandler_Jump");
  84.  
  85. menu_additem(menu , "3 Ugras" , "" , 0);
  86. menu_additem(menu , "Nyul Ugras" , "" , 0);
  87. menu_additem(menu , "Fal Ugras^n" , "" , 0);
  88. menu_additem(menu , "Rendes Ugras" , "" , 0);
  89.  
  90. menu_setprop(menu , MPROP_EXIT , MEXIT_ALL);
  91.  
  92. menu_display(id , menu , 0);
  93.  
  94. new arg[21];
  95. read_argv(0 , arg , 20);
  96. if(!contain(arg , "say"))
  97. return PLUGIN_CONTINUE;
  98.  
  99. return PLUGIN_HANDLED;
  100. }
  101.  
  102. public menuHandler_Jump(id , menu , item)
  103. {
  104. if(item == MENU_EXIT)
  105. {
  106. menu_destroy(menu);
  107. return PLUGIN_HANDLED;
  108. }
  109.  
  110. new szCommand[6] , szName[64];
  111. new access , callback;
  112.  
  113. menu_item_getinfo(menu , item , access , szCommand , 5 , szName , 63 , callback);
  114.  
  115. if(equal(szName , "Multi-jump"))
  116. {
  117. client_print(id , print_chat , "[AMXX] 3 Ugras bekapcsolva!");
  118. g_iJumpType[id] = JUMP_MULTI;
  119.  
  120. menu_destroy(menu); return PLUGIN_CONTINUE;
  121. }
  122. else if(equal(szName , "Bunnyhop"))
  123. {
  124. client_print(id , print_chat , "[AMXX] Nyul Ugras bekapcsolva!");
  125. g_iJumpType[id] = JUMP_BUNNY;
  126.  
  127. menu_destroy(menu); return PLUGIN_CONTINUE;
  128. }
  129. else if(equal(szName , "Wall Jump^n"))
  130. {
  131. client_print(id , print_chat , "[AMXX] Fal Ugras bekapcsolva!");
  132. g_iJumpType[id] = JUMP_WALL;
  133.  
  134. menu_destroy(menu); return PLUGIN_CONTINUE;
  135. }
  136. else
  137. {
  138. client_print(id , print_chat , "[AMXX] Rendes Ugras bekapcsolva!");
  139. g_iJumpType[id] = JUMP_REGULAR;
  140.  
  141. menu_destroy(menu); return PLUGIN_CONTINUE;
  142. }
  143.  
  144. menu_destroy(menu);
  145.  
  146. return PLUGIN_HANDLED;
  147. }
  148.  
  149. public client_PreThink(id)
  150. {
  151. if(!is_user_alive(id) || !g_iJumpType[id])
  152. return PLUGIN_CONTINUE;
  153.  
  154. if(g_iJumpType[id] == JUMP_BUNNY)
  155. {
  156. entity_set_float(id, EV_FL_fuser2, 0.0) // Disable slow down after jumping
  157.  
  158. // Code from CBasePlayer::Jump (player.cpp) Make a player jump automatically
  159. if (entity_get_int(id, EV_INT_button) & 2) { // If holding jump
  160. new flags = entity_get_int(id, EV_INT_flags)
  161.  
  162. if (flags & FL_WATERJUMP)
  163. return PLUGIN_CONTINUE
  164. if ( entity_get_int(id, EV_INT_waterlevel) >= 2 )
  165. return PLUGIN_CONTINUE
  166. if ( !(flags & FL_ONGROUND) )
  167. return PLUGIN_CONTINUE
  168.  
  169. new Float:velocity[3]
  170. entity_get_vector(id, EV_VEC_velocity, velocity)
  171. velocity[2] += 250.0
  172. entity_set_vector(id, EV_VEC_velocity, velocity)
  173.  
  174. entity_set_int(id, EV_INT_gaitsequence, 6) // Play the Jump Animation
  175.  
  176. return PLUGIN_CONTINUE;
  177. }
  178. }
  179. else if(g_iJumpType[id] == JUMP_MULTI)
  180. {
  181. if((get_user_button(id) & IN_JUMP) && !(get_entity_flags(id) & FL_ONGROUND) && !(get_user_oldbutton(id) & IN_JUMP))
  182. {
  183. if(jumpnum[id] < get_pcvar_num(PCVAR_MAX_JUMPS))
  184. {
  185. dojump[id] = true
  186. jumpnum[id]++
  187. return PLUGIN_CONTINUE
  188. }
  189. }
  190. if((get_user_button(id) & IN_JUMP) && (get_entity_flags(id) & FL_ONGROUND))
  191. {
  192. jumpnum[id] = 0
  193. return PLUGIN_CONTINUE
  194. }
  195. }
  196. else if(g_iJumpType[id] == JUMP_WALL)
  197. {
  198. wallteam = get_pcvar_num(PCVAR_WJ_TEAM)
  199. team[id] = get_user_team(id)
  200. if(!wallteam || wallteam == team[id])
  201. {
  202. newButton[id] = get_user_button(id)
  203. new oldButton = get_user_oldbutton(id)
  204. new flags = get_entity_flags(id)
  205.  
  206. //reset if we are on ground
  207. if(caughtJump[id] && (flags & FL_ONGROUND))
  208. {
  209. numJumps[id] = 0
  210. caughtJump[id] = false
  211. }
  212.  
  213. //begin when we jump
  214. if((newButton[id] & IN_JUMP) && (flags & FL_ONGROUND) && !caughtJump[id] && !(oldButton & IN_JUMP) && !numJumps[id])
  215. {
  216. caughtJump[id] = true
  217. entity_get_vector(id,EV_VEC_velocity,jumpVeloc[id])
  218. jumpVeloc[id][2] = get_pcvar_float(PCVAR_WJ_STRENGTH)
  219. }
  220. }
  221. }
  222. return PLUGIN_CONTINUE;
  223. }
  224.  
  225. public client_PostThink(id)
  226. {
  227. if((g_iJumpType[id] != JUMP_MULTI && g_iJumpType[id] != JUMP_WALL) || !is_user_alive(id))
  228. return PLUGIN_CONTINUE
  229.  
  230. if(dojump[id])
  231. {
  232. new Float:velocity[3]
  233. entity_get_vector(id,EV_VEC_velocity,velocity)
  234. velocity[2] = random_float(265.0,285.0)
  235. entity_set_vector(id,EV_VEC_velocity,velocity)
  236. dojump[id] = false
  237.  
  238. return PLUGIN_CONTINUE
  239. }
  240. //do velocity if we walljumped
  241. else if(doWJump[id])
  242. {
  243. entity_set_vector(id,EV_VEC_velocity,jumpVeloc[id])
  244.  
  245. doWJump[id] = false
  246.  
  247. if(numJumps[id] >= get_pcvar_num(PCVAR_WJ_NUM)) //reset if we ran out of jumps
  248. {
  249. numJumps[id] = 0
  250. caughtJump[id] = false
  251. }
  252. }
  253. return PLUGIN_CONTINUE
  254. }
  255.  
  256. public Touch_World(id, world)
  257. {
  258. if(is_user_alive(id) && g_iJumpType[id] == JUMP_WALL)
  259. {
  260. //if we touch wall and have jump pressed, setup for jump
  261. if(caughtJump[id] && (newButton[id] & IN_JUMP) && !(get_entity_flags(id) & FL_ONGROUND))
  262. {
  263. //reverse velocity
  264. for(new x=0;x<2;x++)
  265. jumpVeloc[id][x] *= -1.0
  266.  
  267. numJumps[id]++
  268. doWJump[id] = true
  269. }
  270. }
  271. }