Skip to content

Instantly share code, notes, and snippets.

@2called-chaos
Last active December 27, 2015 21:49
Show Gist options
  • Save 2called-chaos/d255b7ed2c09f1d3d7e9 to your computer and use it in GitHub Desktop.
Save 2called-chaos/d255b7ed2c09f1d3d7e9 to your computer and use it in GitHub Desktop.

Revisions

  1. 2called-chaos revised this gist Nov 10, 2013. 1 changed file with 2 additions and 6 deletions.
    8 changes: 2 additions & 6 deletions gistfile1.cs
    Original file line number Diff line number Diff line change
    @@ -69,29 +69,26 @@ public plugin_init()
    public event_new_round()
    {
    g_round_started = true
    return PLUGIN_CONTINUE
    }

    // flash player on spawn
    public event_player_spawned(id)
    {
    // plugin disabled
    if (!get_pcvar_num(g_enabled))
    return PLUGIN_CONTINUE
    return HAM_IGNORED

    // we don't flash on every spawn and round has not been started recently
    if (!get_pcvar_num(g_flash_on_spawn) && !g_round_started)
    return PLUGIN_CONTINUE
    return HAM_IGNORED

    flash_user_with_team_color(id)
    return PLUGIN_CONTINUE
    }

    // reset round started
    public reset_round_started()
    {
    g_round_started = false
    return PLUGIN_CONTINUE
    }


    @@ -133,6 +130,5 @@ public reset_round_started()

    // actual fade
    UTIL_ScreenFade(id, color, get_pcvar_float(g_flash_duration), get_pcvar_float(g_flash_stay), get_pcvar_num(g_flash_alpha), FFADE_IN, true)
    return PLUGIN_CONTINUE
    }

  2. 2called-chaos revised this gist Nov 10, 2013. 1 changed file with 56 additions and 52 deletions.
    108 changes: 56 additions & 52 deletions gistfile1.cs
    Original file line number Diff line number Diff line change
    @@ -44,21 +44,21 @@

    public plugin_init()
    {
    register_plugin("who2shoot", "1.0", "2called-chaos")
    g_round_started = true

    // events
    register_event("HLTV" , "event_new_round" , "a" , "1=0" , "2=0")
    RegisterHam(Ham_Spawn, "player", "event_player_spawned", 1)
    register_logevent("reset_round_started", 2, "1=Round_Start")
    register_logevent("reset_round_started", 2, "1=Round_End")

    // cvars
    g_enabled = register_cvar("amx_who2shoot", "1")
    g_flash_on_spawn = register_cvar("amx_who2shoot_spawn", "1")
    g_flash_stay = register_cvar("amx_who2shoot_stay", "0.1")
    g_flash_duration = register_cvar("amx_who2shoot_duration", "0.3")
    g_flash_alpha = register_cvar("amx_who2shoot_alpha", "180")
    register_plugin("who2shoot", "1.0", "2called-chaos")
    g_round_started = true

    // events
    register_event("HLTV" , "event_new_round" , "a" , "1=0" , "2=0")
    RegisterHam(Ham_Spawn, "player", "event_player_spawned", 1)
    register_logevent("reset_round_started", 2, "1=Round_Start")
    register_logevent("reset_round_started", 2, "1=Round_End")

    // cvars
    g_enabled = register_cvar("amx_who2shoot", "1")
    g_flash_on_spawn = register_cvar("amx_who2shoot_spawn", "1")
    g_flash_stay = register_cvar("amx_who2shoot_stay", "0.1")
    g_flash_duration = register_cvar("amx_who2shoot_duration", "0.3")
    g_flash_alpha = register_cvar("amx_who2shoot_alpha", "180")
    }

    // ==========
    @@ -68,27 +68,30 @@ public plugin_init()
    // new round
    public event_new_round()
    {
    g_round_started = true
    g_round_started = true
    return PLUGIN_CONTINUE
    }

    // flash player on spawn
    public event_player_spawned(id)
    {
    // plugin disabled
    if (!get_pcvar_num(g_enabled))
    return HAM_IGNORED
    // plugin disabled
    if (!get_pcvar_num(g_enabled))
    return PLUGIN_CONTINUE

    // we don't flash on every spawn and round has not been started recently
    if (!get_pcvar_num(g_flash_on_spawn) && !g_round_started)
    return HAM_IGNORED
    // we don't flash on every spawn and round has not been started recently
    if (!get_pcvar_num(g_flash_on_spawn) && !g_round_started)
    return PLUGIN_CONTINUE

    flash_user_with_team_color(id)
    flash_user_with_team_color(id)
    return PLUGIN_CONTINUE
    }

    // reset round started
    public reset_round_started()
    {
    g_round_started = false
    g_round_started = false
    return PLUGIN_CONTINUE
    }


    @@ -98,37 +101,38 @@ public reset_round_started()
    // ============
    flash_user_with_team_color(id)
    {
    // plugin disabled
    if (!get_pcvar_num(g_enabled))
    return PLUGIN_CONTINUE

    // user dead
    if (!is_user_alive(id))
    return PLUGIN_CONTINUE
    // plugin disabled
    if (!get_pcvar_num(g_enabled))
    return PLUGIN_CONTINUE

    // user dead
    if (!is_user_alive(id))
    return PLUGIN_CONTINUE

    // set color
    new color[3]
    switch(cs_get_user_team(id))
    {
    case CS_TEAM_T:
    {
    color[0] = T_LAYER_COLOR_R
    color[1] = T_LAYER_COLOR_G
    color[2] = T_LAYER_COLOR_B
    }

    // set color
    new color[3]
    switch(cs_get_user_team(id))
    case CS_TEAM_CT:
    {
    case CS_TEAM_T:
    {
    color[0] = T_LAYER_COLOR_R
    color[1] = T_LAYER_COLOR_G
    color[2] = T_LAYER_COLOR_B
    }

    case CS_TEAM_CT:
    {
    color[0] = CT_LAYER_COLOR_R
    color[1] = CT_LAYER_COLOR_G
    color[2] = CT_LAYER_COLOR_B
    }

    default: // Spec or unassigned
    return PLUGIN_CONTINUE
    color[0] = CT_LAYER_COLOR_R
    color[1] = CT_LAYER_COLOR_G
    color[2] = CT_LAYER_COLOR_B
    }

    // actual fade
    UTIL_ScreenFade(id, color, get_pcvar_float(g_flash_duration), get_pcvar_float(g_flash_stay), get_pcvar_num(g_flash_alpha), FFADE_IN, true)
    default: // Spec or unassigned
    return PLUGIN_CONTINUE
    }

    // actual fade
    UTIL_ScreenFade(id, color, get_pcvar_float(g_flash_duration), get_pcvar_float(g_flash_stay), get_pcvar_num(g_flash_alpha), FFADE_IN, true)
    return PLUGIN_CONTINUE
    }

  3. 2called-chaos revised this gist Nov 10, 2013. 1 changed file with 52 additions and 56 deletions.
    108 changes: 52 additions & 56 deletions gistfile1.cs
    Original file line number Diff line number Diff line change
    @@ -44,21 +44,21 @@

    public plugin_init()
    {
    register_plugin("who2shoot", "1.0", "2called-chaos")
    g_round_started = true

    // events
    register_event("HLTV" , "event_new_round" , "a" , "1=0" , "2=0")
    RegisterHam(Ham_Spawn, "player", "event_player_spawned", 1)
    register_logevent("reset_round_started", 2, "1=Round_Start")
    register_logevent("reset_round_started", 2, "1=Round_End")

    // cvars
    g_enabled = register_cvar("amx_who2shoot", "1")
    g_flash_on_spawn = register_cvar("amx_who2shoot_spawn", "1")
    g_flash_stay = register_cvar("amx_who2shoot_stay", "0.1")
    g_flash_duration = register_cvar("amx_who2shoot_duration", "0.3")
    g_flash_alpha = register_cvar("amx_who2shoot_alpha", "180")
    register_plugin("who2shoot", "1.0", "2called-chaos")
    g_round_started = true

    // events
    register_event("HLTV" , "event_new_round" , "a" , "1=0" , "2=0")
    RegisterHam(Ham_Spawn, "player", "event_player_spawned", 1)
    register_logevent("reset_round_started", 2, "1=Round_Start")
    register_logevent("reset_round_started", 2, "1=Round_End")

    // cvars
    g_enabled = register_cvar("amx_who2shoot", "1")
    g_flash_on_spawn = register_cvar("amx_who2shoot_spawn", "1")
    g_flash_stay = register_cvar("amx_who2shoot_stay", "0.1")
    g_flash_duration = register_cvar("amx_who2shoot_duration", "0.3")
    g_flash_alpha = register_cvar("amx_who2shoot_alpha", "180")
    }

    // ==========
    @@ -68,30 +68,27 @@ public plugin_init()
    // new round
    public event_new_round()
    {
    g_round_started = true
    return PLUGIN_CONTINUE
    g_round_started = true
    }

    // flash player on spawn
    public event_player_spawned(id)
    {
    // plugin disabled
    if (!get_pcvar_num(g_enabled))
    return PLUGIN_CONTINUE
    // plugin disabled
    if (!get_pcvar_num(g_enabled))
    return HAM_IGNORED

    // we don't flash on every spawn and round has not been started recently
    if (!get_pcvar_num(g_flash_on_spawn) && !g_round_started)
    return PLUGIN_CONTINUE
    // we don't flash on every spawn and round has not been started recently
    if (!get_pcvar_num(g_flash_on_spawn) && !g_round_started)
    return HAM_IGNORED

    flash_user_with_team_color(id)
    return PLUGIN_CONTINUE
    flash_user_with_team_color(id)
    }

    // reset round started
    public reset_round_started()
    {
    g_round_started = false
    return PLUGIN_CONTINUE
    g_round_started = false
    }


    @@ -101,38 +98,37 @@ public reset_round_started()
    // ============
    flash_user_with_team_color(id)
    {
    // plugin disabled
    if (!get_pcvar_num(g_enabled))
    return PLUGIN_CONTINUE

    // user dead
    if (!is_user_alive(id))
    return PLUGIN_CONTINUE

    // set color
    new color[3]
    switch(cs_get_user_team(id))
    {
    case CS_TEAM_T:
    {
    color[0] = T_LAYER_COLOR_R
    color[1] = T_LAYER_COLOR_G
    color[2] = T_LAYER_COLOR_B
    }
    // plugin disabled
    if (!get_pcvar_num(g_enabled))
    return PLUGIN_CONTINUE

    case CS_TEAM_CT:
    // user dead
    if (!is_user_alive(id))
    return PLUGIN_CONTINUE

    // set color
    new color[3]
    switch(cs_get_user_team(id))
    {
    color[0] = CT_LAYER_COLOR_R
    color[1] = CT_LAYER_COLOR_G
    color[2] = CT_LAYER_COLOR_B
    case CS_TEAM_T:
    {
    color[0] = T_LAYER_COLOR_R
    color[1] = T_LAYER_COLOR_G
    color[2] = T_LAYER_COLOR_B
    }

    case CS_TEAM_CT:
    {
    color[0] = CT_LAYER_COLOR_R
    color[1] = CT_LAYER_COLOR_G
    color[2] = CT_LAYER_COLOR_B
    }

    default: // Spec or unassigned
    return PLUGIN_CONTINUE
    }

    default: // Spec or unassigned
    return PLUGIN_CONTINUE
    }

    // actual fade
    UTIL_ScreenFade(id, color, get_pcvar_float(g_flash_duration), get_pcvar_float(g_flash_stay), get_pcvar_num(g_flash_alpha), FFADE_IN, true)
    return PLUGIN_CONTINUE
    // actual fade
    UTIL_ScreenFade(id, color, get_pcvar_float(g_flash_duration), get_pcvar_float(g_flash_stay), get_pcvar_num(g_flash_alpha), FFADE_IN, true)
    }

  4. 2called-chaos renamed this gist Nov 10, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. 2called-chaos renamed this gist Nov 10, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  6. 2called-chaos renamed this gist Nov 10, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  7. 2called-chaos created this gist Nov 10, 2013.
    138 changes: 138 additions & 0 deletions who2shoot.c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,138 @@
    /*
    *
    * Author: 2called-chaos
    * Date: 10-November-2013
    *
    *
    * Description: "Flashes" user on each spawn or round start with it's team color.
    * Especially on deathmatch it's sometimes surprising if you got teambalanced.
    *
    * Cvars:
    *
    * amx_who2shoot 1 Enable plugin
    * amx_who2shoot_spawn 1 flash 1 = on every spawn; 0 = only on round start
    * amx_who2shoot_stay 0.1 Duration layer is shown before fading it out
    * amx_who2shoot_duration 0.3 Duration of the fade effect in seconds
    * amx_who2shoot_alpha 150 Max. alpha of the layer (0 = invisible, 255 = solid)
    *
    *
    * Requirements: AMXModX
    * cstrike
    * HamSandwich
    * Screenfade Util (https://forums.alliedmods.net/showthread.php?t=87623)
    *
    */

    #include <amxmodx>
    #include <cstrike>
    #include <hamsandwich>
    #include <screenfade_util>

    // Layer color CT (R, G, B)
    #define CT_LAYER_COLOR_R 110
    #define CT_LAYER_COLOR_G 156
    #define CT_LAYER_COLOR_B 190

    // Layer color T (R, G, B)
    #define T_LAYER_COLOR_R 255
    #define T_LAYER_COLOR_G 63
    #define T_LAYER_COLOR_B 63

    // Globals
    new g_enabled, g_flash_on_spawn, g_flash_stay, g_flash_duration, g_flash_alpha
    new bool:g_round_started

    public plugin_init()
    {
    register_plugin("who2shoot", "1.0", "2called-chaos")
    g_round_started = true

    // events
    register_event("HLTV" , "event_new_round" , "a" , "1=0" , "2=0")
    RegisterHam(Ham_Spawn, "player", "event_player_spawned", 1)
    register_logevent("reset_round_started", 2, "1=Round_Start")
    register_logevent("reset_round_started", 2, "1=Round_End")

    // cvars
    g_enabled = register_cvar("amx_who2shoot", "1")
    g_flash_on_spawn = register_cvar("amx_who2shoot_spawn", "1")
    g_flash_stay = register_cvar("amx_who2shoot_stay", "0.1")
    g_flash_duration = register_cvar("amx_who2shoot_duration", "0.3")
    g_flash_alpha = register_cvar("amx_who2shoot_alpha", "180")
    }

    // ==========
    // = EVENTS =
    // ==========

    // new round
    public event_new_round()
    {
    g_round_started = true
    return PLUGIN_CONTINUE
    }

    // flash player on spawn
    public event_player_spawned(id)
    {
    // plugin disabled
    if (!get_pcvar_num(g_enabled))
    return PLUGIN_CONTINUE

    // we don't flash on every spawn and round has not been started recently
    if (!get_pcvar_num(g_flash_on_spawn) && !g_round_started)
    return PLUGIN_CONTINUE

    flash_user_with_team_color(id)
    return PLUGIN_CONTINUE
    }

    // reset round started
    public reset_round_started()
    {
    g_round_started = false
    return PLUGIN_CONTINUE
    }



    // ============
    // = FLASHING =
    // ============
    flash_user_with_team_color(id)
    {
    // plugin disabled
    if (!get_pcvar_num(g_enabled))
    return PLUGIN_CONTINUE

    // user dead
    if (!is_user_alive(id))
    return PLUGIN_CONTINUE

    // set color
    new color[3]
    switch(cs_get_user_team(id))
    {
    case CS_TEAM_T:
    {
    color[0] = T_LAYER_COLOR_R
    color[1] = T_LAYER_COLOR_G
    color[2] = T_LAYER_COLOR_B
    }

    case CS_TEAM_CT:
    {
    color[0] = CT_LAYER_COLOR_R
    color[1] = CT_LAYER_COLOR_G
    color[2] = CT_LAYER_COLOR_B
    }

    default: // Spec or unassigned
    return PLUGIN_CONTINUE
    }

    // actual fade
    UTIL_ScreenFade(id, color, get_pcvar_float(g_flash_duration), get_pcvar_float(g_flash_stay), get_pcvar_num(g_flash_alpha), FFADE_IN, true)
    return PLUGIN_CONTINUE
    }