// es_yatf_es.txt // mrYoung Anti-Team Flasher (yATF_ES) by mRyOuNg /// Inspiration from Medda_ATFS by Medda // Installation instructions // : create a directory yatf_es in cstrike/addons/eventscripts // : put this script in this directory as es_yatf_es.txt // : add es_load yatf_es in autoexec.cfg // : configure yatf_es (via block yatf_es_conf) // : Requirements : // : Mattie Eventscripts v1.5 and later // : ES Tools for Mattie Eventscripts v0.418 and later (for flash restriction only) block yatf_es_conf { /// yatf_es_conf // yatf_es_enable // enable yatf (1 - default), or disable (0) // useful to disable script time to time es_xset yatf_es_enable 1 "yATF_ES, Enable (1 - default), or Disable (0) yATF" // yatf_es_sayteamonly // enable (1 - default) or disable (0) sayteamonly feature // if enable, only flasher's team players will be notified about team flash // if disable, all players will be notified es_xset yatf_es_sayteamonly 1 "yATF_ES, Should yATF display notifications to team only? - 1 enable (default), 0 disable" // yatf_es_spawnprotection // duration in seconds to protect against spawn team flash // set to 5 by default, 0 will disable spawn protection es_xset yatf_es_spawnprotection 5 "yATF_ES, Duration in seconds to protect against spawn team flash - 5 secs (default), 0 disable" // yatf_es_warmup // if you use feature such as mani_warmup, you can disable yatf during warmup // yatf_es_warmup is the time, in seconds, of your warmup // set to 90 by default, 0 will disable the warmup feature es_xset yatf_es_warmup 90 "yATF_ES, Time, in seconds, of your warmup - 90 by default" // yatf_es_flashrestrict_percent // percent of teamates flashed at the same time to trigger a flash restriction // set to 0.30 (30%) by default, 0 will disable percent flash restriction es_xset yatf_es_flashrestrict_percent 0.30 "yATF_ES, Percent of teamates flashed at the same time to trigger a flash restriction - 0.30 (default), 0 disable" // yatf_es_flashrestrict_cumulative // number of cumulative (means during one or several teamflashs) teamates flashed to trigger a flash restriction // set to 5 by default, 0 will disable cumulative flash restriction es_xset yatf_es_flashrestrict_cumulative 5 "yATF_ES, Number of cumulative teamates flashed to trigger a flash restriction - 5 (default), 0 disable" // yatf_es_flashrestrict_rounds // number of consecutive rounds to restrict flashs for a player // set to 3 by default, 0 will disable flash restriction es_xset yatf_es_flashrestrict_rounds 1 "yATF_ES, Number of consecutive rounds to restrict flashs for a player - 1 (default), 0 disable" // yatf_es_flashduration // duration of a flash, in seconds, to be considered as a team flash (floating value possible) // a value of 0.75 seems fine, 0 means all teamflashs (even the ridiculous ones ;)) es_xset yatf_es_flashduration 0.75 "yATF_ES, Duration of a flash, in seconds, to be considered as a team flash - 0.75 (default), 0 disable" // yatf_es_admins // comma delimited list of yatf admins (can call !yatfadmin to tweak yatf parameters in realtime and easily) // set to the STEAM_ID_LAN by default //yatf_es_admins "STEAM_0:0001,STEAM_0:0002" es_xset yatf_es_admins "STEAM_ID_LAN" "yATF_ES Admins List" // yatf_es_phrase_* // yatf_es_phrase_* var gives the ability to translate the script in your prefered language // english and french version provided... es_xset yatf_es_phrase_flashteamate "flashs his teamate" "(en) phrase for - flashs his teamate" //es_xset yatf_es_phrase_flashteamate "a flashe son coequipier" "(fr) phrase for - flashs his teamate" es_xset yatf_es_phrase_spawnflash "has been killed for spawn flashing!" "(en) phrase for - spawn flash" //es_xset yatf_es_phrase_spawnflash "a ete tue pour spawn flashing!" "(fr) phrase for - spawn flash" es_xset yatf_es_phrase_restricted "Flashbang restricted during" "(en) phrase for - restricted" //es_xset yatf_es_phrase_restricted "Flashbang restreintes durant" "(fr) phrase for - restricted" es_xset yatf_es_phrase_flashednum "Number of flashed player(s):" "(en) phrase for - flashednum" //es_xset yatf_es_phrase_flashednum "Nombre de joueurs flashe(s):" "(fr) phrase for - flashednum" } block load { /// load block // required actions at script load // versioning es_xset yatf_es_ver "0.4b3" "yATF_ES Version" es_makepublic yatf_es_ver // loading configuration es_xdoblock yatf_es/yatf_es_conf // spawn protection init. if (server_var(yatf_es_spawnprotection) notequalto 0) do { // spawn protection feature enabled // spawn protection status helping to check if will must slay or not... es_xset yatf_es_spawnprotection_status 0 // spawn protection real time is mp_freezetime + spawn protection time es_xset yatf_es_spawnprotection_duration 0 es_math yatf_es_spawnprotection_duration + server_var(mp_freezetime) es_math yatf_es_spawnprotection_duration + server_var(yatf_es_spawnprotection) } // keygroup to store flashed players :: creation es_xset yatf_es_exists 0 es_xexists yatf_es_exists keygroup yatf_es_kg_flashed_players if (server_var(yatf_es_exists) equalto 0) then es_xkeygroupcreate yatf_es_kg_flashed_players // keygroup to store restricted players :: creation es_xset yatf_es_exists 0 es_xexists yatf_es_exists keygroup yatf_es_kg_restricted_players if (server_var(yatf_es_exists) equalto 0) then es_xkeygroupcreate yatf_es_kg_restricted_players // keygroup to store teamflashs by player :: creation es_xset yatf_es_exists 0 es_xexists yatf_es_exists keygroup yatf_es_kg_teamflashs if (server_var(yatf_es_exists) equalto 0) then es_xkeygroupcreate yatf_es_kg_teamflashs } block unload { /// unload block // required actions at script unload // keygroup to store flashed players :: deletion es_xset yatf_es_exists 0 es_xexists yatf_es_exists keygroup yatf_es_kg_flashed_players if (server_var(yatf_es_exists) notequalto 0) then es_xkeygroupdelete yatf_es_kg_flashed_players // keygroup to store restricted players :: deletion es_xset yatf_es_exists 0 es_xexists yatf_es_exists keygroup yatf_es_kg_restricted_players if (server_var(yatf_es_exists) notequalto 0) then es_xkeygroupdelete yatf_es_kg_restricted_players // keygroup to store teamflashs by player :: deletion es_xset yatf_es_exists 0 es_xexists yatf_es_exists keygroup yatf_es_kg_teamflashs if (server_var(yatf_es_exists) notequalto 0) then es_xkeygroupdelete yatf_es_kg_teamflashs } event es_map_start { /// event es_map_start // triggered at map starts // loading configuration to reset to default value es_xdoblock yatf_es/yatf_es_conf // spawn protection init. (in case, mp_freezetime changed) if (server_var(yatf_es_spawnprotection) notequalto 0) do { // spawn protection feature enabled // spawn protection status helping to check if will must slay or not... es_xset yatf_es_spawnprotection_status 0 // spawn protection real time is mp_freezetime + spawn protection time es_xset yatf_es_spawnprotection_duration 0 es_math yatf_es_spawnprotection_duration + server_var(mp_freezetime) es_math yatf_es_spawnprotection_duration + server_var(yatf_es_spawnprotection) } // managing warmup feature if (server_var(yatf_es_warmup) notequalto 0) do { // if warmup activated, disabling yatf for a while es est_UnRestrict #a flashbang es_set yatf_es_enable_state server_var(yatf_es_enable) es_xset yatf_es_enable 0 es_delayed server_var(yatf_es_warmup) es_set yatf_es_enable server_var(yatf_es_enable_state) } } event round_start { /// round_start // triggered at round starts // if yatf enabled if (server_var(yatf_es_enable) notequalto 0) do { // if spawn protection enabled if (server_var(yatf_es_spawnprotection) notequalto 0) do { // then enable the "slay" mode during spawn protection duration es_xset yatf_es_spawnprotection_status 1 es_delayed server_var(yatf_es_spawnprotection_duration) es_xset yatf_es_spawnprotection_status 0 } // flash restriction management es_set yatf_es_frp_tmp server_var(yatf_es_flashrestrict_percent) es_set yatf_es_frc_tmp server_var(yatf_es_flashrestrict_cumulative) ifx parse("yatf_es_frp_tmp != 0 or yatf_es_frc_tmp != 0") do { // unrestrict flashbang for everyone es est_UnRestrict #a flashbang // setup restrictions and clear old restriction es_xset yatf_es_crestricted_player 0 es_foreachkey yatf_es_crestricted_player in yatf_es_kg_restricted_players "es_xdoblock yatf_es/yatf_es_setup_restrict" } } } event player_connect { /// player_connect // trigger when player is connecting to the server // creating key into kg yatf_es_kg_restricted_players es_keycreate yatf_es_kg_restricted_players event_var(userid) es_keysetvalue yatf_es_kg_restricted_players event_var(userid) restrictleft 0 // creating key into kg yatf_es_kg_teamflashs es_keycreate yatf_es_kg_teamflashs event_var(userid) es_keysetvalue yatf_es_kg_teamflashs event_var(userid) teamflashs 0 } event player_disconnect { /// player_disconnect // triggered at player disconnect // let's clean restriction kg es_keydelete yatf_es_kg_restricted_players event_var(userid) // let's clean teamflashs kg es_keydelete yatf_es_kg_teamflashs event_var(userid) } event player_blind { /// player_blind // triggered when a player is flashed // if yatf enabled if (server_var(yatf_es_enable) notequalto 0) do { // Note: it seems player_blind is triggered BEFORE flashbang_detonate (weird)!!! // getting flash duration value es_xset yatf_es_cflashduration 0 es_getplayerprop yatf_es_cflashduration event_var(userid) CCSPlayer.m_flFlashDuration if (server_var(yatf_es_cflashduration) notlessthan server_var(yatf_es_flashduration)) do { // storing flashed players into flashed kg es_keycreate yatf_es_kg_flashed_players event_var(userid) es_keysetvalue yatf_es_kg_flashed_players event_var(userid) team event_var(es_userteam) } } } event flashbang_detonate { /// flashband_detonate // triggered when a flashband detonate // if yatf enabled if (server_var(yatf_es_enable) notequalto 0) do { // Note: it seems player_blind is triggered BEFORE flashbang_detonate (weird)!!! // storing flasher's infos es_set yatf_es_flasher_player_userid event_var(userid) es_set yatf_es_flasher_player_userteam event_var(es_userteam) es_set yatf_es_flasher_player_username event_var(es_username) // will help in the computing of the number of team flashs es_xset yatf_es_teamflash 0 // foreach flashed_players, do some checks es_xset yatf_es_cflashed_player 0 es_foreachkey yatf_es_cflashed_player in yatf_es_kg_flashed_players "es_xdoblock yatf_es/yatf_es_check" if (server_var(yatf_es_teamflash) notequalto 0) do { // if it's a teamflash // first, let's display a message about the number of flashed players // if sayteamonly is enabled if (server_var(yatf_es_sayteamonly) equalto 1) do { // then we should tell everyone on the team // if flasher (or flashed) team is T (2) if (server_var(yatf_es_flasher_player_userteam) equalto 2) do { es_xset yatf_es_cnotify_player 0 foreach player yatf_es_cnotify_player #t "es_tell server_var(yatf_es_cnotify_player) #multi #greenyATF_ES: #default(T) server_var(yatf_es_phrase_flashednum) #lightgreen server_var(yatf_es_teamflash) #default! } // if flasher (or flashed) team is CT (3) if (server_var(yatf_es_flasher_player_userteam) equalto 3) do { es_xset yatf_es_cnotify_player 0 foreach player yatf_es_cnotify_player #ct "es_tell server_var(yatf_es_cnotify_player) #multi #greenyATF_ES: #default(CT) server_var(yatf_es_phrase_flashednum) #lightgreen server_var(yatf_es_teamflash) #default! } } else do { // else, a simple es_msg is required es_msg #multi #greenyATF_ES: #default(ALL) server_var(yatf_es_phrase_flashednum) #lightgreen server_var(yatf_es_teamflash) #default! } // managing spawn protection if (server_var(yatf_es_spawnprotection) notequalto 0) do { // if spawn protection is active if (server_var(yatf_es_spawnprotection_status) equalto 1) do { es_sexec server_var(yatf_es_flasher_player_userid) kill es_msg #multi #greenyATF_ES: #default(ALL)#lightgreen server_var(yatf_es_flasher_player_username) #default server_var(yatf_es_phrase_spawnflash) } } // getting player restriction left es_xset yatf_es_flasher_player_restrictleft 0 es_keygetvalue yatf_es_flasher_player_restrictleft yatf_es_kg_restricted_players server_var(yatf_es_flasher_player_userid) restrictleft // managing percent flash restriction if (server_var(yatf_es_flashrestrict_percent) notequalto 0) do { // computing percent of player flashed es_xset yatf_es_teamcount 0 es_getplayercount yatf_es_teamcount server_var(yatf_es_flasher_player_userteam) es_xset yatf_es_teamflash_tmp 0 es_set yatf_es_teamflash_tmp server_var(yatf_es_teamflash) es_xmath yatf_es_teamflash_tmp float if (server_var(yatf_es_teamcount) notequalto 0) do { es_math yatf_es_teamflash_tmp / server_var(yatf_es_teamcount) // if flasher has flashed at least the number of players to trigger restriction if (server_var(yatf_es_teamflash_tmp) notlessthan server_var(yatf_es_flashrestrict_percent)) do { // computing new restrict left es_math yatf_es_flasher_player_restrictleft + server_var(yatf_es_flashrestrict_rounds) } } } // managing cumulative flash restriction if (server_var(yatf_es_flashrestrict_cumulative) notequalto 0) do { // computing cumulative teamflashs es_xset yatf_es_teamflash_tmp 0 es_keygetvalue yatf_es_teamflash_tmp yatf_es_kg_teamflashs server_var(yatf_es_flasher_player_userid) teamflashs es_math yatf_es_teamflash_tmp + server_var(yatf_es_teamflash) // while we are above the cumulative team flashs limit, we add restrict, and we minus number of cumulative while "server_var(yatf_es_teamflash_tmp) >= server_var(yatf_es_flashrestrict_cumulative)" "es_xdoblock yatf_es/yatf_es_whiletfmgmt" // storing the new cumulative teamflashs value es_keysetvalue yatf_es_kg_teamflashs server_var(yatf_es_flasher_player_userid) teamflashs server_var(yatf_es_teamflash_tmp) } // storing the new restrictleft value es_keysetvalue yatf_es_kg_restricted_players server_var(yatf_es_flasher_player_userid) restrictleft server_var(yatf_es_flasher_player_restrictleft) // clearing yatf_es_kg_flashed_players // keygroup to store flashed players :: deletion es_xset yatf_es_exists 0 es_xexists yatf_es_exists keygroup yatf_es_kg_flashed_players if (server_var(yatf_es_exists) notequalto 0) then es_xkeygroupdelete yatf_es_kg_flashed_players // keygroup to store flashed players :: creation es_xset yatf_es_exists 0 es_xexists yatf_es_exists keygroup yatf_es_kg_flashed_players if (server_var(yatf_es_exists) equalto 0) then es_xkeygroupcreate yatf_es_kg_flashed_players } } } block yatf_es_check { /// block yatf_es_check // getting flashed player team es_xset yatf_es_cflashed_player_userteam 0 es_keygetvalue yatf_es_cflashed_player_userteam yatf_es_kg_flashed_players server_var(yatf_es_cflashed_player) team // if it's not a self flashing if (server_var(yatf_es_cflashed_player) notequalto server_var(yatf_es_flasher_player_userid)) do { // then // if flashed player is in the same team as flasher if (server_var(yatf_es_cflashed_player_userteam) equalto server_var(yatf_es_flasher_player_userteam)) do { // then, it's a teamflash // getting flashed player properties es_xset yatf_es_cflashed_player_username 0 es_getplayername yatf_es_cflashed_player_username server_var(yatf_es_cflashed_player) es_xset yatf_es_cflashed_player_dead 0 playerget isdead yatf_es_cflashed_player_dead server_var(yatf_es_cflashed_player) // if player is alive if (server_var(yatf_es_cflashed_player_dead) equalto 0) do { // then let's notify people about this bad guy ;) // if sayteamonly is enabled if (server_var(yatf_es_sayteamonly) equalto 1) do { // then we should tell everyone on the team // if flasher (or flashed) team is T (2) if (server_var(yatf_es_flasher_player_userteam) equalto 2) do { es_xset yatf_es_cnotify_player 0 foreach player yatf_es_cnotify_player #t "es_tell server_var(yatf_es_cnotify_player) #multi #greenyATF_ES: #default(T)#lightgreen server_var(yatf_es_flasher_player_username) #default server_var(yatf_es_phrase_flashteamate) #lightgreen server_var(yatf_es_cflashed_player_username) #default! } // if flasher (or flashed) team is CT (3) if (server_var(yatf_es_flasher_player_userteam) equalto 3) do { es_xset yatf_es_cnotify_player 0 foreach player yatf_es_cnotify_player #ct "es_tell server_var(yatf_es_cnotify_player) #multi #greenyATF_ES: #default(CT)#lightgreen server_var(yatf_es_flasher_player_username) #default server_var(yatf_es_phrase_flashteamate) #lightgreen server_var(yatf_es_cflashed_player_username) #default! } } else do { // else, a simple es_msg is required es_msg #multi #greenyATF_ES: #default(ALL)#lightgreen server_var(yatf_es_flasher_player_username) #default server_var(yatf_es_phrase_flashteamate) #lightgreen server_var(yatf_es_cflashed_player_username) #default! } es_xmath yatf_es_teamflash + 1 } } } } block yatf_es_setup_restrict { /// block yatf_es_setup_restrict // getting player restriction left es_xset yatf_es_cplayer_restrictleft 0 es_keygetvalue yatf_es_cplayer_restrictleft yatf_es_kg_restricted_players server_var(yatf_es_crestricted_player) restrictleft // if there's a restriction activated if (server_var(yatf_es_cplayer_restrictleft) notequalto 0) do { // restrict setup and notify player es est_Restrict server_var(yatf_es_crestricted_player) flashbang es_tell server_var(yatf_es_crestricted_player) #multi #greenyATF_ES: #default server_var(yatf_es_phrase_restricted) server_var(yatf_es_cplayer_restrictleft) round(s)! // setting the new value for restrictleft es_xmath yatf_es_cplayer_restrictleft - 1 es_keysetvalue yatf_es_kg_restricted_players server_var(yatf_es_crestricted_player) restrictleft server_var(yatf_es_cplayer_restrictleft) } } block yatf_es_whiletfmgmt { /// block yatf_es_whiletfmgmt es_math yatf_es_flasher_player_restrictleft + server_var(yatf_es_flashrestrict_rounds) es_math yatf_es_teamflash_tmp - server_var(yatf_es_flashrestrict_cumulative) }