Guest User

flash

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