Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 39.49 KB | None | 0 0
  1. /*
  2. * Team Flash Control
  3. *
  4. * Author: OT
  5. *
  6. * Plugin Link: http://forums.alliedmods.net/showthread.php?p=651444
  7. *
  8. * Changelog:
  9. *
  10. * 12.0 - remade some forwards, made the plugin more efficient, added cvar for chat messages, made the dynamic light hookable
  11. * 11.0 - added more forwards and natives for the plugin, some isues fixed!
  12. * 10.0 - added forward for the plugin, here you can block a player beeing flashed, and do other stuff.
  13. * 9.5 - new method of remembering the owner! Low on memory usage!
  14. * 9.1 - last improvements + the plugin can now be seen on servers.
  15. * 9.0 - control pannel + last improvements
  16. * 8.5 - new punish system
  17. * 8.1 - cvar bug fix, flashlight bug fix
  18. * 8.0 - new feature -> color flashbangs
  19. * 7.0 - updated all the features, now work 100% + new dynamic light feature
  20. * 6.5 - improvement to the player origin, now the plugin gets the players head
  21. * 6.0 - major improvement to all the blocks (including the new feature)
  22. * 5.5 - small improvement to the moment a player is flashed (when a player is flashed for a long time the flash will count)
  23. * 5.3 - big improvement to the bug detection
  24. * 5.0 - improvement to the new feature
  25. * 5.0b - new feature added -> block flash when you flashed a teammate and a enemy together
  26. * 4.5 - bugfix feature added
  27. * 4.0 - multilang
  28. * 3.5 - added more features, the plugin has a new name "Team Flash Control"
  29. * 3.0 - optimized plugin (pcvars + new forwards) -> now works 100% (2008-07-11)
  30. * 2.0 - optimized plugin -> now works > 70% (2008-07-08)
  31. * 1.1 - fixed bug: more than one player can get a message from the same teamflash event, new cvar: tfc_adminchat (2007-11-04)
  32. * 1.0 - sound on/off cvar: tfc_sound 1/0 (2006-04-14)
  33. * 0.3 - fixed bug: dead spectators will nog get message about teamflash (2006-03-16)
  34. * 0.2 - changed flash owner code, a timer is added, "[Team Flash Snitch]" in green text (2006-03-12)
  35. * 0.1 - initial release (2006-01-25)
  36. *
  37. * Credits:
  38. * Tender for Team Flash Snitch
  39. * MpNumb for Bugfix feature
  40. * xxAvalanchexx for Dynamiclight
  41. * v3x for Colored Flashbangs
  42. */
  43.  
  44. #include <amxmodx>
  45. #include <amxmisc>
  46. #include <cstrike>
  47. #include <fakemeta>
  48. #include <hamsandwich>
  49. #include <xs>
  50.  
  51. // The defines that hold info on how the user has been blinded
  52. #define BLINDED_FULLY 255
  53. #define BLINDED_PARTLY 200
  54.  
  55. // Task unique id
  56. #define REMAIN_TASK 642354
  57.  
  58. // Private data
  59. #define OFFSET_OWNER 41
  60. #define OFFSET_LINUX 4
  61.  
  62. // Macros
  63. #define chars(%1) (sizeof(%1) - 1)
  64.  
  65. // Bitsum useful functions
  66. #define set_block_flash(%0) g_bs_block_flash |= (1<<((%0)-1))
  67. #define can_block_flash(%0) (g_bs_block_flash & (1<<((%0)-1)))
  68.  
  69. #define set_reset_counter(%0) g_bs_reset_counter |= (1<<((%0)-1))
  70. #define del_reset_counter(%0) g_bs_reset_counter &= ~(1<<((%0)-1))
  71. #define can_reset_counter(%0) (g_bs_reset_counter & (1<<((%0)-1)))
  72.  
  73. #define set_can_count(%0) g_bs_counter_in_effect |= (1<<((%0)-1))
  74. #define del_can_count(%0) g_bs_counter_in_effect &= ~(1<<((%0)-1))
  75. #define ply_can_count(%0) (g_bs_counter_in_effect & (1<<((%0)-1)))
  76.  
  77. // Option macros, for easy manuver
  78. #define get_option(%0) get_pcvar_num(pcvars[%0])
  79. #define toggle_option(%0) set_pcvar_num(pcvars[%0], !get_pcvar_num(pcvars[%0]))
  80. #define get_option_float(%0) get_pcvar_float(pcvars[%0])
  81. #define set_option_float(%0, %1) set_pcvar_float(pcvars[%0], %1)
  82. #define set_option_cell(%0, %1) set_pcvar_num(pcvars[%0], %1)
  83.  
  84. // Options
  85. enum Option
  86. {
  87. pc_frc_enable,
  88. pc_frc_chat,
  89. pc_frc_sound,
  90. pc_frc_admin,
  91. pc_frc_block,
  92. pc_frc_selfb,
  93. pc_frc_blocka,
  94.  
  95. pc_frc_count,
  96. pc_frc_punish,
  97. pc_frc_limit,
  98. pc_frc_warn,
  99. pc_frc_mode,
  100. pc_frc_type,
  101. pc_frc_nr_ctr,
  102.  
  103. pc_frc_mcolor,
  104. pc_frc_rcolor,
  105. pc_frc_gcolor,
  106. pc_frc_bcolor,
  107.  
  108. pc_frc_dlight,
  109.  
  110. pc_frc_bug,
  111. }
  112.  
  113.  
  114. // Plugin returns
  115. enum
  116. {
  117. FRC_CONTINUE = 0,
  118. FRC_MAKE_PARTIALLY = 200,
  119. FRC_MAKE_FULLY = 255,
  120. FRC_BLOCK = 300
  121. }
  122.  
  123. // Message events
  124. new saytext
  125. new scrfade
  126.  
  127. // Flasher id
  128. new g_flasher = 0
  129. new CsTeams:g_fl_team
  130.  
  131. // Flash entity index
  132. new g_flash_ent = 0
  133.  
  134. // Player info
  135. new g_flash_mon[33] = {0, ...}
  136. new g_round_lock[33]
  137. new Float:g_time_lock[33]
  138.  
  139. // These are used for forwards, and modified paramaters
  140. new g_last_flashtype[33] = {FRC_BLOCK, ...}
  141. new g_modifdur[33]
  142. new g_modifhold[33]
  143.  
  144. // Bistums, we use this for information storage, check the macros!
  145. new g_bs_block_flash
  146. new g_bs_counter_in_effect
  147. new g_bs_reset_counter
  148.  
  149. // Native coords, and stuff
  150. new g_flashdur[33]
  151. new g_flashhold[33]
  152.  
  153. // Forward info
  154. new bool:g_allow_forward = true
  155.  
  156. // Colors
  157. new g_color_red = 255
  158. new g_color_green = 255
  159. new g_color_blue = 255
  160.  
  161. // Pcvars
  162. enum OptionType
  163. {
  164. OPTION_TOGGLE = 1,
  165. OPTION_CELL,
  166. OPTION_FLOAT
  167. }
  168.  
  169. // Trace & maxplayers
  170. new g_trace
  171. new g_maxplayers
  172.  
  173. // Cvars
  174. new pcvars[Option]
  175. new OptionType:option_type[Option]
  176. new option_value[Option][100]
  177. new option_information[Option][300]
  178.  
  179. // Control pannel
  180. new settingsmenu
  181. new callbacks[2]
  182.  
  183. // Forwards
  184. new g_forward_preflash
  185. new g_forward_postflash
  186. new g_forward_bang
  187. new g_forward_trace
  188. new g_forward_traceb
  189. new g_forward_search
  190. new g_forward_punish
  191. new g_forward_freedata
  192. new g_forward_client
  193. new g_forward_extinit
  194.  
  195. // CFG file (save data)
  196. new const CFG_FILE_NAME[] = "flash_remote_control.cfg"
  197. new CFG_FILE[300]
  198.  
  199. public plugin_init()
  200. {
  201. // Let's register the plugin
  202. register_plugin("Flash Remote Control", "12.0", "OT")
  203. register_cvar("flash_remote_version", "12.0", (FCVAR_SERVER | FCVAR_SPONLY))
  204.  
  205. // The basic cvars
  206. register_option(pc_frc_enable, "frc_enable", "1") // Enable the plugin, this will stop the plugin sending the news but not the forwards!!!
  207. register_option(pc_frc_chat, "frc_chat", "1") // The message you have flashed/been flashed by
  208. register_option(pc_frc_sound, "frc_sound", "1") // the sound that is sent to the flasher
  209. register_option(pc_frc_admin, "frc_adminchat", "1") // the admin messages
  210. register_option(pc_frc_block, "frc_block_team_flash", "1") // block the moment when you flash your teammates
  211. register_option(pc_frc_selfb, "frc_block_self_flash", "1") // block the moment when you flash yourself
  212. register_option(pc_frc_blocka, "frc_block_team_all_flash", "0") // block all players that are flashed if a teammate is flashed
  213.  
  214. // The punish system cvars
  215. register_option(pc_frc_punish, "frc_flasher_punish", "1") // punish the player that flashed too much
  216. register_option(pc_frc_count, "frc_flasher_counter", "1") // 0 -> count only the full flashes 1 -> count all the flashes
  217. register_option(pc_frc_limit, "frc_flasher_mistake_allow", "10", OPTION_CELL) // the times that a player is allowed to flash his teammates before being punished
  218. register_option(pc_frc_warn, "frc_flasher_warn", "0") // warn the player
  219. register_option(pc_frc_mode, "frc_flasher_punish_mode", "2", OPTION_CELL) // punish mode: 0 -> map end, 1 -> rounds, 2 -> time
  220. register_option(pc_frc_type, "frc_flasher_punish_type", "0", OPTION_CELL) // punish type: 0 -> block throw, 1 -> kill when flash, 2 -> flash himself when flash
  221. register_option(pc_frc_nr_ctr, "frc_flasher_punish_control", "2", OPTION_FLOAT) // punish mode control controls how many round/minutes the player will have problems (doesn't work with punish mode 0)
  222.  
  223. // Flash color cvars
  224. register_option(pc_frc_mcolor, "frc_color_mode", "2", OPTION_CELL) // 0 -> off, 1 -> specified color, 2 -> random color chose(for all players), 3 -> random color for every player
  225. register_option(pc_frc_rcolor, "frc_red_color", "100") // the red color cvar
  226. register_option(pc_frc_gcolor, "frc_green_color", "100") // the green color cvar
  227. register_option(pc_frc_bcolor, "frc_blue_color", "255") // the blue color cvar
  228.  
  229. // Flash dynamic light cvars, the dynamic light is affected by the color cvars
  230. register_option(pc_frc_dlight, "frc_dynamic_light", "1") // dynamic light
  231.  
  232. // Bug fix cvar
  233. register_option(pc_frc_bug, "frc_bug_fix", "1") // bug fix control toggle
  234.  
  235. // Special option values
  236. register_option_value(pc_frc_limit, "5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20")
  237. register_option_value(pc_frc_mode, "0;1;2")
  238. register_option_value(pc_frc_type, "0;1;2")
  239. register_option_value(pc_frc_mcolor, "0;1;2;3")
  240.  
  241. // Control panel menu
  242. register_clcmd("amx_flash_control_menu", "conjure_menu", ADMIN_CFG, "Shows settings menu for flashbang remote control.")
  243. register_clcmd("amx_fcm", "conjure_menu", ADMIN_CFG, "Shows settings menu for flashbang remote control.")
  244.  
  245. // The message constants
  246. saytext = get_user_msgid("SayText")
  247. scrfade = get_user_msgid("ScreenFade")
  248.  
  249. // The events
  250. register_event("ScreenFade", "event_blinded", "be", "1>4096", "4=255", "5=255", "6=255", "7>199")
  251. register_logevent("event_round_end", 2, "1=Round_End")
  252.  
  253. // The forwards
  254. register_forward(FM_SetModel, "fw_setmodel", 1)
  255. register_forward(FM_EmitSound, "fw_emitsound", 1)
  256. register_forward(FM_PlayerPreThink, "fw_player_prethink")
  257. register_forward(FM_FindEntityInSphere, "fw_findentityinsphere")
  258.  
  259. // Control pannel
  260. callbacks[0] = menu_makecallback("callback_disabled")
  261. callbacks[1] = menu_makecallback("callback_enabled")
  262.  
  263. // The dictionary
  264. register_dictionary("flashbang_remote_control.txt")
  265.  
  266. // Config file
  267. new config[200]
  268. get_configsdir(config, chars(config))
  269. format(CFG_FILE, chars(CFG_FILE), "%s/%s", config, CFG_FILE_NAME)
  270.  
  271. // Create the trace handle so we can't interfere on other plugins that use the tracehandle 0.
  272. g_trace = create_tr2()
  273. g_maxplayers = get_maxplayers()
  274.  
  275. // Create the plugin forwards
  276. g_forward_preflash = CreateMultiForward("fw_FRC_preflash", ET_CONTINUE, FP_CELL, FP_CELL, FP_CELL, FP_CELL) // Tested!
  277. g_forward_postflash = CreateMultiForward("fw_FRC_postflash", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL) // Tested!
  278. g_forward_bang = CreateMultiForward("fw_FRC_flashbang_explosion", ET_IGNORE, FP_CELL, FP_CELL) // Tested!
  279. g_forward_punish = CreateMultiForward("fw_FRC_punish", ET_CONTINUE, FP_CELL, FP_CELL) // Tested!
  280. g_forward_freedata = CreateMultiForward("fw_FRC_free_plugin_data", ET_IGNORE) // Tested!
  281. g_forward_trace = CreateMultiForward("fw_FRC_trace", ET_CONTINUE, FP_ARRAY, FP_ARRAY, FP_CELL, FP_CELL, FP_CELL)// Tested!
  282. g_forward_traceb = CreateMultiForward("fw_FRC_trace_bug", ET_CONTINUE, FP_ARRAY, FP_ARRAY, FP_CELL, FP_CELL, FP_CELL)// Tested!
  283. g_forward_client = CreateMultiForward("fw_FRC_counter_reset", ET_IGNORE, FP_CELL) // Tested!
  284. g_forward_search = CreateMultiForward("fw_FRC_flash_find_in_sphere", ET_CONTINUE, FP_CELL, FP_CELL) // Tested!
  285. g_forward_extinit = CreateMultiForward("fw_FRC_extention_init", ET_IGNORE)
  286.  
  287. // Loat settings
  288. exec_cfg()
  289.  
  290. set_task(1.0, "register_delay")
  291. }
  292.  
  293. public register_delay()
  294. {
  295. // We register this here so we can let other plugins mess with flash events! And with the grenade properties!
  296. RegisterHam(Ham_Think, "grenade", "fw_think")
  297. register_message(scrfade, "message_screenfade")
  298.  
  299. new ret
  300. ExecuteForward(g_forward_extinit, ret)
  301. }
  302.  
  303. public plugin_end()
  304. {
  305. // Free the trace handle
  306. free_tr2(g_trace)
  307.  
  308. // Dealloc the plugin forwards
  309. DestroyForward(g_forward_preflash)
  310. DestroyForward(g_forward_postflash)
  311. DestroyForward(g_forward_bang)
  312. DestroyForward(g_forward_punish)
  313. DestroyForward(g_forward_freedata)
  314. DestroyForward(g_forward_traceb)
  315. DestroyForward(g_forward_trace)
  316. DestroyForward(g_forward_client)
  317. DestroyForward(g_forward_search)
  318. }
  319.  
  320. public plugin_natives()
  321. {
  322. register_library("frc_lib")
  323.  
  324. register_native("get_FRC_duration", "native_get_FRC_duration", 1)
  325. register_native("set_FRC_duration", "native_set_FRC_duration", 1)
  326. register_native("get_FRC_holdtime", "native_get_FRC_holdtime", 1)
  327. register_native("set_FRC_holdtime", "native_set_FRC_holdtime", 1)
  328. register_native("get_FRC_counter", "native_get_FRC_counter", 1)
  329. register_native("set_FRC_counter", "native_set_FRC_counter", 1)
  330. register_native("get_FRC_flash_limit", "native_get_FRC_flash_limit", 1)
  331.  
  332. register_native("get_FRC_exploding_flash", "native_get_FRC_exploding_flash", 1)
  333. register_native("get_FRC_exploding_owner", "native_get_FRC_explo_fl_owner", 1)
  334.  
  335. register_native("FRC_flash_player", "native_FRC_flash_player", 1)
  336. }
  337.  
  338. public native_get_FRC_counter(id)
  339. {
  340. return g_flash_mon[id]
  341. }
  342.  
  343. public native_set_FRC_counter(id, quantity)
  344. {
  345. g_flash_mon[id] = quantity
  346. return 1
  347. }
  348.  
  349. public native_get_FRC_flash_limit()
  350. {
  351. return get_option(pc_frc_limit)
  352. }
  353.  
  354. public native_get_FRC_exploding_flash()
  355. {
  356. return g_flash_ent
  357. }
  358.  
  359. public native_get_FRC_explo_fl_owner()
  360. {
  361. return g_flasher
  362. }
  363.  
  364. public native_set_FRC_duration(flashed, duration)
  365. {
  366. g_flashdur[flashed] = duration
  367. }
  368.  
  369. public native_get_FRC_duration(flashed)
  370. {
  371. return g_flashdur[flashed]
  372. }
  373.  
  374. public native_set_FRC_holdtime(flashed, duration)
  375. {
  376. g_flashhold[flashed] = duration
  377. }
  378.  
  379. public native_get_FRC_holdtime(flashed)
  380. {
  381. return g_flashhold[flashed]
  382. }
  383.  
  384. public native_FRC_flash_player(flasher, flashed, duration, holdtime, amount)
  385. {
  386. if (flasher == 0 || g_flasher != 0)
  387. {
  388. switch (get_option(pc_frc_mcolor))
  389. {
  390. case 1:
  391. {
  392. g_color_red = get_option(pc_frc_rcolor)
  393. g_color_green = get_option(pc_frc_gcolor)
  394. g_color_blue = get_option(pc_frc_bcolor)
  395. }
  396. case 2, 3:
  397. {
  398. g_color_red = random_num(0, 255)
  399. g_color_green = random_num(0, 255)
  400. g_color_blue = random_num(0, 255)
  401. }
  402. default:
  403. {
  404. g_color_red = 255
  405. g_color_green = 255
  406. g_color_blue = 255
  407. }
  408. }
  409.  
  410. flash(flashed, floatround(float(duration) * 409.6), floatround(float(holdtime) * 409.6), 0x0000 , g_color_red, g_color_green, g_color_blue, amount)
  411. }
  412. else
  413. {
  414. switch (get_option(pc_frc_mcolor))
  415. {
  416. case 1:
  417. {
  418. g_color_red = get_option(pc_frc_rcolor)
  419. g_color_green = get_option(pc_frc_gcolor)
  420. g_color_blue = get_option(pc_frc_bcolor)
  421. }
  422. case 2, 3:
  423. {
  424. g_color_red = random_num(0, 255)
  425. g_color_green = random_num(0, 255)
  426. g_color_blue = random_num(0, 255)
  427. }
  428. default:
  429. {
  430. g_color_red = 255
  431. g_color_green = 255
  432. g_color_blue = 255
  433. }
  434. }
  435.  
  436. g_flash_ent = flasher
  437. g_flasher = flasher
  438.  
  439. eflash(flashed, floatround(float(duration) * 409.6), floatround(float(holdtime) * 409.6), 0x0000 , 255, 255, 255, amount)
  440.  
  441. g_flash_ent = 0
  442. g_flasher = 0
  443.  
  444. new ret
  445. ExecuteForward(g_forward_freedata, ret)
  446. }
  447.  
  448. return 1
  449. }
  450.  
  451. // Cache the sound
  452. public plugin_precache()
  453. {
  454. engfunc(EngFunc_PrecacheSound, "radio/bot/im_blind.wav")
  455. }
  456.  
  457. // Control Pannel
  458. // Cfg save system
  459. public exec_cfg()
  460. {
  461. if(file_exists(CFG_FILE))
  462. server_cmd("exec %s", CFG_FILE)
  463. }
  464.  
  465. public save_cfg()
  466. {
  467. new file[2000]
  468. format(file, chars(file), "echo [Flashbang Remote Control] Executing config file ...^n")
  469.  
  470. add_to_file(file, chars(file), pc_frc_enable)
  471. add_to_file(file, chars(file), pc_frc_chat)
  472. add_to_file(file, chars(file), pc_frc_sound)
  473. add_to_file(file, chars(file), pc_frc_admin)
  474. add_to_file(file, chars(file), pc_frc_selfb)
  475. add_to_file(file, chars(file), pc_frc_block)
  476. add_to_file(file, chars(file), pc_frc_blocka)
  477. add_to_file(file, chars(file), pc_frc_punish)
  478. add_to_file(file, chars(file), pc_frc_count)
  479. add_to_file(file, chars(file), pc_frc_limit)
  480. add_to_file(file, chars(file), pc_frc_warn)
  481. add_to_file(file, chars(file), pc_frc_mode)
  482. add_to_file(file, chars(file), pc_frc_type)
  483. add_to_file(file, chars(file), pc_frc_nr_ctr)
  484. add_to_file(file, chars(file), pc_frc_mcolor)
  485. add_to_file(file, chars(file), pc_frc_rcolor)
  486. add_to_file(file, chars(file), pc_frc_gcolor)
  487. add_to_file(file, chars(file), pc_frc_bcolor)
  488. add_to_file(file, chars(file), pc_frc_dlight)
  489. add_to_file(file, chars(file), pc_frc_bug)
  490.  
  491. format(file, chars(file), "%secho [Flashbang Remote Control] Settings loaded from config file", file)
  492.  
  493. delete_file(CFG_FILE)
  494. write_file(CFG_FILE, file)
  495. }
  496.  
  497. stock add_to_file(file[], size_of_file, Option:option)
  498. {
  499. switch (option_type[option])
  500. {
  501. case OPTION_TOGGLE, OPTION_CELL: format(file, size_of_file, "%s%s %d^n", file, option_information[option], get_option(option))
  502. case OPTION_FLOAT: format(file, size_of_file, "%s%s %f^n", file, option_information[option], get_option_float(option))
  503. }
  504. }
  505.  
  506. // Control Pannel Menu system
  507. public conjure_menu(id, level, cid)
  508. {
  509. if (cmd_access(id, level, cid, 1))
  510. {
  511. menu_adjust(id)
  512. }
  513. return PLUGIN_HANDLED
  514. }
  515.  
  516. // Let's create the menu!
  517. stock menu_adjust(id, page = 0)
  518. {
  519. settingsmenu = menu_create("Flash Remote Control Pannel", "menu_handler")
  520.  
  521. add_option_toggle(pc_frc_enable, "Enable plugin", "Yes", "No")
  522.  
  523. if (get_option(pc_frc_enable) == 0)
  524. {
  525. menu_display(id, settingsmenu, page)
  526. return PLUGIN_CONTINUE
  527. }
  528.  
  529. add_option_toggle(pc_frc_chat, "Enable chat messages (when flashed)", "Yes", "No")
  530. add_option_toggle(pc_frc_admin, "Admin text message display", "Enabled", "Disabled")
  531. add_option_toggle(pc_frc_sound, "Play the ^"I'm blind^" sound", "On", "Off")
  532. add_option_toggle(pc_frc_block, "Block team flash", "Yes", "No")
  533. add_option_toggle(pc_frc_selfb, "Block self flash", "Yes", "No")
  534. add_option_toggle(pc_frc_blocka, "Block the flash effect to all when a teammate is flashed", "Yes", "No")
  535. add_option_toggle(pc_frc_bug, "Enable bug fixer", "Yes", "No")
  536. add_option_toggle(pc_frc_dlight, "Enable dynamic light", "Yes", "No")
  537. add_option_quatrotoggle(pc_frc_mcolor, "Flash color mode", "Normal", "Specified colors", "Random color (the same for all the players)", "Random color for every player")
  538.  
  539. add_option_toggle(pc_frc_punish, "Punish system", "On", "Off")
  540.  
  541. if (get_option(pc_frc_punish))
  542. {
  543. add_option_toggle(pc_frc_count, "Method of counting", "All the teamflashes", "Just the full teamflashes")
  544. add_option_toggle(pc_frc_warn, "Warn the flasher", "Yes", "No")
  545. add_option_tritoggle(pc_frc_mode, "Punish mode", "Until map end", "By rounds", "By time")
  546. add_option_tritoggle(pc_frc_type, "Punish type", "Block throw", "Kill", "Self flash")
  547. add_cell_option(pc_frc_limit, "The number of players someone can flash before beeing punished", "times")
  548.  
  549.  
  550. switch (get_option(pc_frc_mode))
  551. {
  552. case 1:
  553. {
  554. register_option_value(pc_frc_nr_ctr, "1;2;3;4;5;6;7;8;9;10")
  555. add_float_cell_option(pc_frc_nr_ctr, "Number of rounds of punish", "times")
  556. }
  557. case 2:
  558. {
  559. register_option_value(pc_frc_nr_ctr, "1;1.5;2;2.5;3;3.5;4;4.5;5;5.5;6;7;8;9;10")
  560. add_float_option(pc_frc_nr_ctr, "Time of punish", "minutes")
  561. }
  562. }
  563.  
  564. }
  565.  
  566. menu_display(id, settingsmenu, page)
  567. return PLUGIN_CONTINUE
  568. }
  569.  
  570. stock add_option_toggle(Option:control_option, const basetext[], const yestext[], const notext[], Option:displayif = Option:-1)
  571. {
  572. new cmd[3], itemtext[100]
  573. num_to_str(_:control_option, cmd, chars(cmd))
  574. format(itemtext, chars(itemtext), "%s: %s%s", basetext, (get_option(control_option) ? "\y" : "\r" ), (get_option(control_option) ? yestext : notext))
  575. menu_additem(settingsmenu, itemtext, cmd, _, (displayif != Option:-1 && !get_option(displayif)) ? callbacks[0] : callbacks[1])
  576. }
  577.  
  578. stock add_option_tritoggle(Option:control_option, const basetext[], const text[], const text2[], const text3[], Option:displayif = Option:-1)
  579. {
  580. new cmd[3], itemtext[100]
  581. num_to_str(_:control_option, cmd, chars(cmd))
  582. format(itemtext, chars(itemtext), "%s:\y %s%s%s", basetext, (get_option(control_option) == 0 ? text : "" ), (get_option(control_option) == 1 ? text2 : "" ), (get_option(control_option) == 2 ? text3 : "" ))
  583. menu_additem(settingsmenu, itemtext, cmd, _, (displayif != Option:-1 && !get_option(displayif)) ? callbacks[0] : callbacks[1])
  584. }
  585.  
  586. stock add_option_quatrotoggle(Option:control_option, const basetext[], const text[], const text2[], const text3[], const text4[], Option:displayif = Option:-1)
  587. {
  588. new cmd[3], itemtext[100]
  589. num_to_str(_:control_option, cmd, chars(cmd))
  590. format(itemtext, chars(itemtext), "%s:\y %s%s%s%s", basetext, (get_option(control_option) == 0 ? text : "" ), (get_option(control_option) == 1 ? text2 : "" ), (get_option(control_option) == 2 ? text3 : "" ), (get_option(control_option) == 3 ? text4 : "" ))
  591. menu_additem(settingsmenu, itemtext, cmd, _, (displayif != Option:-1 && !get_option(displayif)) ? callbacks[0] : callbacks[1])
  592. }
  593.  
  594. stock add_float_option(Option:control_option, const basetext[], const unit[])
  595. {
  596. new cmd[3], itemtext[100]
  597. new value[20]
  598.  
  599. format(value, chars(value), "%0.2f", get_option_float(control_option))
  600.  
  601. num_to_str(_:control_option, cmd, chars(cmd))
  602. format(itemtext, chars(itemtext), "%s: \y%s \r%s", basetext, value, unit)
  603. menu_additem(settingsmenu, itemtext, cmd, _, _)
  604. }
  605.  
  606. stock add_float_cell_option(Option:control_option, const basetext[], const unit[])
  607. {
  608. new cmd[3], itemtext[100]
  609. new value[20]
  610.  
  611. format(value, chars(value), "%d", floatround(get_option_float(control_option)))
  612.  
  613. num_to_str(_:control_option, cmd, chars(cmd))
  614. format(itemtext, chars(itemtext), "%s: \y%s \r%s", basetext, value, unit)
  615. menu_additem(settingsmenu, itemtext, cmd, _, _)
  616. }
  617.  
  618. stock add_cell_option(Option:control_option, const basetext[], const unit[])
  619. {
  620. new cmd[3], itemtext[100]
  621. new value[20]
  622.  
  623. format(value, chars(value), "%d", get_option(control_option))
  624.  
  625. num_to_str(_:control_option, cmd, chars(cmd))
  626. format(itemtext, chars(itemtext), "%s: \y%s \r%s", basetext, value, unit)
  627. menu_additem(settingsmenu, itemtext, cmd, _, _)
  628. }
  629.  
  630. public callback_disabled(id, menu, item)
  631. {
  632. return ITEM_DISABLED
  633. }
  634.  
  635. public callback_enabled(id, menu, item)
  636. {
  637. return ITEM_ENABLED
  638. }
  639.  
  640.  
  641. // Base cvar change system
  642. public menu_handler(id, menu, item)
  643. {
  644. new access, info[5], callback
  645. menu_item_getinfo(menu, item, access, info, chars(info), _, _, callback)
  646.  
  647. if (item < 0)
  648. {
  649. save_cfg()
  650. return PLUGIN_HANDLED
  651. }
  652.  
  653. new cvar = str_to_num(info)
  654.  
  655. switch (option_type[Option:cvar])
  656. {
  657. case OPTION_TOGGLE:
  658. {
  659. toggle_option(Option:cvar)
  660. }
  661. case OPTION_CELL:
  662. {
  663. new value_string[100]
  664. format(value_string, chars(value_string), "%s;", option_value[Option:cvar])
  665.  
  666. new values[20][10]
  667. new true_value[20]
  668.  
  669. new last = 0, newpos = 0, k = 0;
  670.  
  671. for (new i=0;i<sizeof(value_string);i++)
  672. {
  673. if(equal(value_string[i], ";", 1))
  674. {
  675. newpos = i
  676. }
  677.  
  678. if (newpos > last)
  679. {
  680. for (new j=last;j<newpos;j++)
  681. {
  682. format(values[k], 9, "%s%s", values[k], value_string[j])
  683. }
  684.  
  685. last = newpos + 1
  686. k++
  687. }
  688. }
  689.  
  690. new bool:ok = false
  691. new counter = 0
  692.  
  693. for (new i=0;i<k;i++)
  694. {
  695. counter++
  696.  
  697. true_value[i] = str_to_num(values[i])
  698.  
  699. if (ok == true)
  700. {
  701. set_pcvar_num(pcvars[Option:cvar], true_value[i])
  702. counter = 0
  703. break
  704. }
  705.  
  706. if (true_value[i] == get_option(Option:cvar))
  707. ok = true
  708. }
  709.  
  710. if (counter == k)
  711. set_pcvar_num(pcvars[Option:cvar], true_value[0])
  712. }
  713. case OPTION_FLOAT:
  714. {
  715. new value_string_float[100]
  716. format(value_string_float, chars(value_string_float), "%s;", option_value[Option:cvar])
  717.  
  718. new values_float[20][10]
  719. new Float:true_value_float[20]
  720.  
  721. new last = 0, newpos = 0, k = 0;
  722.  
  723. for (new i=0;i<sizeof(value_string_float);i++)
  724. {
  725. if(equal(value_string_float[i], ";", 1))
  726. {
  727. newpos = i
  728. }
  729.  
  730. if (newpos > last)
  731. {
  732. for (new j=last;j<newpos;j++)
  733. {
  734. format(values_float[k], 9, "%s%s", values_float[k], value_string_float[j])
  735. }
  736.  
  737. last = newpos + 1
  738. k++
  739. }
  740. }
  741.  
  742. new bool:ok=false
  743. new counter = 0
  744.  
  745. for (new i=0;i<k;i++)
  746. {
  747. counter++
  748.  
  749. true_value_float[i] = str_to_float(values_float[i])
  750.  
  751. if (ok == true)
  752. {
  753. set_pcvar_float(pcvars[Option:cvar], true_value_float[i])
  754. counter = 0
  755. break
  756. }
  757.  
  758. if (true_value_float[i] == get_option_float(Option:cvar))
  759. ok = true
  760. }
  761.  
  762. if (counter == k)
  763. set_pcvar_float(pcvars[Option:cvar], true_value_float[0])
  764. }
  765. }
  766.  
  767. menu_destroy(menu)
  768. menu_adjust(id, floatround(float(item)/7.0, floatround_floor))
  769. save_cfg()
  770. return PLUGIN_HANDLED
  771. }
  772.  
  773. // Round end
  774. public event_round_end()
  775. {
  776. static players[32], num, id
  777. get_players(players, num)
  778.  
  779. for (new i=0;i<num;i++)
  780. {
  781. id = players[i]
  782.  
  783. if (g_round_lock[id] > 0 && !ply_can_count(id))
  784. g_round_lock[id] -= 1
  785.  
  786. if (g_round_lock[id] == 0 && get_option(pc_frc_mode) == 1 && !ply_can_count(id))
  787. {
  788. del_reset_counter(id)
  789. set_can_count(id)
  790. g_flash_mon[id] = 0
  791. }
  792. }
  793. }
  794.  
  795. // Reset the monitor when a player connects or disconnects
  796. public client_disconnect(id)
  797. {
  798. set_reset_counter(id)
  799. }
  800.  
  801. public client_connect(id)
  802. {
  803. set_reset_counter(id)
  804. }
  805.  
  806. // Damn you!!! You flashed me!!!
  807. public event_blinded(id)
  808. {
  809. if (!is_user_alive(id) || g_flasher == 0)
  810. return PLUGIN_CONTINUE
  811.  
  812. new alpha, ret
  813.  
  814. g_flashdur[id] = -1
  815. g_modifhold[id] = -1
  816.  
  817. switch (g_last_flashtype[id])
  818. {
  819. case FRC_BLOCK:
  820. {
  821. return PLUGIN_CONTINUE
  822. }
  823. case FRC_MAKE_PARTIALLY:
  824. {
  825. alpha = BLINDED_PARTLY
  826. }
  827. case FRC_MAKE_FULLY:
  828. {
  829. alpha = BLINDED_FULLY
  830. }
  831. default:
  832. {
  833. alpha = read_data(7)
  834. }
  835. }
  836.  
  837. g_last_flashtype[id] = FRC_BLOCK
  838.  
  839. ExecuteForward(g_forward_postflash, ret, g_flasher, id, g_flash_ent, alpha)
  840.  
  841. // And now the news!
  842. return show_news(id, alpha, g_flasher)
  843. }
  844.  
  845. public message_screenfade(msg_id, msg_dest, ent)
  846. {
  847. if (g_flasher == 0)
  848. return PLUGIN_CONTINUE
  849.  
  850. g_flashdur[ent] = floatround(float(get_msg_arg_int(1)) / 409.6)
  851. g_flashhold[ent] = floatround(float(get_msg_arg_int(2)) / 409.6)
  852.  
  853. new ret
  854. ExecuteForward(g_forward_preflash, ret, g_flasher, ent, g_flash_ent, get_msg_arg_int(7))
  855.  
  856. new actdur = (g_flashdur[ent] > 0) ? g_flashdur[ent] : 0
  857. new acthold = (g_flashhold[ent] > 0) ? g_flashhold[ent] : 0
  858.  
  859. if (actdur != floatround(float(get_msg_arg_int(1)) / 409.6))
  860. {
  861. if (actdur == 0)
  862. {
  863. ret = FRC_BLOCK
  864. }
  865. else
  866. {
  867. g_modifdur[ent] = floatround(float(actdur) * 409.6)
  868. set_msg_arg_int(1, ARG_SHORT, g_modifdur[ent])
  869. }
  870. }
  871.  
  872. if (floatround(float(get_msg_arg_int(2)) / 409.6) != acthold)
  873. {
  874. g_modifhold[ent] = floatround(float(acthold) * 409.6)
  875. set_msg_arg_int(2, ARG_SHORT, g_modifhold[ent])
  876. }
  877.  
  878. switch (ret)
  879. {
  880. case FRC_BLOCK:
  881. {
  882. g_last_flashtype[ent] = FRC_BLOCK
  883. return PLUGIN_HANDLED
  884. }
  885. case FRC_MAKE_PARTIALLY:
  886. {
  887. g_last_flashtype[ent] = FRC_MAKE_PARTIALLY
  888. set_msg_arg_int(7, ARG_BYTE, BLINDED_PARTLY)
  889. }
  890. case FRC_MAKE_FULLY:
  891. {
  892. g_last_flashtype[ent] = FRC_MAKE_FULLY
  893. set_msg_arg_int(7, ARG_BYTE, BLINDED_FULLY)
  894. }
  895. default:
  896. {
  897. g_last_flashtype[ent] = FRC_CONTINUE
  898. }
  899. }
  900.  
  901. if (get_option(pc_frc_mcolor) != 3)
  902. {
  903. set_msg_arg_int(4, ARG_BYTE, g_color_red)
  904. set_msg_arg_int(5, ARG_BYTE, g_color_green)
  905. set_msg_arg_int(6, ARG_BYTE, g_color_blue)
  906. }
  907. else
  908. {
  909. set_msg_arg_int(4, ARG_BYTE, random_num(0, 255))
  910. set_msg_arg_int(5, ARG_BYTE, random_num(0, 255))
  911. set_msg_arg_int(6, ARG_BYTE, random_num(0, 255))
  912. }
  913.  
  914. return PLUGIN_CONTINUE
  915. }
  916.  
  917. // Show the news!
  918. public show_news(id, alpha, id_fl)
  919. {
  920. // If you flash a teammate
  921. if (cs_get_user_team(id) == g_fl_team && id != id_fl && get_option(pc_frc_enable) != 0)
  922. {
  923. new flasher[32]
  924. get_user_name(id_fl, flasher, chars(flasher))
  925.  
  926. new name[32]
  927. get_user_name(id, name, chars(name))
  928.  
  929. if (get_option(pc_frc_chat))
  930. {
  931. new message1[128], message2[128]
  932.  
  933. format(message1, chars(message1), "^x04[Team Flash Control]^x01 %L ^x03%s", id, "THE_FLASHED_MSG", flasher)
  934. format(message2, chars(message1), "^x04[Team Flash Control]^x01 %L ^x03(%s)", id_fl, alpha == BLINDED_FULLY ? "FLASHER_MSG_TOTAL" : "FLASHER_MSG_PART", name)
  935.  
  936. colored_msg(id, message1)
  937. colored_msg(id_fl, message2)
  938. }
  939.  
  940. if (!is_user_bot(id_fl) && get_option(pc_frc_punish) && ply_can_count(id_fl) && (alpha == BLINDED_FULLY || (get_option(pc_frc_count) && alpha != BLINDED_FULLY)))
  941. {
  942. g_flash_mon[id_fl] += 1
  943.  
  944. if (g_flash_mon[id_fl] >= get_option(pc_frc_limit))
  945. {
  946. del_can_count(id_fl)
  947.  
  948. switch (get_option(pc_frc_mode))
  949. {
  950. case 1: g_round_lock[id_fl] = floatround(get_option_float(pc_frc_nr_ctr), floatround_round)
  951. case 2: g_time_lock[id_fl] = get_gametime() + (get_option_float(pc_frc_nr_ctr) * 60.0)
  952. }
  953.  
  954. if(get_option(pc_frc_admin) && get_option(pc_frc_punish))
  955. {
  956. new msg[128]
  957. format(msg, chars(msg), "%L", LANG_SERVER, "BLOCK_USER_FLASH_MSG", flasher)
  958. admin_message("[Team Flash Control]", msg)
  959. }
  960.  
  961. }
  962. }
  963.  
  964. if (g_flash_mon[id_fl] >= get_option(pc_frc_limit) && alpha == BLINDED_FULLY && get_option(pc_frc_punish))
  965. {
  966. new ret = FRC_CONTINUE
  967. ExecuteForward(g_forward_punish, ret, id_fl, get_option(pc_frc_mode))
  968.  
  969. if (ret == FRC_CONTINUE)
  970. {
  971. switch (get_option(pc_frc_type))
  972. {
  973. case 1: user_kill(id_fl)
  974. case 2: eflash(id_fl, 10<<12, 1<<12, 0x0000 , 255, 255, 255, 255)
  975. }
  976. }
  977. }
  978.  
  979.  
  980. if(get_option(pc_frc_sound))
  981. client_cmd(id_fl, "spk sound/radio/bot/im_blind.wav")
  982.  
  983. if(alpha == BLINDED_FULLY && get_option(pc_frc_admin))
  984. {
  985. new msg[128]
  986. format(msg, chars(msg), "%L", LANG_SERVER, "ADMIN_MSG", flasher, name)
  987. admin_message("[Team Flash Control]", msg)
  988. }
  989. }
  990.  
  991. return PLUGIN_CONTINUE
  992. }
  993.  
  994. // Player prethink
  995. public fw_player_prethink(id)
  996. {
  997. if (can_reset_counter(id))
  998. {
  999. del_reset_counter(id)
  1000. set_can_count(id)
  1001.  
  1002. g_flash_mon[id] = 0
  1003.  
  1004. new ret
  1005. ExecuteForward(g_forward_client, ret, id)
  1006. }
  1007.  
  1008. if (get_gametime() >= g_time_lock[id] && get_option(pc_frc_mode) == 2 && ply_can_count(id))
  1009. {
  1010. del_reset_counter(id)
  1011. set_can_count(id)
  1012.  
  1013. g_flash_mon[id] = 0
  1014.  
  1015. new ret
  1016. ExecuteForward(g_forward_client, ret, id)
  1017. }
  1018.  
  1019. if (!is_user_alive(id))
  1020. return FMRES_IGNORED
  1021.  
  1022. if (get_user_weapon(id) == CSW_FLASHBANG && pev(id, pev_button) & IN_ATTACK && g_flash_mon[id] >= get_option(pc_frc_limit) && get_option(pc_frc_punish) && get_option(pc_frc_type) == 0 && get_option(pc_frc_enable) != 0)
  1023. {
  1024. new ret = FRC_CONTINUE
  1025. ExecuteForward(g_forward_punish, ret, id, get_option(pc_frc_mode))
  1026.  
  1027. if (ret == FRC_CONTINUE)
  1028. {
  1029. set_pev(id, pev_button, pev(id, pev_button) & ~IN_ATTACK)
  1030. return FMRES_HANDLED
  1031. }
  1032. }
  1033.  
  1034. return FMRES_IGNORED
  1035. }
  1036.  
  1037. // The moment the flash is thrown
  1038. public fw_setmodel(ent, const model[])
  1039. {
  1040. if (!pev_valid(ent))
  1041. return FMRES_IGNORED
  1042.  
  1043. // Not yet thrown
  1044. if (pev_float(ent, pev_gravity) == 0.0)
  1045. return FMRES_IGNORED
  1046.  
  1047. if (containi(model, "w_flashbang.mdl") == -1)
  1048. return FMRES_IGNORED
  1049.  
  1050. // Get the owner
  1051. set_pdata_int(ent, OFFSET_OWNER, pev(ent, pev_owner), OFFSET_LINUX)
  1052.  
  1053. return FMRES_IGNORED
  1054. }
  1055.  
  1056. // The grenade thinks ... quiet!!!
  1057. public fw_think(ent)
  1058. {
  1059. if (!is_flash(ent) || g_flash_ent == ent)
  1060. return HAM_IGNORED
  1061.  
  1062. // The flash has not kaboomed
  1063. if (pev_float(ent, pev_dmgtime) > get_gametime())
  1064. return HAM_IGNORED
  1065.  
  1066. g_flasher = get_pdata_int(ent, OFFSET_OWNER, OFFSET_LINUX)
  1067. g_fl_team = cs_get_user_team(g_flasher)
  1068. g_flash_ent = ent
  1069.  
  1070. new ret
  1071. ExecuteForward(g_forward_bang, ret, ent, g_flasher)
  1072.  
  1073. new Float:origin[3]
  1074. pev(ent, pev_origin, origin)
  1075.  
  1076. if (get_option(pc_frc_selfb) != 0 && get_option(pc_frc_enable) != 0)
  1077. set_block_flash(g_flasher)
  1078.  
  1079. if (get_option(pc_frc_block) != 0 && get_option(pc_frc_enable) != 0)
  1080. {
  1081. for (new i=1;i<33;i++)
  1082. {
  1083. if (!is_user_connected(i) || is_user_connecting(i))
  1084. continue
  1085.  
  1086. if (i != g_flasher && cs_get_user_team(i) == g_fl_team)
  1087. set_block_flash(i)
  1088. }
  1089. }
  1090.  
  1091. if (get_option(pc_frc_blocka) != 0 && get_option(pc_frc_enable) != 0)
  1092. {
  1093. new Float:user_origin[3], Float:start[3]
  1094. new hit
  1095.  
  1096. while ((hit = engfunc(EngFunc_FindEntityInSphere, hit, origin, 1500.0)))
  1097. {
  1098. if (hit > g_maxplayers)
  1099. break
  1100.  
  1101. if (hit == g_flasher)
  1102. continue
  1103.  
  1104. if (!is_user_alive(hit))
  1105. continue
  1106.  
  1107. if (cs_get_user_team(hit) != g_fl_team)
  1108. continue
  1109.  
  1110. // Get the origin of the players head
  1111. pev(hit, pev_origin, user_origin)
  1112. pev(hit, pev_view_ofs, start)
  1113. xs_vec_add(user_origin, start, user_origin)
  1114.  
  1115. // Traceline from the player origin to the grenade origin
  1116. engfunc(EngFunc_TraceLine, origin, user_origin, DONT_IGNORE_MONSTERS, ent, g_trace)
  1117.  
  1118. new ret, ar_start, ar_end
  1119. ar_start = PrepareArray(_:origin, 3, 0)
  1120. ar_end = PrepareArray(_:user_origin, 3, 0)
  1121.  
  1122. ExecuteForward(g_forward_trace, ret, ar_start, ar_end, DONT_IGNORE_MONSTERS, hit, g_trace)
  1123.  
  1124. if (get_tr2(g_trace, TR_pHit) == hit)
  1125. {
  1126. g_allow_forward = false
  1127. break
  1128. }
  1129. }
  1130. }
  1131.  
  1132. if (get_option(pc_frc_dlight) != 0 && get_option(pc_frc_enable) != 0)
  1133. {
  1134. switch (get_option(pc_frc_mcolor))
  1135. {
  1136. case 1:
  1137. {
  1138. g_color_red = get_option(pc_frc_rcolor)
  1139. g_color_green = get_option(pc_frc_gcolor)
  1140. g_color_blue = get_option(pc_frc_bcolor)
  1141.  
  1142. dynamic_light(origin, g_color_red, g_color_green, g_color_blue)
  1143. }
  1144. case 2:
  1145. {
  1146. g_color_red = random_num(0, 255)
  1147. g_color_green = random_num(0, 255)
  1148. g_color_blue = random_num(0, 255)
  1149.  
  1150. dynamic_light(origin, g_color_red, g_color_green, g_color_blue)
  1151. }
  1152. default:
  1153. {
  1154. g_color_red = 255
  1155. g_color_green = 255
  1156. g_color_blue = 255
  1157.  
  1158. dynamic_light(origin)
  1159. }
  1160. }
  1161. }
  1162.  
  1163. return HAM_IGNORED
  1164. }
  1165.  
  1166. // The grenade emits the explosion sound
  1167. public fw_emitsound(ent, chan, const sound[])
  1168. {
  1169. if (!pev_valid(ent))
  1170. return FMRES_IGNORED
  1171.  
  1172. if (contain(sound, "flash") == -1)
  1173. return FMRES_IGNORED
  1174.  
  1175. static classname[32]
  1176. pev(ent, pev_classname, classname, 31)
  1177. if (!equal(classname, "grenade"))
  1178. return FMRES_IGNORED
  1179.  
  1180. // Good time to reset the flasher and the ent id
  1181. g_flash_ent = 0
  1182. g_flasher = 0
  1183. g_allow_forward = true
  1184.  
  1185. new owner = get_pdata_int(ent, OFFSET_OWNER, OFFSET_LINUX)
  1186.  
  1187. if (task_exists(owner + REMAIN_TASK))
  1188. remove_task(owner + REMAIN_TASK)
  1189.  
  1190. // Show the user how many flashes he has left to throw before before beeing blocked
  1191. set_task(0.2, "remaining_flashes", owner + REMAIN_TASK)
  1192.  
  1193. // Remove all the flashes that need to be blocked!
  1194. g_bs_block_flash = 0
  1195.  
  1196. new ret
  1197. ExecuteForward(g_forward_freedata, ret)
  1198.  
  1199. return FMRES_IGNORED
  1200. }
  1201.  
  1202. // Let's find the victims
  1203. public fw_findentityinsphere(start_ent, Float:origin[3], Float:radius)
  1204. {
  1205. if (radius != 1500.0 || g_flash_ent == 0)
  1206. return FMRES_IGNORED
  1207.  
  1208. if (g_allow_forward == false)
  1209. {
  1210. forward_return(FMV_CELL, -1)
  1211. return FMRES_SUPERCEDE
  1212. }
  1213.  
  1214. static hit, Float:user_origin[3], Float:fraction, Float:start[3], ret, hit_fw
  1215.  
  1216. hit_fw = engfunc(EngFunc_FindEntityInSphere, hit, origin, radius)
  1217.  
  1218. if (1 <= hit_fw <= g_maxplayers)
  1219. {
  1220. ExecuteForward(g_forward_search, ret, hit_fw, g_flash_ent)
  1221.  
  1222. if (ret != FRC_CONTINUE)
  1223. {
  1224. hit = hit_fw
  1225. forward_return(FMV_CELL, -1)
  1226. return FMRES_SUPERCEDE
  1227. }
  1228. }
  1229.  
  1230. if (get_option(pc_frc_enable) != 0)
  1231. {
  1232. if (get_option(pc_frc_bug) != 0)
  1233. {
  1234. while ((hit = engfunc(EngFunc_FindEntityInSphere, hit, origin, radius)))
  1235. {
  1236. if (hit > g_maxplayers)
  1237. {
  1238. forward_return(FMV_CELL, hit)
  1239. return FMRES_SUPERCEDE
  1240. }
  1241.  
  1242. // Hit dead player
  1243. if (!is_user_alive(hit))
  1244. {
  1245. forward_return(FMV_CELL, hit)
  1246. return FMRES_SUPERCEDE
  1247. }
  1248.  
  1249.  
  1250. // Get the origin of the players head
  1251. pev(hit, pev_origin, user_origin)
  1252. pev(hit, pev_view_ofs, start)
  1253. xs_vec_add(user_origin, start, user_origin)
  1254.  
  1255. // Traceline from the player origin to the grenade origin
  1256. engfunc(EngFunc_TraceLine, user_origin, origin, DONT_IGNORE_MONSTERS, hit, g_trace)
  1257.  
  1258. new ret, ar_start, ar_end
  1259. ar_start = PrepareArray(_:user_origin, 3, 0)
  1260. ar_end = PrepareArray(_:origin, 3, 0)
  1261.  
  1262. ExecuteForward(g_forward_traceb, ret, ar_start, ar_end, DONT_IGNORE_MONSTERS, hit, g_trace)
  1263.  
  1264. get_tr2(g_trace, TR_flFraction, fraction)
  1265.  
  1266. // If the trace didn't hit anything in it's way then we're cool!
  1267. if (fraction == 1.0 && !can_block_flash(hit))
  1268. {
  1269. forward_return(FMV_CELL, hit)
  1270. return FMRES_SUPERCEDE
  1271. }
  1272. }
  1273. }
  1274. else
  1275. {
  1276. while ((hit = engfunc(EngFunc_FindEntityInSphere, hit, origin, radius)))
  1277. {
  1278. if (hit > g_maxplayers)
  1279. {
  1280. forward_return(FMV_CELL, hit)
  1281. return FMRES_SUPERCEDE
  1282. }
  1283.  
  1284. // Hit dead player
  1285. if (!is_user_alive(hit))
  1286. {
  1287. forward_return(FMV_CELL, hit)
  1288. return FMRES_SUPERCEDE
  1289. }
  1290.  
  1291. if (!can_block_flash(hit))
  1292. {
  1293. forward_return(FMV_CELL, hit)
  1294. return FMRES_SUPERCEDE
  1295. }
  1296. }
  1297. }
  1298.  
  1299. // Cancel the check, if nothing was hit
  1300. forward_return(FMV_CELL, -1)
  1301. return FMRES_SUPERCEDE
  1302. }
  1303.  
  1304. return FMRES_IGNORED
  1305. }
  1306.  
  1307. // We are in trouble!
  1308. public remaining_flashes(id)
  1309. {
  1310. id -= REMAIN_TASK
  1311.  
  1312. if (!(get_option(pc_frc_admin) != 0 && get_option(pc_frc_limit) >= g_flash_mon[id] >= (get_option(pc_frc_limit) - 2) && get_option(pc_frc_punish) != 0 && get_option(pc_frc_warn) != 0) || get_option(pc_frc_enable) == 0)
  1313. return PLUGIN_CONTINUE
  1314.  
  1315. new message[128]
  1316.  
  1317. format(message, chars(message), "^x04[Team Flash Control] ^x01%L ^x03%d ", id, "FLASHER_MSG_LEFT1", get_option(pc_frc_limit) - g_flash_mon[id] + 1)
  1318. format(message, chars(message), "%s^x01%L", message, id, "FLASHER_MSG_LEFT2")
  1319.  
  1320. colored_msg(id, message)
  1321.  
  1322. return PLUGIN_CONTINUE
  1323. }
  1324.  
  1325. // Is the entity a flash grenade??? hmmm...
  1326. public bool:is_flash(ent)
  1327. {
  1328. static model[32]
  1329. pev(ent, pev_model, model, 31)
  1330. return bool:(containi(model, "w_flashbang.mdl") != -1)
  1331. }
  1332.  
  1333. // The dynamic light of the flashbang, it adds a little bit of realism
  1334. dynamic_light(Float:origin[3], red = 255, green = 255, blue = 255)
  1335. {
  1336. new o[3]
  1337. FVecIVec(origin, o)
  1338.  
  1339. emessage_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  1340. ewrite_byte(TE_DLIGHT) // The light effect
  1341. ewrite_coord(o[0]) // x
  1342. ewrite_coord(o[1]) // y
  1343. ewrite_coord(o[2]) // z
  1344. ewrite_byte(75) // radius
  1345. ewrite_byte(red) // r
  1346. ewrite_byte(green) // g
  1347. ewrite_byte(blue) // b
  1348. ewrite_byte(4) // life
  1349. ewrite_byte(120) // decay rate
  1350. emessage_end()
  1351. }
  1352.  
  1353. // Hookable flash message
  1354. eflash(id, duration, holdtime, flags, red = 255, green = 255, blue = 255, alpha)
  1355. {
  1356. emessage_begin(MSG_ONE, scrfade, {0, 0, 0}, id)
  1357. ewrite_short(duration)
  1358. ewrite_short(holdtime)
  1359. ewrite_short(flags)
  1360. ewrite_byte(red)
  1361. ewrite_byte(green)
  1362. ewrite_byte(blue)
  1363. ewrite_byte(alpha)
  1364. emessage_end()
  1365. }
  1366.  
  1367. flash(id, duration, holdtime, flags, red = 255, green = 255, blue = 255, alpha)
  1368. {
  1369. message_begin(MSG_ONE, scrfade, {0, 0, 0}, id)
  1370. write_short(duration)
  1371. write_short(holdtime)
  1372. write_short(flags)
  1373. write_byte(red)
  1374. write_byte(green)
  1375. write_byte(blue)
  1376. write_byte(alpha)
  1377. message_end()
  1378. }
  1379.  
  1380. // Just the colored message ... don't you like colors?
  1381. public colored_msg(id, msg[])
  1382. {
  1383. message_begin(MSG_ONE, saytext, {0, 0, 0}, id)
  1384. write_byte(id)
  1385. write_string(msg)
  1386. message_end()
  1387. }
  1388.  
  1389. // Similar to pev() just returns a float value
  1390. public Float:pev_float(index, type)
  1391. {
  1392. static Float:nr
  1393. pev(index, type, nr)
  1394. return nr
  1395. }
  1396.  
  1397. // Message to admins, they need to know ...
  1398. public admin_message(const name[], const message[])
  1399. {
  1400. new message2[192]
  1401. new players[32], num
  1402. get_players(players, num)
  1403.  
  1404. format(message2, chars(message2), "(ADMINS) %s : %s", name, message)
  1405.  
  1406. for (new i = 0; i < num; ++i)
  1407. {
  1408. if (access(players[i], ADMIN_CHAT))
  1409. client_print(players[i], print_chat, "%s", message2)
  1410. }
  1411. }
  1412.  
  1413. // Control panel system functions/stocks
  1414. register_option(Option:option, const name[300], const string[], OptionType:type = OPTION_TOGGLE, flags = 0, Float:value = 0.0)
  1415. {
  1416. pcvars[option] = register_cvar(name, string, flags, value)
  1417. option_type[option] = type
  1418. option_information[option] = name
  1419. }
  1420.  
  1421. register_option_value(Option:option, values[100])
  1422. {
  1423. if (option_type[option] == OPTION_TOGGLE)
  1424. return
  1425.  
  1426. option_value[option] = values
  1427. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement