#include <amxmodx>
#include <nvault>
new const Version[] = "0.4";
const DaySeconds = 86400;
enum VeteranLevels
{
Player,
Veteran,
Pro
}
enum VeteranLevelData
{
SecondsNeeded,
VeteranFlags[ 26 ],
VeteranBits
}
new VeteranInfo[ VeteranLevels ][ VeteranLevelData ] =
{
{ 0 , "" , 0 },
{ 60 , "l" , 0 },
{ 120 , "bklm" , 0 }
};
enum VeteranData
{
SteamID[ 34 ],
bool:IsAdmin,
SecondsPlayed,
VeteranLevels:VeteranLevel
}
new PlayerData[ MAX_PLAYERS + 1 ][ VeteranData ];
new g_Vault;
public plugin_init()
{
register_plugin( "Veterans" , Version , "bugsy" );
register_event( "HLTV" , "NewRound" , "a" , "1=0" , "2=0" );
register_clcmd( "say !veteran" , "VeteranSay" );
register_clcmd( "say_team !veteran" , "VeteranSay" );
register_clcmd( "say !pro" , "ProSay" );
register_clcmd( "say_team !pro" , "ProSay" );
register_clcmd( "say !skill" , "SkillSay" );
register_clcmd( "say_team !skill" , "SkillSay" );
}
public plugin_cfg()
{
nvault_prune( ( g_Vault = nvault_open( "veteran_data" ) ) , 0 , get_systime() - ( DaySeconds * 2 ) );
for ( new VeteranLevels:i = Veteran ; i < VeteranLevels ; i++ )
{
VeteranInfo[ i ][ VeteranBits ] = read_flags( VeteranInfo[ i ][ VeteranFlags ] );
}
}
public plugin_end()
{
nvault_close( g_Vault );
}
public client_authorized( id )
{
new szData[ 11 ] , iTS;
if ( !( PlayerData[ id ][ IsAdmin ] = bool:( !( get_user_flags( id ) & ADMIN_USER ) ) ) )
{
get_user_authid( id , PlayerData[ id ][ SteamID ] , charsmax( PlayerData[][ SteamID ] ) );
if ( nvault_lookup( g_Vault , PlayerData[ id ][ SteamID ] , szData , charsmax( szData ) , iTS ) )
{
PlayerData[ id ][ SecondsPlayed ] = str_to_num( szData );
SetVeteranLevel( id );
}
}
}
public client_disconnected( id )
{
new szSeconds[ 11 ];
if ( !PlayerData[ id ][ IsAdmin ] )
{
num_to_str( PlayerData[ id ][ SecondsPlayed ] + get_user_time( id ) , szSeconds , charsmax( szSeconds ) )
nvault_set( g_Vault , PlayerData[ id ][ SteamID ] , szSeconds );
PlayerData[ id ][ SecondsPlayed ] = 0;
PlayerData[ id ][ VeteranLevel ] = Player;
}
}
public VeteranSay( id )
{
show_motd( id , "veteran_motd.txt" );
}
public ProSay( id )
{
show_motd( id , "pro_motd.txt" );
}
public SkillSay( id )
{
if ( PlayerData[ id ][ IsAdmin ] )
{
client_print( id , print_chat , "* You are an admin" );
}
else
{
if ( PlayerData[ id ][ VeteranLevel ] < Pro )
{
set_dhudmessage( 235, 151, 78, 0.38, 0.01, 0, 0.1, 4.0, 0.4, 0.8 );
switch ( PlayerData[ id ][ VeteranLevel ] )
{
case Player:
{
show_dhudmessage( id , "To become veteran play %d minutes. Type !veteran" , VeteranInfo[ Veteran ][ SecondsNeeded ] / 60 );
}
case Veteran:
{
show_dhudmessage( id , "You are a Veteran. To become Pro play for %d minutes. Type !pro" , VeteranInfo[ Pro ][ SecondsNeeded ] / 60 );
}
}
}
else
{
client_print( id , print_chat , "* You are a Pro player" );
}
}
}
public NewRound()
{
new iPlayers[ 32 ] , iNum , iPlayer;
get_players( iPlayers , iNum , "ch" );
for ( new i = 0 ; i < iNum ; i++ )
{
iPlayer = iPlayers[ i ];
if ( !PlayerData[ iPlayer ][ IsAdmin ] )
{
SetVeteranLevel( iPlayer );
SkillSay( iPlayer );
}
}
}
SetVeteranLevel( id )
{
new VeteranLevels:vlLevel = Player;
if ( PlayerData[ id ][ VeteranLevel ] < Pro )
{
for ( new VeteranLevels:i = Pro ; i >= Veteran ; i-- )
{
if ( PlayerData[ id ][ SecondsPlayed ] >= VeteranInfo[ i ][ SecondsNeeded ] )
{
vlLevel = i;
remove_user_flags( id , ADMIN_USER );
set_user_flags( id , ( get_user_flags( id ) | VeteranInfo[ i ][ VeteranBits ] ) );
break;
}
}
PlayerData[ id ][ VeteranLevel ] = vlLevel;
}
}