Код:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <csstats>
#include <hamsandwich>
#define PLUGIN "Score Admin Info"
#define VERSION "1.1"
#define AUTHOR "vato loco [GE-S]"
#define PLUGIN_CVAR "score_admin_info"
#define MAX_PLAYERS 32 + 1
#define MAX_NAME_LENGTH 31 + 1
#define MAX_CVARS 6
#define MAX_CHACHE_CVARS 3
#define MSG_DELAY 90.0
#define ACCESS_HIDE ADMIN_BAN
enum { KILLS = 0, DEATH, SCORE_TYPES }
enum { RED = 0, GREEN, BLUE, MSG_COLORS }
enum { POSITIVE = 0, STANDARD ,NEGATIVE, MSG_TYPES }
new g_Blank[] = ""
new g_ClassName[] = "sai_info"
new Float:g_fLastMsg
new Float:g_fMsgDelay = MSG_DELAY
new bool:g_bShowScore[MAX_PLAYERS]
new bool:g_bIsAdmin[MAX_PLAYERS]
new bool:g_bIsAlive[MAX_PLAYERS]
new bool:g_bIsConnected[MAX_PLAYERS]
new bool:g_bIsBot[MAX_PLAYERS]
new g_iRank[MAX_PLAYERS]
new g_iPlayerName[MAX_PLAYERS][MAX_NAME_LENGTH]
new g_iScore[MAX_PLAYERS][SCORE_TYPES]
new g_pCvar[MAX_CVARS]
new g_CachepCvar[MAX_CHACHE_CVARS]
new g_iColor[MSG_TYPES][MSG_COLORS]
new g_SyncScoreInfo
new g_iMaxStats
new g_iMaxPlayers
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_cvar(PLUGIN_CVAR, VERSION, FCVAR_SERVER|FCVAR_SPONLY, 0.0)
register_think(g_ClassName,"ForwardThink")
register_event("HLTV", "ev_RoundStart", "a", "1=0", "2=0")
register_event("ScoreInfo", "ev_ScoreInfo", "a")
RegisterHam(Ham_Spawn, "player", "client_alive", 1)
RegisterHam(Ham_Killed, "player", "client_alive", 1)
register_clcmd("say /myscore", "client_showscore")
register_clcmd("say .myscore", "client_showscore")
register_clcmd("say /ms", "client_showscore")
register_clcmd("say .ms", "client_showscore")
register_clcmd("say_team /myscore", "client_showscore")
register_clcmd("say_team .myscore", "client_showscore")
register_clcmd("say_team /ms", "client_showscore")
register_clcmd("say_team .ms", "client_showscore")
register_clcmd("say /hideme", "client_hide", ACCESS_HIDE)
register_clcmd("say .hideme", "client_hide", ACCESS_HIDE)
register_clcmd("say_team /hideme", "client_hide", ACCESS_HIDE)
register_clcmd("say_team .hideme", "client_hide", ACCESS_HIDE)
g_pCvar[0] = register_cvar("sai_enabled", "1")
g_pCvar[1] = register_cvar("sai_show_admin", "1")
g_pCvar[2] = register_cvar("sai_on_join", "1")
g_pCvar[3] = register_cvar("sai_positive_color", "0 160 0")
g_pCvar[4] = register_cvar("sai_standard_color", "255 255 0")
g_pCvar[5] = register_cvar("sai_negative_color", "255 0 0")
g_SyncScoreInfo = CreateHudSyncObj()
g_iMaxPlayers = get_maxplayers()
new iEnt = create_entity("info_target")
entity_set_string(iEnt, EV_SZ_classname, g_ClassName)
entity_set_float(iEnt, EV_FL_nextthink, get_gametime() + 1.0)
}
public plugin_cfg()
{
set_task(0.5, "ev_RoundStart")
}
public client_putinserver(id)
{
g_bIsConnected[id] = true
g_bIsBot[id] = bool:is_user_bot(id)
if(!g_bIsBot[id])
{
g_bShowScore[id] = bool:g_CachepCvar[2]
g_bIsAdmin[id] = bool:is_user_admin(id)
}
get_user_name(id, g_iPlayerName[id], 31)
}
public client_disconnect(id)
{
g_bIsAlive[id] = false
g_bIsConnected[id] = false
g_bShowScore[id] = false
g_bIsAdmin[id] = false
g_bIsBot[id] = false
}
public client_infochanged(id)
{
get_user_info(id, "name", g_iPlayerName[id], 31)
}
public client_showscore(id)
{
g_bShowScore[id] = !g_bShowScore[id]
client_print(id, print_center, g_bShowScore[id] ? "Show Score Enabled" : "Show Score Disabled")
}
public client_hide(id, lvl, cid)
{
if(!cmd_access(id, lvl, cid, 1))
{
return PLUGIN_HANDLED
}
g_bIsAdmin[id] = !g_bIsAdmin[id]
client_print(id, print_center, g_bIsAdmin[id] ? "Hide Modus Disabled" : "Hide Modus Enabled")
return PLUGIN_CONTINUE
}
public client_alive(id)
{
g_bIsAlive[id] = bool:is_user_alive(id)
}
public ev_RoundStart()
{
g_CachepCvar[0] = get_pcvar_num(g_pCvar[0])
g_CachepCvar[1] = get_pcvar_num(g_pCvar[1])
g_CachepCvar[2] = get_pcvar_num(g_pCvar[2])
GetCvarColor(g_pCvar[3], g_iColor[POSITIVE][RED], g_iColor[POSITIVE][GREEN], g_iColor[POSITIVE][BLUE])
GetCvarColor(g_pCvar[4], g_iColor[STANDARD][RED], g_iColor[STANDARD][GREEN], g_iColor[STANDARD][BLUE])
GetCvarColor(g_pCvar[5], g_iColor[NEGATIVE][RED], g_iColor[NEGATIVE][GREEN], g_iColor[NEGATIVE][BLUE])
new stats[8], bodyhits[8], id
g_iMaxStats = get_statsnum()
for(id = 1; id <= g_iMaxPlayers; id++)
{
if(g_bIsConnected[id])
{
g_iRank[id] = get_user_stats(id, stats, bodyhits)
}
}
}
public ev_ScoreInfo()
{
g_iScore[read_data(1)][KILLS] = read_data(2)
g_iScore[read_data(1)][DEATH] = read_data(3)
}
public ForwardThink(iEnt)
{
if(g_CachepCvar[0])
{
static id, target, specmode
for(id = 1; id <= g_iMaxPlayers; id++)
{
if(g_bIsConnected[id])
{
specmode = entity_get_int(id, EV_INT_iuser1)
if(g_bIsAlive[id])
{
if(g_bShowScore[id])
{
ShowPlayerInfo(id, g_iScore[id][KILLS], g_iScore[id][DEATH], 0.86, g_Blank, g_Blank, g_iRank[id])
}
}
else if(specmode == 2 || specmode == 4)
{
target = entity_get_int(id, EV_INT_iuser2)
if(target && target != id)
{
ShowPlayerInfo(id, g_iScore[target][KILLS], g_iScore[target][DEATH], 0.81, g_CachepCvar[1] ? g_bIsAdmin[target] ? "| Status: Admin |" : g_Blank : g_Blank, g_iPlayerName[target], g_iRank[target])
}
}
}
}
}
entity_set_float(iEnt, EV_FL_nextthink, get_gametime() + 0.1)
}
ShowPlayerInfo(id, iFrags, iDeath, Float:yPos, sAdmin[], sName[], iRank)
{
if(!g_bIsBot[id])
{
static Float:fEff, Float:fGameTime, r, g, b
fGameTime = get_gametime()
fEff = (100.0 * float(iFrags) / float(iFrags + iDeath))
if(iFrags > iDeath)
{
r = g_iColor[POSITIVE][RED]
g = g_iColor[POSITIVE][GREEN]
b = g_iColor[POSITIVE][BLUE]
}
else if(iFrags == iDeath)
{
r = g_iColor[STANDARD][RED]
g = g_iColor[STANDARD][GREEN]
b = g_iColor[STANDARD][BLUE]
}
else if(iFrags < iDeath)
{
r = g_iColor[NEGATIVE][RED]
g = g_iColor[NEGATIVE][GREEN]
b = g_iColor[NEGATIVE][BLUE]
}
if(g_fLastMsg + g_fMsgDelay <= fGameTime)
{
client_print(id, print_chat, g_bShowScore[id] ? "[AMXX] Type In Chat /myscore To Disable Your Score In Hud." : "[AMXX] Type In Chat /myscore To Enable Your Score In Hud.")
g_fLastMsg = fGameTime
}
set_hudmessage(r, g, b, -1.0, yPos, _, _, 0.2, _, _, -1)
ShowSyncHudMsg(id, g_SyncScoreInfo, "%s^n| Kills: %d | Eff: %0.2f%% | Death: %d |^n%s Rank: %d of %d", sAdmin, iFrags, fEff, iDeath, sName, iRank, g_iMaxStats)
}
}
GetCvarColor(cvar, &r, &g, &b)
{
static colors[16], piece[5]
get_pcvar_string(cvar, colors, 15)
strbreak(colors, piece, 4, colors, 15)
r = str_to_num(piece)
strbreak(colors, piece, 4, colors, 15)
g = str_to_num(piece)
b = str_to_num(colors)
}