HLMOD.HU Forrás Megtekintés
- www.hlmod.hu#include < amxmodx >
#include < amxmisc >
#include < fakemeta >
#include < hamsandwich >
#define PLUGIN "Info Message HUD"
#define VERSION "1.3"
#define AUTHOR "Blizzard/guipatinador"
new const szColors[ ][ ] = {
"white",
"red",
"green",
"blue",
"aqua",
"purple",
"orange",
"yellow",
"gold",
"silver"
}
new const COLORS[ ][ ] = {
{ 255, 255, 255 },
{ 255, 0, 0 },
{ 0, 255, 0 },
{ 0, 0, 255 },
{ 0, 255, 255 },
{ 255, 0, 255 },
{ 255, 170, 0 },
{ 255, 255, 0 },
{ 212, 255, 0 },
{ 210, 210, 210 }
}
enum _:Structure {
iRedValue,
iGreenValue,
iBlueValue,
}
new g_HudColors[ Structure ]
enum ( += 1 ) {
ALIVE = 1,
DEAD,
ALL
}
new Trie:g_tColors
new Trie:g_tClassName
new g_szClassName[ ] = "Timer"
new g_szMapName[ 32 ]
new g_szHostname[ 64 ]
new g_pcvarHudType
new bool:g_IsAlive[ 33 ]
new x_pos, y_pos;
public plugin_init( )
{
register_plugin( PLUGIN, VERSION, AUTHOR )
get_mapname( g_szMapName, charsmax( g_szMapName ) )
get_cvar_string( "hostname", g_szHostname, charsmax( g_szHostname ) )
register_concmd( "hud_color", "ChangeColor", ADMIN_RCON, "white or red or green or blue" )
x_pos = register_cvar("hud_x_pos", "-1.0");
y_pos = register_cvar("hud_y_pos", "0.0");
g_pcvarHudType = register_cvar( "hud_type", "3" )
// 1 = csak az élő embereknek
// 2 = csak a halott embereknek
// 3 = mindenkinek
g_tColors = TrieCreate( )
new i
for( i = 0; i < sizeof COLORS; i++ )
{
TrieSetCell( g_tColors, szColors[ i ], i )
}
g_tClassName = TrieCreate( )
TrieSetCell( g_tClassName, g_szClassName, 1 )
new iEnt = engfunc( EngFunc_CreateNamedEntity, engfunc( EngFunc_AllocString,"info_target" ) )
set_pev( iEnt, pev_classname, g_szClassName )
set_pev( iEnt, pev_nextthink, 1.0 )
RegisterHam( Ham_Spawn, "player", "FwdPlayerSpawnPost", 1 )
RegisterHam( Ham_Killed, "player", "FwdPlayerKilledPost", 1 )
register_forward( FM_Think,"ForwardThink" )
}
public plugin_cfg( )
{
server_cmd( "hud_color white" )
}
public client_connect( id )
{
g_IsAlive[ id ] = false
}
public FwdPlayerSpawnPost( id )
{
if( is_user_alive( id ) )
{
g_IsAlive[ id ] = true
}
}
public FwdPlayerKilledPost( iVictim )
{
g_IsAlive[ iVictim ] = false
}
public ChangeColor( id, level, cid )
{
if ( !cmd_access( id, level, cid, 2 ) )
return PLUGIN_HANDLED
static szColor[ 16 ]
read_argv( 1, szColor, charsmax( szColor ) )
strtolower( szColor )
static iPos
if( TrieGetCell( g_tColors, szColor, iPos ) )
{
g_HudColors[ iRedValue ] = COLORS[ iPos ][ 0 ]
g_HudColors[ iGreenValue ] = COLORS[ iPos ][ 1 ]
g_HudColors[ iBlueValue ] = COLORS[ iPos ][ 2 ]
console_print( id, "HUD szin modositva erre: %s", szColor )
}
else
{
console_print( id, "%s ervenytelen szin!", szColor )
}
return PLUGIN_HANDLED
}
public ForwardThink( iEnt )
{
static szClassName[ 32 ]
pev( iEnt, pev_classname, szClassName, charsmax( szClassName ) )
if( !TrieKeyExists( g_tClassName, szClassName ) )
return FMRES_IGNORED
new iHudType = get_pcvar_num( g_pcvarHudType )
new Players[ 32 ]
new iNum
new i
get_players( Players, iNum, "ch" )
for( --iNum; iNum >= 0; iNum-- )
{
i = Players[ iNum ]
switch( iHudType )
{
case ALIVE:
{
if( g_IsAlive[ i ] )
{
ShowTimer( i )
}
}
case DEAD:
{
if( !g_IsAlive[ i ] )
{
ShowTimer( i )
}
}
case ALL:
{
ShowTimer( i )
}
}
}
static Float:fGlobalTime
global_get( glb_time, fGlobalTime )
set_pev( iEnt, pev_nextthink, fGlobalTime + 1.0 )
return FMRES_IGNORED
}
public ShowTimer( id )
{
new iTimeLeft = get_timeleft( )
set_hudmessage( g_HudColors[ iRedValue ], g_HudColors[ iGreenValue ], g_HudColors[ iBlueValue ], get_pcvar_float(x_pos), get_pcvar_float(y_pos), 0, 0.0, 1.0 )
show_hudmessage( id, "Hátralévő idő: %d:%02d | %s | Pálya: %s", iTimeLeft / 60, iTimeLeft % 60, g_szHostname, g_szMapName )
}