HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <fun>
  4. #include <engine>
  5.  
  6. //Used for create_middle functions
  7. #define tag_sprite_size_horizontal 4000
  8. #define tag_sprite_size_vertical 600
  9. #define tag_sprite_vertical_increments 15
  10.  
  11. #define MINNUM 2
  12.  
  13. new bool:stopplugin
  14.  
  15. new beamsprite
  16.  
  17. new CTspawn_loc[3]
  18. new Tspawn_loc[3]
  19.  
  20. new plugin_enabled, plugin_fence, plugin_2ppl, plugin_checktime, plugin_redrawtime, plugin_fencecolor, plugin_fencealpha, plugin_punishment
  21.  
  22. new Float:farthest_point1[3]
  23. new Float:farthest_point2[3]
  24. new alivenum, maxplayers
  25.  
  26. new Float:oldtime
  27.  
  28. new multiplier
  29.  
  30. public plugin_init()
  31. {
  32. register_plugin("No Rush","2.0","GHW_Chronic")
  33.  
  34. plugin_enabled = register_cvar("NR_enabled","1")
  35. plugin_fence = register_cvar("NR_fence","1")
  36. plugin_2ppl = register_cvar("NR_twopeople","1")
  37. plugin_punishment = register_cvar("NR_punishment","1")
  38. plugin_checktime = register_cvar("NR_checktime","2.0")
  39. plugin_redrawtime = register_cvar("NR_redrawtime","15.0")
  40. plugin_fencecolor = register_cvar("NR_fencecolor","green")
  41. plugin_fencealpha = register_cvar("NR_fencealpha","200")
  42.  
  43. stopplugin=true
  44. new mapname[32]
  45. get_mapname(mapname,31)
  46. new configfile[200]
  47. get_configsdir(configfile,199)
  48. format(configfile,199,"%s/no_rush_maps.ini",configfile)
  49. if(file_exists(configfile))
  50. {
  51. new read[32], trash
  52. for(new i=0;i<file_size(configfile,1);i++)
  53. {
  54. read_file(configfile,i,read,31,trash)
  55. if(equali(mapname,read))
  56. {
  57. set_task(0.1,"spawn_locs")
  58. set_task(0.2,"create_middle1")
  59. oldtime = get_pcvar_float(plugin_redrawtime)
  60. stopplugin=false
  61. break;
  62. }
  63. }
  64. }
  65.  
  66. register_event("DeathMsg","checknum","a")
  67. register_event("ResetHUD","checknum","b")
  68.  
  69. maxplayers = get_maxplayers()
  70. }
  71.  
  72. public plugin_precache()
  73. {
  74. beamsprite = precache_model("sprites/dot.spr")
  75. }
  76.  
  77. public client_putinserver(id)
  78. {
  79. if(!stopplugin)
  80. {
  81. set_task(get_pcvar_float(plugin_checktime),"prethink",id,"",0,"b")
  82. }
  83. }
  84.  
  85. public client_disconnect(id)
  86. {
  87. remove_task(id)
  88. }
  89.  
  90. public checknum()
  91. {
  92. if(get_pcvar_num(plugin_enabled) && !stopplugin)
  93. {
  94. new newnum
  95. for(new i=0;i<=maxplayers;i++)
  96. {
  97. if(is_user_alive(i)) newnum++
  98. }
  99. if(alivenum>MINNUM && newnum<=MINNUM && get_pcvar_num(plugin_2ppl))
  100. {
  101. client_print(0,print_chat,"[AMXX]Te most mar at tudsz menni a masik oldalra, mivel csak 2 ember maradt.")
  102. }
  103. alivenum=newnum
  104. }
  105. }
  106.  
  107. public prethink(id)
  108. {
  109. if(is_user_alive(id) && !stopplugin && get_pcvar_num(plugin_enabled) && !(alivenum<=MINNUM && get_pcvar_num(plugin_2ppl)) )
  110. {
  111. new origin[3]
  112. get_user_origin(id,origin)
  113. new team[32]
  114. get_user_team(id,team,31)
  115. new teamnum=1
  116. if(containi(team,"CT")!=-1 || containi(team,"Counter")!=-1)
  117. {
  118. teamnum=2
  119. }
  120. if( (get_distance(origin,CTspawn_loc)<get_distance(origin,Tspawn_loc) && teamnum==1) || (get_distance(origin,Tspawn_loc)<get_distance(origin,CTspawn_loc) && teamnum==2) )
  121. {
  122. if(get_pcvar_num(plugin_punishment)==1) user_kill(id)
  123. else
  124. {
  125. new origin[3]
  126. get_user_origin(id,origin)
  127. new Float:vector1[3]
  128. if(teamnum==2)
  129. {
  130. vector1[0] = float(CTspawn_loc[0]) - origin[0]
  131. vector1[1] = float(CTspawn_loc[1]) - origin[1]
  132. vector1[2] = float(CTspawn_loc[2]) - origin[2]
  133. }
  134. else
  135. {
  136. vector1[0] = float(Tspawn_loc[0]) - origin[0]
  137. vector1[1] = float(Tspawn_loc[1]) - origin[1]
  138. vector1[2] = float(Tspawn_loc[2]) - origin[2]
  139. }
  140. new Float:num = floatsqroot(250*250 / vector1[0]*vector1[0] + vector1[1]*vector1[1] + vector1[2]*vector1[2])
  141. vector1[0] *= num
  142. vector1[1] *= num
  143. vector1[2] *= num
  144. set_user_velocity(id,vector1)
  145. }
  146. client_print(id,print_chat,"[AMXX] Ne manj at a kozepso vonalon!")
  147. }
  148. }
  149. }
  150.  
  151. public spawn_locs()
  152. {
  153. new ent1 = find_ent_by_class(0,"info_player_start")
  154. new ent2 = find_ent_by_class(0,"info_player_deathmatch")
  155. if(!ent1)
  156. {
  157. log_amx("No info_player_start found")
  158. stopplugin=true
  159. }
  160. if(!ent2)
  161. {
  162. log_amx("No info_player_deathmatch found")
  163. stopplugin=true
  164. }
  165. new Float:CTspawn_loc_F[3]
  166. new Float:Tspawn_loc_F[3]
  167. entity_get_vector(ent1,EV_VEC_origin,CTspawn_loc_F)
  168. entity_get_vector(ent2,EV_VEC_origin,Tspawn_loc_F)
  169. CTspawn_loc[0] = floatround(CTspawn_loc_F[0])
  170. CTspawn_loc[1] = floatround(CTspawn_loc_F[1])
  171. CTspawn_loc[2] = floatround(CTspawn_loc_F[2])
  172. Tspawn_loc[0] = floatround(Tspawn_loc_F[0])
  173. Tspawn_loc[1] = floatround(Tspawn_loc_F[1])
  174. Tspawn_loc[2] = floatround(Tspawn_loc_F[2])
  175. }
  176.  
  177. public create_middle1()
  178. {
  179. //***
  180. //Simple Algebra to calculate the location of the middle line(s).
  181. //***
  182.  
  183. new Float:CTspawn_loc_F[3]
  184. new Float:Tspawn_loc_F[3]
  185. IVecFVec(CTspawn_loc,CTspawn_loc_F)
  186. IVecFVec(Tspawn_loc,Tspawn_loc_F)
  187.  
  188. new Float:line1_slope = (CTspawn_loc_F[1] - Tspawn_loc_F[1]) / (CTspawn_loc_F[0] - Tspawn_loc_F[0])
  189. new Float:line2_slope = -1.0 * (1.0 / line1_slope)
  190.  
  191. new Float:midpoint[3]
  192. midpoint[0] = (CTspawn_loc_F[0] + Tspawn_loc_F[0]) / 2
  193. midpoint[1] = (CTspawn_loc_F[1] + Tspawn_loc_F[1]) / 2
  194. midpoint[2] = (CTspawn_loc_F[2] + Tspawn_loc_F[2]) / 2
  195.  
  196. if(floatabs(line2_slope)>1.0)
  197. {
  198. farthest_point1[1] = midpoint[1] + (tag_sprite_size_horizontal / 2)
  199. farthest_point2[1] = midpoint[1] - (tag_sprite_size_horizontal / 2)
  200.  
  201. farthest_point1[0] = (farthest_point1[1] - midpoint[1] + (line2_slope * midpoint[0])) / line2_slope
  202. farthest_point2[0] = (farthest_point2[1] - midpoint[1] + (line2_slope * midpoint[0])) / line2_slope
  203. }
  204.  
  205. if(floatabs(line2_slope)<=1.0)
  206. {
  207. farthest_point1[0] = midpoint[0] + (tag_sprite_size_horizontal / 2)
  208. farthest_point2[0] = midpoint[0] - (tag_sprite_size_horizontal / 2)
  209.  
  210. farthest_point1[1] = line2_slope*(farthest_point1[0]-midpoint[0]) + midpoint[1]
  211. farthest_point2[1] = line2_slope*(farthest_point2[0]-midpoint[0]) + midpoint[1]
  212. }
  213.  
  214. farthest_point1[2] = midpoint[2] - (tag_sprite_size_vertical / 2)
  215.  
  216. set_task(get_pcvar_float(plugin_redrawtime),"create_middle2",1337,"",0,"b")
  217. }
  218.  
  219. public create_middle2()
  220. {
  221. if(!stopplugin && get_pcvar_num(plugin_fence) && get_pcvar_num(plugin_enabled) && !(alivenum<=MINNUM && get_pcvar_num(plugin_2ppl)))
  222. {
  223. set_task(0.1,"create_middle3",0,"",0,"a",(tag_sprite_size_vertical / tag_sprite_vertical_increments))
  224. multiplier=1
  225. }
  226. if(oldtime!=get_pcvar_float(plugin_redrawtime))
  227. {
  228. remove_task(1337)
  229. set_task(get_pcvar_float(plugin_redrawtime),"create_middle1",1337,"",0,"b")
  230. oldtime=get_pcvar_float(plugin_redrawtime)
  231. }
  232. }
  233.  
  234. public create_middle3()
  235. {
  236. new zpoint = floatround(farthest_point1[2]) + (multiplier * tag_sprite_vertical_increments)
  237. multiplier++
  238. new color[32], red, green, blue
  239. get_pcvar_string(plugin_fencecolor,color,31)
  240. if(equali(color,"red"))
  241. {
  242. red=255
  243. green=0
  244. blue=0
  245. }
  246. else if(equali(color,"blue"))
  247. {
  248. red=0
  249. green=0
  250. blue=255
  251. }
  252. else if(equali(color,"white"))
  253. {
  254. red=255
  255. green=255
  256. blue=255
  257. }
  258. else if(equali(color,"random"))
  259. {
  260. red=random_num(0,255)
  261. green=random_num(0,255)
  262. blue=random_num(0,255)
  263. }
  264. else if(equali(color,"Yellow"))
  265. {
  266. red = 255
  267. green = 255
  268. blue = 0
  269. }
  270. else if(equali(color,"Orange"))
  271. {
  272. red = 255
  273. green = 128
  274. blue = 64
  275. }
  276. else if(equali(color,"Pink"))
  277. {
  278. red = 255
  279. green = 0
  280. blue = 128
  281. }
  282. else if(equali(color,"Indigo"))
  283. {
  284. red = 0
  285. green = 255
  286. blue = 255
  287. }
  288. else
  289. {
  290. red=0
  291. green=255
  292. blue=0
  293. }
  294.  
  295. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  296. write_byte(0) //TE_BEAMPOINTS
  297. write_coord(floatround(farthest_point1[0]))
  298. write_coord(floatround(farthest_point1[1]))
  299. write_coord(zpoint)
  300. write_coord(floatround(farthest_point2[0]))
  301. write_coord(floatround(farthest_point2[1]))
  302. write_coord(zpoint)
  303. write_short(beamsprite)
  304. write_byte(1) // framestart
  305. write_byte(1) // framerate
  306. write_byte(get_pcvar_num(plugin_redrawtime) * 10)// life in 0.1's
  307. write_byte(5) // width
  308. write_byte(0) // noise
  309. write_byte(red) // red
  310. write_byte(green) // green
  311. write_byte(blue) // blue
  312. write_byte(get_pcvar_num(plugin_fencealpha))// brightness
  313. write_byte(0) // speed
  314. message_end()
  315. }
  316.