Код за потвърждение: Избери целия код
#include <amxmodx>
#include <nvault>
#define PLUGIN "Score HUD"
#define VERSION "1.0"
#define AUTHOR "AndrewZ"
enum _:SCORE_DATA
{
DISABLE,
KILLS,
HEADSHOTS,
KNIFEKILLS,
GRENADEKILLS,
DEATHS
}
new g_user_score[ 33 ][ SCORE_DATA + 1 ]
new g_maxplayers
new g_iVault
public plugin_init()
{
register_plugin( PLUGIN, VERSION, AUTHOR )
g_maxplayers = get_maxplayers()
register_clcmd( "say /score", "cmd_score" )
register_event( "DeathMsg", "event_death", "a" )
set_task( 1.0, "rtask_show_hud", _, _, _, "b" )
g_iVault = nvault_open("ScoreHUD")
}
public cmd_score( id )
{
if( g_user_score[ id ][ DISABLE ] )
{
g_user_score[ id ][ DISABLE ] = 0
client_print( id, print_chat, "HUD Statistics informer is on" )
}
else
{
g_user_score[ id ][ DISABLE ] = 1
client_print( id, print_chat, "HUD Statistics informer is off." )
}
return PLUGIN_HANDLED
}
public clear_data( id )
{
if( !id )
{
for( new i = 1; i <= g_maxplayers; i ++ )
{
for( new data; data <= SCORE_DATA; data ++ )
g_user_score[ i ][ data ] = 0
}
}
else
{
for( new data; data <= SCORE_DATA; data ++ )
g_user_score[ id ][ data ] = 0
}
}
public plugin_end() nvault_close(g_iVault)
public client_putinserver(id) UseVault(id, 1)
public client_disconnect(id) UseVault(id, 0)
public event_death()
{
new killer = read_data(1)
new victim = read_data(2)
new headshot = read_data(3)
new weapon[ 12 ]; read_data(4, weapon, 11)
if(!is_user_connected(killer) && !is_user_connected(victim))
return
if(killer == victim)
{
g_user_score[ victim ][ DEATHS ] ++
return
}
g_user_score[ killer ][ KILLS ] ++
if( headshot )
g_user_score[ killer ][ HEADSHOTS ] ++
if( equal( weapon, "knife" ) )
g_user_score[ killer ][ KNIFEKILLS ] ++
else if( equal( weapon, "grenade" ) )
g_user_score[ killer ][ GRENADEKILLS ] ++
g_user_score[ victim ][ DEATHS ] ++
UseVault(killer, 0)
}
public rtask_show_hud()
{
for( new id = 1; id <= g_maxplayers; id ++ )
{
if( !is_user_alive( id ) || g_user_score[ id ][ DISABLE ] )
continue
new Float:kd,
Float:k = float( g_user_score[ id ][ KILLS ] ),
Float:d = float( g_user_score[ id ][ DEATHS ] )
if( k && d )
kd = k / d
else kd = 0.0
set_hudmessage(255, 255, 255, -1.0, 0.89, 0, 6.0, 1.0)
show_hudmessage
(
id, "Kills: %d | Headshots: %d | Knife kills: %d | Grenade kills: %d | Deaths: %d | К/D: %.2f",
g_user_score[ id ][ KILLS ],
g_user_score[ id ][ HEADSHOTS ],
g_user_score[ id ][ KNIFEKILLS ],
g_user_score[ id ][ GRENADEKILLS],
g_user_score[ id ][ DEATHS ],
kd
)
}
}
UseVault(id, iType)
{
new szIP[23], szData[128]
get_user_ip(id, szIP, charsmax(szIP),1)
switch(iType)
{
case 0:
{
formatex(szData,charsmax(szData),"%i|%i|%i|%i|%i",g_user_score[ id ][ KILLS ] , g_user_score[ id ][ HEADSHOTS ],g_user_score[ id ][ KNIFEKILLS ], g_user_score[ id ][ GRENADEKILLS],g_user_score[ id ][ DEATHS ])
nvault_set(g_iVault, szIP, szData)
}
case 1:
{
nvault_get(g_iVault, szIP, szData, charsmax(szData))
replace_all(szData, charsmax(szData), "|", " ")
new szKills[8], szHS[8], szKnKill[8], szGnKills[8], szDeaths[8]
parse(szData, szKills,charsmax(szKills), szHS,charsmax(szHS), szKnKill, charsmax(szKnKill), szGnKills,charsmax(szGnKills), szDeaths, charsmax(szDeaths))
g_user_score[ id ][ KILLS ] = str_to_num(szKills)
g_user_score[ id ][ HEADSHOTS ] = str_to_num(szHS)
g_user_score[ id ][ KNIFEKILLS ] = str_to_num(szKnKill)
g_user_score[ id ][ GRENADEKILLS] = str_to_num(szGnKills)
g_user_score[ id ][ DEATHS ] = str_to_num(szDeaths)
}
}
}