#include <amxmodx>
#include <cstrike>
#include <csstatsx_sql>
#include <time_perf>
#define PLUGIN "spec_hud_info"
#define VERSION "0.1"
#define AUTHOR "perf"
#define STATS_KILLS 0
#define STATS_DEATHS 1
#define STATS_HS 2
const MAX_TIME_LENGTH = 80 // '1 weeks, 6 days, 20 hours, 22 minutes and 41 seconds': 53 in English & 80 in Russian
new const g_skill_letters[][] = {
"L-",
"L",
"L+",
"M-",
"M",
"M+",
"H-",
"H",
"H+",
"P-",
"P",
"P+",
"G"
}
new Float:g_skill_opt[sizeof g_skill_letters]
new bool: g_bEnabled[MAX_PLAYERS + 1];
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_dictionary("time_perf.txt")
register_event("SpecHealth2","spec_target","bd")
}
public plugin_cfg()
{
new levelString[512],stPos,ePos,rawPoint[20],cnt
new g_pCvarSkill = get_cvar_pointer("aes_statsx_skill")
get_pcvar_string(g_pCvarSkill,levelString,charsmax(levelString))
// парсер буковок скилла
do {
ePos = strfind(levelString[stPos]," ")
formatex(rawPoint,ePos,levelString[stPos])
g_skill_opt[cnt] = str_to_float(rawPoint)
stPos += ePos + 1
cnt++
// narkoman wole suka
if(cnt > sizeof g_skill_letters - 1)
break
} while (ePos != -1)
}
public spec_target(id)
{
if(!g_bEnabled[id]) return;
new target
target = read_data(2)
if (get_user_stats_id(target) > 0)
{
// Client connected and loaded
new Stats[8], Bodyhits[8], iRank
iRank = get_user_stats_sql(target, Stats, Bodyhits)
new Float:szSkill, szSkill_id
get_user_skill(target, szSkill)
szSkill_id = aes_statsx_get_skill_id(szSkill)
new gametime = get_user_gametime(target)
new szTime[MAX_TIME_LENGTH]
get_time_length( target, gametime, timeunit_seconds, szTime, charsmax(szTime) )
new Float: kd, Float:hsp
kd = float(Stats[STATS_KILLS]) / float(Stats[STATS_DEATHS])
hsp = (100.0 * float(Stats[STATS_HS]) / float(Stats[STATS_KILLS]))
new szMessage[ 192 ]
if(!is_user_steam(target))
{
formatex( szMessage, charsmax( szMessage ), "Non Steam^nRank: %d | %s %.2f^nKD: %.2f | HSP: %.2f^nOnline: %s",
iRank, g_skill_letters[szSkill_id], szSkill, kd, hsp, szTime)
send_hudmessage(id, szMessage, Float:0.89,Float:0.75,random(255),random(255),random(255),255,Float:5.0,Float:0.05,Float:0.05,-1,2,random(255),random(255),random(255),255,Float:0.5)
}
else
{
formatex( szMessage, charsmax( szMessage ), "Steam^nRank: %d | %s %.2f^nKD: %.2f | HSP: %.2f^nOnline: %s",
iRank, g_skill_letters[szSkill_id], szSkill, kd, hsp, szTime)
send_hudmessage(id, szMessage, Float:0.89,Float:0.75,random(255),random(255),random(255),255,Float:5.0,Float:0.05,Float:0.05,-1,2,random(255),random(255),random(255),255,Float:0.5)
}
}
}
aes_statsx_get_skill_id(Float:szSkill)
{
for(new i ; i < sizeof g_skill_opt ; i++)
{
if(szSkill < g_skill_opt[i])
{
return i
}
}
return (sizeof g_skill_opt - 1)
}
stock bool:is_user_steam(id)
{
// Author Sh0oter
static dp_pointer
if(dp_pointer || (dp_pointer = get_cvar_pointer("dp_r_id_provider")))
{
server_cmd("dp_clientinfo %d", id)
server_exec()
return (get_pcvar_num(dp_pointer) == 2) ? true : false
}
return false
}
stock send_hudmessage(id,text[],Float:X,Float:Y,R,G,B,A=255,Float:holdtime=5.0,Float:fadeintime=0.1,Float:fadeouttime=0.1,channel=2,effect=0,effect_R=0,effect_G=0,effect_B=0,effect_A=255,Float:effecttime=0.0) {
if ( id )
message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, {0,0,0}, id);
else
message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(TE_TEXTMESSAGE)
write_byte(channel)
write_short(coord_to_hudmsgshort(X))
write_short(coord_to_hudmsgshort(Y))
write_byte(effect)
write_byte(R)
write_byte(G)
write_byte(B)
write_byte(A)
write_byte(effect_R)
write_byte(effect_G)
write_byte(effect_B)
write_byte(effect_A)
write_short(seconds_to_hudmsgshort(fadeintime))
write_short(seconds_to_hudmsgshort(fadeouttime))
write_short(seconds_to_hudmsgshort(holdtime))
if ( effect == 2 )
write_short(seconds_to_hudmsgshort(effecttime));
write_string(text)
message_end()
}
/* 0.0 - 255.99609375 seconds */
stock seconds_to_hudmsgshort(Float:sec) {
new output = floatround(sec * 256);
return output < 0 ? 0 : output > 65535 ? 65535 : output;
}
stock coord_to_hudmsgshort(Float:coord) {
new output = floatround(coord * 8192);
return output < -32768 ? -32768 : output > 32767 ? 32767 : output;
}
#if !defined MAX_PLAYERS
const MAX_PLAYERS = 32;
#endif
public client_connect(id)
g_bEnabled[id] = true;
public plugin_precache()
register_clcmd("say /specstat", "ToggleStats");
public ToggleStats(id) {
g_bEnabled[id] = !g_bEnabled[id];
}