-
-
Save 2called-chaos/d255b7ed2c09f1d3d7e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* | |
* 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 | |
} | |
// flash player on spawn | |
public event_player_spawned(id) | |
{ | |
// 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 HAM_IGNORED | |
flash_user_with_team_color(id) | |
} | |
// reset round started | |
public reset_round_started() | |
{ | |
g_round_started = false | |
} | |
// ============ | |
// = 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) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment