HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. //------------------------------------------------------------------------------
  2. #include <amxmodx>
  3. #include <engine>
  4. #include <fakemeta>
  5. //------------------------------------------------------------------------------
  6. #include <zp50_ammopacks>
  7. #include <zp50_class_nemesis>
  8. #include <zp50_class_survivor>
  9. #include <zp50_colorchat>
  10. //------------------------------------------------------------------------------
  11. #define PLUGIN "Zombie Plague Parachute"
  12. #define VERSION "1.3"
  13. #define AUTHOR "H.RED.ZONE"
  14. //------------------------------------------------------------------------------
  15. new bool:has_parachute[33], para_ent[33], pDetach, pFallSpeed, pEnabled, pCost
  16. //------------------------------------------------------------------------------
  17. new const MODEL_H[] = "models/RZ/parachute.mdl" //Models Human
  18. new const MODEL_Z[] = "models/RZ/parachute.mdl" //Models Zombie
  19. new const MODEL_S[] = "models/RZ/parachute.mdl" //Models Survivor
  20. new const MODEL_N[] = "models/RZ/parachute.mdl" //Models Nemesis
  21. //------------------------------------------------------------------------------
  22. public plugin_init() {
  23. //------------------------------------------------------------------------------
  24. register_plugin(PLUGIN, VERSION, AUTHOR)
  25. //------------------------------------------------------------------------------
  26. pEnabled = register_cvar("sv_parachute", "1" ) //Enable parachute
  27. pFallSpeed = register_cvar("parachute_fallspeed", "50") //Fall speed
  28. pDetach = register_cvar("parachute_detach", "1") //Don't change
  29. pCost = register_cvar("parachute_cost", "0") //Cost If set to 0 parachute is free.
  30. //------------------------------------------------------------------------------
  31. register_clcmd("say /pb", "buy_parachute")
  32. register_clcmd("say /parachute", "buy_parachute")
  33. register_clcmd("say_team /pb", "buy_parachute")
  34. register_clcmd("say_team /parachute", "buy_parachute")
  35. //------------------------------------------------------------------------------
  36. register_event("ResetHUD", "newSpawn", "be")
  37. register_event("DeathMsg", "death_event", "a")
  38. //------------------------------------------------------------------------------
  39. register_forward(FM_CmdStart, "fw_Start")
  40. //------------------------------------------------------------------------------
  41. }
  42. //------------------------------------------------------------------------------
  43. public plugin_precache() {
  44. precache_model(MODEL_Z)
  45. precache_model(MODEL_N)
  46. precache_model(MODEL_H)
  47. precache_model(MODEL_S)
  48. }
  49. //------------------------------------------------------------------------------
  50. public client_connect(id) {
  51. parachute_reset(id)
  52. }
  53. //------------------------------------------------------------------------------
  54. public client_disconnect(id) {
  55. parachute_reset(id)
  56. }
  57. //------------------------------------------------------------------------------
  58. public death_event() {
  59. new id = read_data(2)
  60. parachute_reset(id)
  61. }
  62. //------------------------------------------------------------------------------
  63. parachute_reset(id) {
  64. if(para_ent[id] > 0) {
  65. if (is_valid_ent(para_ent[id])) {
  66. remove_entity(para_ent[id])
  67. }
  68. }
  69. }
  70. //------------------------------------------------------------------------------
  71. public newSpawn(id) {
  72. if(para_ent[id] > 0) {
  73. remove_entity(para_ent[id])
  74. para_ent[id] = 0
  75. }
  76.  
  77. if (get_pcvar_num(pCost) <= 0) {
  78. has_parachute[id] = true
  79. }
  80. }
  81. //------------------------------------------------------------------------------
  82. public buy_parachute(id) {
  83. if (!is_user_connected(id)) return PLUGIN_CONTINUE
  84.  
  85. if (!get_pcvar_num(pEnabled)) {
  86. return PLUGIN_HANDLED
  87. }
  88.  
  89. if (has_parachute[id]) {
  90. zp_colored_print(id, "Neked nem kell ^x04 ejtoernyot ^x01 venni.")
  91. return PLUGIN_HANDLED
  92. }
  93.  
  94. new money = zp_ammopacks_get(id)
  95. new cost = get_pcvar_num(pCost)
  96.  
  97. if (money < cost) {
  98. return PLUGIN_HANDLED
  99. }
  100. zp_colored_print(id, "Neked van^x04 ejtoernyod.")
  101. zp_ammopacks_set(id, money - cost)
  102. has_parachute[id] = true
  103.  
  104. return PLUGIN_HANDLED
  105. }
  106. //------------------------------------------------------------------------------
  107. public fw_Start(id)
  108. {
  109.  
  110. if (!get_pcvar_num(pEnabled)) return
  111. if (!is_user_alive(id) || !has_parachute[id]) return
  112.  
  113. new Float:fallspeed = get_pcvar_float(pFallSpeed) * -1.0
  114. new Float:frame
  115.  
  116. new button = get_user_button(id)
  117. new oldbutton = get_user_oldbutton(id)
  118. new flags = get_entity_flags(id)
  119.  
  120. if (para_ent[id] > 0 && (flags & FL_ONGROUND)) {
  121.  
  122. if (get_pcvar_num(pDetach)) {
  123.  
  124. if (entity_get_int(para_ent[id],EV_INT_sequence) != 2) {
  125. entity_set_int(para_ent[id], EV_INT_sequence, 2)
  126. entity_set_int(para_ent[id], EV_INT_gaitsequence, 1)
  127. entity_set_float(para_ent[id], EV_FL_frame, 0.0)
  128. entity_set_float(para_ent[id], EV_FL_fuser1, 0.0)
  129. entity_set_float(para_ent[id], EV_FL_animtime, 0.0)
  130. entity_set_float(para_ent[id], EV_FL_framerate, 0.0)
  131. return
  132. }
  133.  
  134. frame = entity_get_float(para_ent[id],EV_FL_fuser1) + 2.0
  135. entity_set_float(para_ent[id],EV_FL_fuser1,frame)
  136. entity_set_float(para_ent[id],EV_FL_frame,frame)
  137.  
  138. if (frame > 254.0) {
  139. remove_entity(para_ent[id])
  140. para_ent[id] = 0
  141. }
  142. }
  143. else {
  144. remove_entity(para_ent[id])
  145. para_ent[id] = 0
  146. }
  147.  
  148. return
  149. }
  150.  
  151. if (button & IN_USE) {
  152.  
  153. new Float:velocity[3]
  154. entity_get_vector(id, EV_VEC_velocity, velocity)
  155.  
  156. if (velocity[2] < 0.0) {
  157.  
  158. if(para_ent[id] <= 0) {
  159. para_ent[id] = create_entity("info_target")
  160. if(para_ent[id] > 0) {
  161. entity_set_string(para_ent[id],EV_SZ_classname,"parachute")
  162. entity_set_edict(para_ent[id], EV_ENT_aiment, id)
  163. entity_set_edict(para_ent[id], EV_ENT_owner, id)
  164. entity_set_int(para_ent[id], EV_INT_movetype, MOVETYPE_FOLLOW)
  165. entity_set_int(para_ent[id], EV_INT_sequence, 0)
  166. entity_set_int(para_ent[id], EV_INT_gaitsequence, 1)
  167. entity_set_float(para_ent[id], EV_FL_frame, 0.0)
  168. entity_set_float(para_ent[id], EV_FL_fuser1, 0.0)
  169.  
  170. if (zp_core_is_zombie(id))
  171. {
  172. entity_set_model(para_ent[id], MODEL_Z)
  173. }
  174. if (!zp_core_is_zombie(id))
  175. {
  176. entity_set_model(para_ent[id], MODEL_H)
  177. }
  178. if (zp_class_survivor_get(id))
  179. {
  180. entity_set_model(para_ent[id], MODEL_S)
  181. }
  182. if (zp_class_nemesis_get(id))
  183. {
  184. entity_set_model(para_ent[id], MODEL_N)
  185. }
  186. }
  187. }
  188.  
  189. if (para_ent[id] > 0) {
  190.  
  191. entity_set_int(id, EV_INT_sequence, 3)
  192. entity_set_int(id, EV_INT_gaitsequence, 1)
  193. entity_set_float(id, EV_FL_frame, 1.0)
  194. entity_set_float(id, EV_FL_framerate, 1.0)
  195.  
  196. velocity[2] = (velocity[2] + 40.0 < fallspeed) ? velocity[2] + 40.0 : fallspeed
  197. entity_set_vector(id, EV_VEC_velocity, velocity)
  198.  
  199. if (entity_get_int(para_ent[id],EV_INT_sequence) == 0) {
  200.  
  201. frame = entity_get_float(para_ent[id],EV_FL_fuser1) + 1.0
  202. entity_set_float(para_ent[id],EV_FL_fuser1,frame)
  203. entity_set_float(para_ent[id],EV_FL_frame,frame)
  204.  
  205. if (frame > 100.0) {
  206. entity_set_float(para_ent[id], EV_FL_animtime, 0.0)
  207. entity_set_float(para_ent[id], EV_FL_framerate, 0.4)
  208. entity_set_int(para_ent[id], EV_INT_sequence, 1)
  209. entity_set_int(para_ent[id], EV_INT_gaitsequence, 1)
  210. entity_set_float(para_ent[id], EV_FL_frame, 0.0)
  211. entity_set_float(para_ent[id], EV_FL_fuser1, 0.0)
  212. }
  213. }
  214. }
  215. }
  216. else if (para_ent[id] > 0) {
  217. remove_entity(para_ent[id])
  218. para_ent[id] = 0
  219. }
  220. }
  221. else if ((oldbutton & IN_USE) && para_ent[id] > 0 ) {
  222. remove_entity(para_ent[id])
  223. para_ent[id] = 0
  224. }
  225. }
  226. //------------------------------------------------------------------------------
  227. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  228. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
  229. */
  230.