Сompiler Плагин Достижений

elf01

Пользователь
Регистрация
24 Мар 2018
Сообщения
153
Симпатии
7
Пол
Мужской
#1
Amx Mod X
AMXX 1.8.3
Ошибка
C++:
achievements.sma<73>:error 020: invalid symbol name""
Исходник
// Should the plugin save player data in SQL database?
// To save player data in a vault, change #define USING_SQL to //#define USING_SQL
// To save player data in SQL, change //#define USING_SQL" to #define USING_SQL
// If you comment //#define USING_REGEX its a little bit more non-steam friendly

//#define USING_SQL
//#define USING_REGEX

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
#include <nvault>
#include <csx>
#include <fun>
#include <xs>

//#if defined USING_REGEX
#include <regex>
//#endif

#if defined USING_SQL
#include <sqlx>

new Handle:g_sql_tuple
#else
#include <nvault>

new g_iVault
#endif

#if defined USING_SQL
new g_loaded_data[ 33 ]
#endif

#define VERSION "2.3"

#define XO_WEAPON 4
#define XO_PLAYER 5
#define m_pPlayer 41
#define m_flTimeWeaponIdle 48
#define m_iClientClip 52
#define m_fInReload 54
#define m_fInSpecialReload 55
#define ALPHA_FULLBLINDED 255
#define m_pActiveItem 373
#define m_flFlashedUntil 514
#define m_flFlashedAt 515
#define m_flFlashHoldTime 516
#define m_flFlashDuration 517
#define m_iFlashAlpha 518


#define INTERVAL 60

new g_iMaxPlayers
#define FIRST_PLAYER_ID 1
#define IsPlayer(%1) ( FIRST_PLAYER_ID <= %1 <= g_iMaxPlayers )

#define NADES_BITSUM (1 << CSW_HEGRENADE) | (1 << CSW_FLASHBANG) | (1 << CSW_SMOKEGRENADE)
#define NORELOAD_BITSUM NADES_BITSUM | (1 << CSW_KNIFE) | (1 << CSW_C4) | (1 << CSW_M3) | (1 << CSW_XM1014)
#define fm_get_c4() engfunc( EngFunc_FindEntityByString, -1, "classname", "weapon_c4" )

new g_C4Ent
new Float:g_fC4Origin[ 3 ]

#define GetBit(%1,%2) ( %1 & 1 << ( %2 & 31 ) )
#define SetBit(%1,%2) ( %1 |= ( 1 << ( %2 & 31 ) ) )
#define DelBit(%1,%2) ( %1 &= ~( 1 << ( %2 & 31 ) ) )

const MAX_PLAYERS = 32
const MAX_WEAPONS = CSW_P90
const RIFFLES_BITSUM = ((1 << CSW_AUG) | (1 << CSW_GALIL) | (1 << CSW_FAMAS) | (1 << CSW_M249) | (1 << CSW_M4A1) | (1 << CSW_SG552) | (1 << CSW_AK47))
const SNIPERS_BITSUM = ((1 << CSW_SCOUT) | (1 << CSW_SG550) | (1 << CSW_AWP) | (1 << CSW_G3SG1))
const THROUGH_WALL_WEAPONS = ((1 << CSW_DEAGLE) | RIFFLES_BITSUM | SNIPERS_BITSUM)

new g_iBombTime, g_iPlanter,
g_iGetBombPlanted, g_iRounds,
g_fwid

new const g_szAchievementSound[] = "achieve.wav"
new const g_szAchievementTag[] = "[Achievement]"
new g_iMsgSayText

new const Float:vecNullOrigin[ 3 ]

new Float:flDistance[ MAX_PLAYERS + 1 ],
Float:vecOldOrigin[ MAX_PLAYERS + 1 ][ 3 ],
Float:g_iFeet = 35.0

new g_iRoundSparys[ MAX_PLAYERS + 1 ], g_iKills[ MAX_PLAYERS + 1 ],
g_iShotKills[ MAX_PLAYERS + 1 ], g_iGrenadeKills[ MAX_PLAYERS + 1 ],
g_iGetTempid[ MAX_PLAYERS + 1 ]

new StandAlone, OneHpHero,
is_VictimInAir, iKillerHasNotMoved,
iKillerShot, is_Alive,
g_iDeathMessages, is_Connected,
is_NotValidPlayer

new bool:is_DefusingWithKit, bool:g_iGetBombDown,
bool:g_iBombPlant

//#if defined USING_REGEX
new Regex:g_SteamID_pattern
new g_regex_return
//#endif

enum _:g_iAchCount
{
CONNECTIONS,
HEAD_SHOTS,
DISTANCE_KILLED,
DISTANCE_WALKED,
BOMB,
PLANT_BOMB,
PLANT_BOMB_COUNT,
DEFUSED_BOMB,
TOTAL_KILLS,
PISTOL_MASTER,
RIFLE_MASTER,
SHOTGUN_MASTER,
SPRAY_N_PRAY,
MASTER_AT_ARMS,
PLAY_AROUND,
STAND_ALONE,
ONE_HP_HERO,
BAD_FRIEND,
URBAN_DESIGNER,
GRAFFITI,
AMMO_CONSERVATION,
FLY_AWAY,
FLY_KILLER,
RELOADER,
CAMP_FIRE,
HAT_TRICK,
COWBOY_DIPLOMACY,
TOTAL_DAMAGE,
WALL_HACKER,

COMPLETED_ACHIEVEMENTS
}

new const g_iAchsMotd[g_iAchCount][] =
{
"Ultimate Server Lover",
"Boom Head-Shot",
"I've Got The Power",
"Long Run",
"OMFG that was close",
"Short Fuse",
"Boomala Boomala",
"Nothing Can Blow Up",
"God of War",
"Pistol Master",
"Rifle Master",
"Shotgun Master",
"Spray and Pray",
"Master At Arms",
"Play Around",
"Stand Alone",
"1 Hp Hero",
"Bad Friend",
"Urban Designer",
"Graffiti Is My Second Name",
"Ammo Conservation",
"Fly Away",
"Fly Killer",
"Reloader",
"Camp Fire",
"Hat Trick",
"Cowboy Diplomacy",
"You've Made Your Points",
"Wall HACKER",
"Completed Achievements Percentage"
}

new const g_iAchsSecondary[][] =
{
"I'll Be Back",
"I Like This Server",
"Half Way There",
"Baby Foot Steps",
"I'm Half Way There",
"C4 Defuser",
"That Was Easy",
"Like a Game",
"Master of C4",
"Short Range Kill",
"Nice Aim",
"Long Range Kill",
"Aim-Bot Time",
"Killer Master"
}

new const g_iAchsDesciption[g_iAchCount][] =
{
"Connect to the server 500 times!",
"Get a total of 300 Headshots!",
"Kill the player from a distance!",
"Run around the map!",
"Defuse the bomb right before it explodes!",
"Plant the bomb within 25 seconds of round start!",
"Plant the bomb of a total of 100 times!",
"Get a total of 400 bomb defuses!",
"Get a total of 1000 kills!",
"Unlock all achievements for pistols!",
"Unlock all achievements for rifles!",
"Unlock all achievements for Shotguns!",
"Get a kill while being 100% flashed!",
"Unlock all achievements for weapons!",
"Spend 1 hour playing in the server!",
"Die 15 times as the last guy on the team!",
"Kill a enemy while having 1 HP!",
"Kill 5 teammates!",
"Spray 50 decals!",
"Spray 3 times in one round!",
"Kill two players with a single bullet!",
"Kill an enemy while he/she is in the air!",
"Kill an enemy while You are in the air!",
"Reload your weapon 1000 times!",
"Kill 3 enemies in a row, all within the same area!",
"Kill 3 enemies with one HeGrenade!",
"Rescue 50 hostages!",
"Inflect 50000 damage on your enemies!",
"Kill an enemy though the wall 10 times!",
"Completed Percentage"
}

const MAX_CONNECTION = 500 // Connections
const MAX_HEAD_SHOTS = 300 // Headshots
const MAX_DISTANCE_KILLED = 4 // distance killed
const MAX_DISTANCE_WALKED = 3 // distance walk
const MAX_BOMB = 1 // bomb
const MAX_PLANT_BOMB = 1 // Plant bomb
const MAX_PLANT_BOMB_COUNT = 100 // plant bomb count
const MAX_DEFUSED_BOMB = 40 // Defused Bomb
const MAX_TOTAL_KILLS = 1000 // total kills
const MAX_PISTOL_MASTER = 6 // Pistol master
const MAX_RIFLE_MASTER = 10 // rifle Master
const MAX_SHOTGUN_MASTER = 2 // shotgun master
const MAX_SPRAY_N_PRAY = 1 // spray and pray
const MAX_MASTER_AT_ARMS = 25 // Master of Arms
const MAX_PLAY_AROUND = 60 // Play Around
const MAX_STAND_ALONE = 15 // Stand Alone
const MAX_ONE_HP_HERO = 1 // 1 Hp Hero
const MAX_BAD_FRIEND = 5 // Bad Friend
const MAX_URBAN_DESIGNER = 50 // Urban Designer
const MAX_GRAFFITI = 1 // Graffiti Is My Second Name
const MAX_AMMO_CONSERVATION = 1 // Ammo Conservation
const MAX_FLY_AWAY = 1 // Fly Away
const MAX_FLY_KILLER = 1 // Fly Killer
const MAX_RELOADER = 1000 // Reloader
const MAX_CAMP_FIRE = 1 // Camp Fire
const MAX_HAT_TRICK = 1 // HatTrick
const MAX_COWBOY_DIPLOMACY = 50 // Cowboy Diplomacy
const MAX_TOTAL_DAMAGE = 50000 // Total Damage 50000 Damage points
const MAX_WALL_HACKER = 10 // Wall hacker
const MAX_COMPLETEDPERCENTAGE = 69 // Completed Percentage

new const g_iAchsMaxPoints[g_iAchCount] =
{
500, // Connections
300, // Headshots
4, // distance killed
3, // distance walk
1, // bomb
1, // Plant bomb
100, // plant bomb count
40, // Defused Bomb
1000, // total kills
6, // Pistol master
10, // rifle Master
2, // shotgun master
1, // spray and pray
25, // Master of Arms
60, // Play Around
15, // Stand Alone
1, // 1 Hp Hero
5, // Bad Friend
50, // Urban Designer
1, // Graffiti Is My Second Name
1, // Ammo Conservation
1, // Fly way
1, // Fly Killer
1000, // Reloader
1, // Camp Fire
1, // HatTrick
50, // Cowboy Diplomacy
50000, // Total Damage 50000 Damage points
10, // Wall hacker
69 // Completed Percentage
}

enum _:MAX_TYPES
{
TYPE_NONE,
TYPE_RELATION,
TYPE_PLAYER,
TYPE_HEALTH,
}

enum
{
LOOK_FRIEND = 1,
LOOK_ENEMY,
LOOK_HOSTAGE,
}

enum _:MAX_REPLACES
{
RE_ACHIEVEMENT,
RE_HP,
RE_NAME,
}

new const Replaces[ MAX_REPLACES ][] =
{
"%Achivement%",
"%hp%",
"%name%"
}

new g_iAuthID[ MAX_PLAYERS + 1 ][ 35 ]

//Cvars
new g_pCvar_Enabled, g_pCvarC4Timer,
g_pCvar_ShowInfo, g_pCvar_DeathMessage,
g_pCvar_FlashMessage, g_pCvar_BombMessage,
g_pCvar_DeadPlayerNames, g_pCvar_DeadPlayerMessage,
g_pCvar_StatustextMessageFriend, g_pCvar_StatustextMessageEnemy,
g_pCvar_PlaySound, g_pCvar_Reward, g_pCvar_Message

new status_value[ MAX_TYPES ]
new gStatusText

new const g_szWeaponNames[][] =
{
"p228",
"scout",
"hegrenade",
"xm1014",
"c4",
"mac10",
"aug",
"smokegrenade",
"elite",
"fiveseven",
"ump45",
"sg550",
"galil",
"famas",
"usp",
"glock18",
"awp",
"mp5navy",
"m249",
"m3",
"m4a1",
"tmp",
"g3sg1",
"flashbang",
"deagle",
"sg552",
"ak47",
"knife",
"p90"
}

#define WEAPON_SIZE sizeof(g_szWeaponNames)

new const g_iWeaponIDs[WEAPON_SIZE] =
{
CSW_P228,
CSW_SCOUT,
CSW_HEGRENADE,
CSW_XM1014,
CSW_C4,
CSW_MAC10,
CSW_AUG,
CSW_SMOKEGRENADE,
CSW_ELITE,
CSW_FIVESEVEN,
CSW_UMP45,
CSW_SG550,
CSW_GALIL,
CSW_FAMAS,
CSW_USP,
CSW_GLOCK18,
CSW_AWP,
CSW_MP5NAVY,
CSW_M249,
CSW_M3,
CSW_M4A1,
CSW_TMP,
CSW_G3SG1,
CSW_FLASHBANG,
CSW_DEAGLE,
CSW_SG552,
CSW_AK47,
CSW_KNIFE,
CSW_P90
}

enum
{
P228,
SCOUT,
HEGRENADE,
XM1014,
C4,
MAC10,
AUG,
SMOKEGRENADE,
ELITE,
FIVESEVEN,
UMP45,
SG550,
GALIL,
FAMAS,
USP,
GLOCK18,
AWP,
MP5NAVY,
M249,
M3,
M4A1,
TMP,
G3SG1,
FLASHBANG,
DEAGLE,
SG552,
AK47,
KNIFE,
P90
}

new const g_iAchsWeaponMaxKills[] =
{
100, //"p228",
100, //"scout",
5, //"hegrenade",
20, //"xm1014",
5, //"c4",
25, //"mac10",
30, //"aug",
40, //"smokegrenade",
50, //"elite",
50, //"fiveseven",
75, //"ump45",
75, //"sg550",
250, //"galil",
250, //"famas",
80, //"usp",
80, //"glock18",
275, //"awp",
100, //"mp5navy",
50, //"m249",
50, //"m3",
275, //"m4a1",
100, //"tmp",
75, //"g3sg1",
75, //"flashbang",
125, //"deagle",
100, //"sg552",
275, //"ak47",
20, //"knife",
30 //"p90"
}

const MAX_P228 = 100 //"p228",
const MAX_SCOUT = 100 //"scout",
const MAX_HEGRENADE = 5 //"hegrenade",
const MAX_XM1014 = 20 //"xm1014",
const MAX_C4 = 5 //"c4",
const MAX_MAC10 = 25 //"mac10",
const MAX_AUG = 30 //"aug",
const MAX_SMOKEGRENADE = 40 //"smokegrenade",
const MAX_ELITE = 50 //"elite",
const MAX_FIVESEVEN = 50 //"fiveseven",
const MAX_UMP45 = 75 //"ump45",
const MAX_SG550 = 75 //"sg550",
const MAX_GALIL = 250 //"galil",
const MAX_FAMAS = 250 //"famas",
const MAX_USP = 80 //"usp",
const MAX_GLOCK18 = 80 //"glock18",
const MAX_AWP = 275 //"awp",
const MAX_MP5NAVY = 100 //"mp5navy",
const MAX_M249 = 50 //"m249",
const MAX_M3 = 50 //"m3",
const MAX_M4A1 = 275 //"m4a1",
const MAX_TMP = 100 //"tmp",
const MAX_G3SG1 = 75 //"g3sg1",
const MAX_FLASHBANG = 75 //"flashbang",
const MAX_DEAGLE = 125 //"deagle",
const MAX_SG552 = 100 //"sg552",
const MAX_AK47 = 275 //"ak47",
const MAX_KNIFE = 20 //"knife",
const MAX_P90 = 30 //"p90"

new const g_szWeaponNames2[WEAPON_SIZE][] =
{
"P228",
"Scout",
"He-Grenade",
"XM1014",
"C4",
"Mac10",
"Aug",
"Smoke-Grenade",
"Elite",
"Fiveseven",
"Ump45",
"SG550",
"Galil",
"Famas",
"USP",
"Glock",
"AWP",
"MP5",
"M249",
"M3",
"M4A1",
"TMP",
"G3SG1",
"FlashBang",
"Deagle",
"SG552",
"AK47",
"Knife",
"P90"
}

new const g_iAchsWeap[WEAPON_SIZE][] =
{
"228 Compact Expert",
"Schmidt Scout Expert",
"HE Grenade Expert",
"Leone YG1265 Auto Shotgun Expert",
"C4 Killer",
"Ingram Mac-10 Expert",
"Bullpup Expert",
"It's A Bit Smokey In Here!",
".40 Dual Elites Expert",
"ES Five-Seven Expert",
"KM UMP45 Expert",
"D3/AU-1 Expert",
"IDF Defender Expert",
"Clarion 5.56 Expert",
"KM Tactical .45 Expert",
".9Ч19 Sidearm Expert",
"Magnum Sniper Rifle Expert",
"KM Sub-Machine Gun Expert",
"M249 Expert",
"Leone 12 Gauge Super Expert",
"Maverick M4A1 Carbine Expert",
"Schmidt Machine Pistol Expert",
"Krieg 550 Commando Expert",
"Can You See?",
"Night Hawk .50c Expert",
"Krieg 552 Expert",
"CV-47 Expert",
"Knife Expert",
"ES C90 Expert"
}

new const g_iGunEvents[][] = {
"events/awp.sc",
"events/g3sg1.sc",
"events/ak47.sc",
"events/scout.sc",
"events/m249.sc",
"events/m4a1.sc",
"events/sg552.sc",
"events/aug.sc",
"events/sg550.sc",
"events/m3.sc",
"events/xm1014.sc",
"events/usp.sc",
"events/mac10.sc",
"events/ump45.sc",
"events/fiveseven.sc",
"events/p90.sc",
"events/deagle.sc",
"events/p228.sc",
"events/glock18.sc",
"events/mp5n.sc",
"events/tmp.sc",
"events/elite_left.sc",
"events/elite_right.sc",
"events/galil.sc",
"events/famas.sc"
}

new g_iPlayersKills[ MAX_PLAYERS+1 ][ MAX_WEAPONS+1 ]
new g_iAchLevel[ MAX_PLAYERS+1 ][ g_iAchCount ]
new g_iTimerEntity, g_iJoinTime[ MAX_PLAYERS+1 ]

new Trie:g_tWeaponNameToID
new iWeaponID, g_iGunEvent_IDsBitsum

public plugin_init() {

#if defined USING_SQL
register_plugin( "Achievements (SQL)", VERSION, "Pastout!" )
#else
register_plugin( "Achievements", VERSION, "Pastout!" )
#endif

g_pCvar_Enabled = register_cvar("ach_enable", "1")// 1 = on || 0 = off
if ( !get_pcvar_num( g_pCvar_Enabled ) )
return;

g_pCvarC4Timer = get_cvar_pointer( "mp_c4timer" )
g_pCvar_ShowInfo = register_cvar( "ach_showinfo", "0" )
g_pCvar_DeathMessage = register_cvar( "ach_deathmessage", "0" )
g_pCvar_FlashMessage = register_cvar( "ach_flashmessage", "0" )
g_pCvar_BombMessage = register_cvar( "ach_bombmessage", "0" )
g_pCvar_PlaySound = register_cvar( "ach_playsound", "1" )
g_pCvar_Reward = register_cvar( "ach_reward", "300" )
g_pCvar_Message = register_cvar( "ach_message", "2" )
g_pCvar_DeadPlayerNames = register_cvar( "dead_player_names", "1" )
g_pCvar_DeadPlayerMessage = register_cvar( "dead_player_message", "%name% (%hp%) %steamid%" )
g_pCvar_StatustextMessageFriend = register_cvar( "statustext_message_friend", "Friend : %name% Health : %hp%%% Achievement Completion : %Achivement%%%" )
g_pCvar_StatustextMessageEnemy = register_cvar( "statustext_message_enemy", "Enemy : %name% Achievement Completion : %Achivement%%%" )

new command[] = "CmdMainMenu"
register_clcmd( "say /achievement", command )
register_clcmd( "say /achievements", command )
register_clcmd( "say /ach", command )
//register_clcmd( "say /help", "Ach_HelpMenu" )
//register_clcmd( "say /deathmessage", "CmdDeathMessage" )

register_clcmd( "Enter_Value", "CmdEnterValue" )

register_event( "DeathMsg", "Event_PlayerKilled", "a" )
register_event( "HLTV", "Event_NewRound", "a", "1=0", "2=0" )
register_event( "StatusIcon", "Event_GotBomb", "be", "1=1", "1=2", "2=c4" )
register_event( "23", "Event_Spray", "a", "1=112" )
register_event( "CurWeapon", "Event_CurWeapon", "be", "1=1", "3>0" )
register_event( "StatusValue", "Event_StatusValue", "b" )

register_logevent( "Event_PlayerAction", 3, "1=triggered" )

new entity[] = "hud_entity"
g_iTimerEntity = create_entity( "info_target" )
entity_set_string( g_iTimerEntity, EV_SZ_classname, entity )
register_think( entity, "FwdHUDThink" )
entity_set_float( g_iTimerEntity, EV_FL_nextthink, get_gametime() + 1.0 )

g_iMaxPlayers = get_maxplayers( )
g_tWeaponNameToID = TrieCreate( )
g_iMsgSayText = get_user_msgid( "SayText" )
gStatusText = get_user_msgid( "StatusText" )

for( new i = 0; i < WEAPON_SIZE; i++ )
{
TrieSetCell( g_tWeaponNameToID, g_szWeaponNames, g_iWeaponIDs )
}

new g_szHamShotgunReload[] = "FwdHamShotgunReload"
new g_szPlayer[] = "player"
RegisterHam( Ham_Weapon_Reload, "weapon_m3", g_szHamShotgunReload, .Post = true )
RegisterHam( Ham_Weapon_Reload, "weapon_xm1014", g_szHamShotgunReload, .Post = true )
RegisterHam( Ham_TraceAttack, g_szPlayer, "Ham_CBasePlayer_TraceAttack", .Post = false )
RegisterHam( Ham_Spawn, g_szPlayer, "Ham_CBasePlayer_Spawn", .Post = true )
RegisterHam( Ham_Killed, g_szPlayer, "Ham_CBasePlayer_Killed", .Post = false )
RegisterHam( Ham_TakeDamage, g_szPlayer, "Ham_CBasePlayer_TakeDamage", .Post = true )

unregister_forward( FM_PrecacheEvent, g_fwid, 1 )
register_forward( FM_PlaybackEvent, "FwdPlaybackEvent" )
register_forward( FM_CmdStart, "FwdCmdStart" )

#if !defined USING_SQL
g_iVault = nvault_open( "Achievements" )

if(g_iVault == INVALID_HANDLE)
set_fail_state( "Error opening nVault" )

#endif

//#if defined USING_REGEX
new err[ 2 ]
g_SteamID_pattern = regex_compile( "^^STEAM_0:(0|1):\d+$", g_regex_return, err, sizeof( err ) - 1 )
//#endif

}

public plugin_unpause()
{
is_Connected = 0;
is_Alive = 0;
static iPlayers[ 32 ], iNum, iPlayer
get_players( iPlayers, iNum, "ch" )

for( new i = 0; i < iNum; i++ )
{
iPlayer = iPlayers[ i ]
SetBit( is_Connected, iPlayer )
if( is_user_alive( iPlayer ) )
{
SetBit( is_Alive, iPlayer )
}
}
}

public Event_StatusValue( id )
{
new num = read_data( 1 )

if( num <= 0 || num >= MAX_TYPES )
return

new update = status_value[ num ] = read_data( 2 )

switch( num )
{
case TYPE_RELATION:
{
if( !update && GetBit( is_Alive, id ) )
{
message_begin( MSG_ONE_UNRELIABLE, gStatusText, _, id )
write_byte( 0 )
write_string( "" )
message_end()
}
}
case TYPE_PLAYER:
{
//if( GetBit( is_Alive, id ) )
if( GetBit( is_Alive, id ) && !GetBit( is_NotValidPlayer, id ))
{
new message[ 192 ]

switch( status_value[ TYPE_RELATION ] )
{
case LOOK_FRIEND:
{
get_pcvar_string( g_pCvar_StatustextMessageFriend, message, charsmax( message ) )
}
case LOOK_ENEMY:
{
get_pcvar_string( g_pCvar_StatustextMessageEnemy, message, charsmax( message ) )
}
case LOOK_HOSTAGE:
{
return
}
}

EditMessage( message, update, true, get_user_health( update ) )

message_begin( MSG_ONE_UNRELIABLE, gStatusText, _, id )
write_byte( 0 )
write_string( message )
message_end()
}
}
case TYPE_HEALTH:
{
if( !status_value[ TYPE_RELATION ] )
return;

if( !FreeLook( id ) )
return;

switch( status_value[ TYPE_RELATION ] )
{
case LOOK_FRIEND, LOOK_ENEMY:
{
new message[ 192 ]
get_pcvar_string( g_pCvar_DeadPlayerMessage, message, charsmax( message ) )

EditMessage( message, status_value[ TYPE_PLAYER ], false, update )
}
case LOOK_HOSTAGE:
{
new message[ 192 ]
get_pcvar_string( g_pCvar_DeadPlayerMessage, message, charsmax(message) )

EditMessage( message, 0, false, update )
}
}
}
}
}

FreeLook( id )
{
if( GetBit( is_Connected, id ) && !GetBit( is_Alive, id ) )
return false;

if( pev(id, pev_iuser2) && get_pcvar_num( g_pCvar_DeadPlayerNames ) <= 1 )
return false;

return true;
}

EditMessage( message[ 192 ], player, bool:status_text, hp )
{
new temp[ 35 ]

if( GetBit( is_Alive, player ) )
{
for( new i; i < MAX_REPLACES; i++ )
{
switch( i )
{
case RE_ACHIEVEMENT:
{
new Float:g_Number = ( g_iAchLevel[ player ][ COMPLETED_ACHIEVEMENTS ]*1.0 )
new Float:g_Number2 = ( g_iAchsMaxPoints[ COMPLETED_ACHIEVEMENTS ]*1.0 )
new Float:g_Number3 = g_Number/g_Number2*100
formatex( temp, charsmax( temp ), "%.f", g_Number3 )
}

case RE_HP:
{
num_to_str( hp, temp, charsmax( temp ) )
}

case RE_NAME:
{
if( status_text )
copy( temp, charsmax( temp ), "%p2" )
else
get_user_name( player, temp, charsmax( temp ) )
}

default:
{
copy( temp, charsmax(temp), "" )
}
}

replace( message, charsmax( message ), Replaces[ i ], temp )
}
}
else
{
for( new i; i < MAX_REPLACES; i++ )
{
switch( i )
{
case RE_HP:
{
num_to_str( hp, temp, charsmax( temp ) )
replace( message, charsmax( message ), Replaces[ i ], temp )
}

case RE_NAME:
{
replace( message, charsmax( message ), Replaces[ i ], "Hostage" )
}

default:
{
replace( message, charsmax( message ), Replaces[ i ], "" )
}
}
}
}

trim( message )
}

public Ham_CBasePlayer_Killed( iVictim, iAttacker )
{
if( IsPlayer( iAttacker )
&& IsPlayer( iVictim )
&& GetBit( is_Connected, iVictim )
&& GetBit( is_Connected, iAttacker )
&& GetBit( is_Alive, iAttacker ) )
{
#if defined USING_REGEX
if( !IsUserAuthorized( iAttacker ) || !IsUserAuthorized( iVictim ) )
{
return HAM_HANDLED
}
#endif

new Float:eek:rigin[ 3 ]
entity_get_vector( iVictim, EV_VEC_origin, origin )

if( ( 1 << get_user_weapon( iAttacker ) ) & THROUGH_WALL_WEAPONS )
{
if( !fm_is_ent_visible_maxdistance( iAttacker, iVictim,.maxdistance = 3500.0) && is_in_viewcone( iAttacker, origin ) )
{
g_iAchLevel[ iAttacker ][ WALL_HACKER ]++
switch( g_iAchLevel[ iAttacker ][ WALL_HACKER ] )
{
case MAX_WALL_HACKER:
{
Achievement( iAttacker, WALL_HACKER, -1 )
}
}
//Print( 0, "You have been walled!" )
}
}
}

return HAM_HANDLED
}

bool:fm_is_ent_visible_maxdistance( const index, const entity, ignoremonsters = 0, Float:maxdistance )
{
new Float:start[ 3 ], Float:dest[ 3 ]
pev( index, pev_origin, start )
pev( index, pev_view_ofs, dest )
xs_vec_add( start, dest, start )
pev( entity, pev_origin, dest )

if( vector_distance( start,dest ) <= maxdistance )
{
engfunc( EngFunc_TraceLine, start, dest, ignoremonsters, index, 0 )
new Float:fraction;
get_tr2( 0, TR_flFraction, fraction )

if ( fraction == 1.0 || get_tr2( 0, TR_pHit ) == entity )
return true
}
return false
}

public client_damage( iAttacker, iVictim, gDamage, iWeapon, iHitplace, TA )
{
#if defined USING_REGEX
if( !IsUserAuthorized( iAttacker ) || !IsUserAuthorized( iVictim ) )
{
return PLUGIN_HANDLED
}
#endif
if( IsPlayer( iAttacker ) && IsPlayer( iVictim ) )
{
new iPreviousLevel = g_iAchLevel[ iAttacker ][ TOTAL_DAMAGE ] / g_iAchsMaxPoints[ TOTAL_DAMAGE ]
new iNewLevel = ( g_iAchLevel[ iAttacker ][ TOTAL_DAMAGE ] += gDamage ) / g_iAchsMaxPoints[ TOTAL_DAMAGE ]
if( iNewLevel > iPreviousLevel )
{
Achievement( iAttacker, TOTAL_DAMAGE, -1 )
}
}

#if defined USING_REGEX
return PLUGIN_HANDLED
#endif
}

public Ham_CBasePlayer_TakeDamage(iVictim, inflictor, iAttacker, Float:fDamage, bitDamage)
{
if ( !inflictor )
return HAM_IGNORED

new Float:fOrigin[ 3 ]
new iC4 = fm_get_c4()
new szClass[ 14 ]

pev( iVictim , pev_origin , fOrigin )
pev( inflictor , pev_classname , szClass , 13 )

if ( ( bitDamage & DMG_BLAST )
&& ( get_distance_f( fOrigin , g_fC4Origin ) <= 1700.0 )
&& ( !iC4 && g_C4Ent
&& ( equal( szClass, "env_explosion" ) || equal( szClass, "grenade" ) ) ) )
{
if( GetBit( is_Connected, g_iPlanter )
&& GetBit( is_Connected, iVictim )
&& get_user_health( iVictim ) <= 0 )
{
message_begin( MSG_BROADCAST, 83, { 0,0,0 }, 0 )
write_byte( g_iPlanter )
write_byte( iVictim )
write_byte( 0 )
write_string( "world" )
message_end()

g_iPlayersKills[ g_iPlanter ][ CSW_C4 ]++

if( g_iPlayersKills[ g_iPlanter ][ CSW_C4 ] == 30 )
{
Achievement( g_iPlanter, -1, C4 )
}

if( g_iAchLevel[ g_iPlanter ][ BAD_FRIEND ] > MAX_BAD_FRIEND && cs_get_user_team( g_iPlanter ) == cs_get_user_team( iVictim ) )
{
g_iAchLevel[ g_iPlanter ][ BAD_FRIEND ]++
}
}
}

return HAM_IGNORED;
}

public Event_PlayerAction( )
{
new szArg[ 64 ], szAction[ 64 ], szName[ 64 ]
new iUserId, id

read_logargv( 0, szArg, 64 )
read_logargv( 2, szAction, 64 )
parse_loguser( szArg, szName, 64, iUserId )
id = find_player( "k", iUserId )

if( id == 0 )
{
return
}
#if defined USING_REGEX
if( !IsUserAuthorized( id ) )
{
return
}
#endif
if( equal( szAction, "Rescued_A_Hostage" ) )
{
g_iAchLevel[ id ][ COWBOY_DIPLOMACY ]++
switch( g_iAchLevel[ id ][ COWBOY_DIPLOMACY ] )
{
case MAX_COWBOY_DIPLOMACY:
{
Achievement( id, COWBOY_DIPLOMACY, -1 )
}
}
Print( 0, "^4[AMXX]^3 %s^1 has^4 rescued^1 a^3 Hostage^1.", szName )// Hostage rescued
}

if( get_pcvar_num( g_pCvar_BombMessage ) == 1 )
{
if( equal( szAction, "Begin_Bomb_Defuse_With_Kit" ) )
{
is_DefusingWithKit = true
}
}
#if defined USING_REGEX
return
#endif
}

public Event_CurWeapon( iPlayer )
{
#if defined USING_REGEX
if( !IsUserAuthorized( iPlayer ) )
{
return
}
#endif

new iId = read_data( 2 )
if( ~NORELOAD_BITSUM & 1 << iId )
{
new iWeapon = get_pdata_cbase( iPlayer, m_pActiveItem, XO_PLAYER )
new iClientClip = get_pdata_int( iWeapon, m_iClientClip, XO_WEAPON )
new iClip = read_data( 3 )
if( iClip > iClientClip )
{
// Player <iPlayer> has reloaded weapon <m_pActiveItem>, weapontype iId
//new iPlayer = get_pdata_cbase( iWeapon, m_pPlayer, 4 )

//if( get_pdata_int( iWeapon, m_fInReload, 4 ) ) {
g_iAchLevel[ iPlayer ][ RELOADER ]++
switch( g_iAchLevel[ iPlayer ][ RELOADER ] )
{
case MAX_RELOADER:
{
Achievement( iPlayer, RELOADER, -1 )
}
}
// }
}
}

#if defined USING_REGEX
return
#endif
}

public FwdHamShotgunReload( const iWeapon )
{
if( get_pdata_int( iWeapon, m_fInSpecialReload, 4 ) != 1 )
return
new Float:flTimeWeaponIdle = get_pdata_float( iWeapon, m_flTimeWeaponIdle, 4 )

if( flTimeWeaponIdle != 0.55 )
return

new iPlayer = get_pdata_cbase( iWeapon, m_pPlayer, 4 )

#if defined USING_REGEX
if( !IsUserAuthorized( iPlayer ) )
{
return
}
#endif

g_iAchLevel[ iPlayer ][ RELOADER ]++
switch( g_iAchLevel[ iPlayer ][ RELOADER ] )
{
case MAX_RELOADER:
{
Achievement( iPlayer, RELOADER, -1 )
}
}
#if defined USING_REGEX
return
#endif
}

public FwdHUDThink( iEntity )
{
if ( iEntity != g_iTimerEntity )
return

static iPlayers[ 32 ], iNum, iPlayer
get_players( iPlayers, iNum, "ch" )

for( new i = 0; i < iNum; i++ )
{
iPlayer = iPlayers[ i ]
if(g_iAchLevel[ iPlayer ][ PLAY_AROUND ] < MAX_PLAY_AROUND )
{
if ( ( get_systime() - g_iJoinTime[ iPlayer ] ) >= INTERVAL )
{
#if defined USING_REGEX
if( !IsUserAuthorized( iPlayer ) )
{
return
}
#endif

g_iJoinTime[ iPlayer ] = get_systime()
g_iAchLevel[ iPlayer ][ PLAY_AROUND ]++
switch( g_iAchLevel[ iPlayer ][ PLAY_AROUND ] )
{
case MAX_PLAY_AROUND:
{
Achievement( iPlayer, PLAY_AROUND, -1 )
}
}
#if defined USING_REGEX
return
#endif
}
}
}

entity_set_float( g_iTimerEntity, EV_FL_nextthink, get_gametime() + 1.0 )
}

public CmdDeathMessage( id )
{
if( get_pcvar_num( g_pCvar_DeathMessage ) != 1 )
{

Print( id, "^4[AMXX]^1 Sorry the^4 death message^1 has been^4 disable^1 for^3 everyone." )
return PLUGIN_HANDLED
}
if( GetBit( g_iDeathMessages, id ) )
{
SetBit( g_iDeathMessages, id )
Print( id, "^4[AMXX]^1 You have^4 Enable^3 death messages^1." )
}
else
{
if( GetBit( g_iDeathMessages, id ) )
{
DelBit( g_iDeathMessages, id )
Print( id, "^4[AMXX]^1 You have^4 Disable^3 death messages^1." )
}
}
return PLUGIN_HANDLED
}

public plugin_precache()
{
g_fwid = register_forward( FM_PrecacheEvent, "FwdPrecacheEvent", 1 )
precache_sound( g_szAchievementSound )

#if defined USING_SQL
g_sql_tuple = SQL_MakeStdTuple()

SQL_ThreadQuery(g_sql_tuple, "QueryCreateTable", "CREATE TABLE IF NOT EXISTS `Achievement` ( `name` VARCHAR(32) NOT NULL, `authid` VARCHAR(35) NOT NULL, `data` VARCHAR(256) NOT NULL );" )
#endif
}

public FwdPrecacheEvent( type, const name[] )
{
for( new i = 0; i < sizeof g_iGunEvents; ++i ) {
if( equal( g_iGunEvents[ i ], name ) ) {
g_iGunEvent_IDsBitsum |= ( 1 << get_orig_retval() )
return FMRES_HANDLED
}
}
return FMRES_IGNORED
}

public FwdPlaybackEvent( flags, id, eventid )
{
if( !( g_iGunEvent_IDsBitsum & ( 1 << eventid ) ) || !IsPlayer( id )/*(1 <= id <= g_iMaxPlayers )*/ )
return FMRES_IGNORED;

DelBit( iKillerShot, id );
g_iShotKills[ id ] = 0;

return FMRES_HANDLED;
}

public Ham_CBasePlayer_TraceAttack( this, iAttacker, Float:damage, Float:direction[ 3 ], traceresult, damagebits )
{
if( GetBit( is_Connected, iAttacker ) && GetBit( is_Alive, iAttacker ) )
{
static g_iWeapon; g_iWeapon = get_user_weapon( iAttacker )
if( g_iWeapon == CSW_KNIFE || g_iWeapon == CSW_HEGRENADE )
{
return HAM_HANDLED
}

SetBit( iKillerShot, iAttacker )

}
return HAM_HANDLED

}

#if defined USING_SQL
public QueryCreateTable( failstate, Handle:query, error[], errnum, data[], size, Float:queuetime )
{
if( failstate == TQUERY_CONNECT_FAILED
|| failstate == TQUERY_QUERY_FAILED )
{
set_fail_state( error )
}
}
#endif
new iPage
public Ach_HelpMenu( id, iPage )
{
//Menu Title
new title[ 64 ]; formatex( title, sizeof( title ) - 1, "\rAchievement\w Info Menu^n" )
//Create the menu
new menu = menu_create( title, "DescriptionMenu_Handle" )

new iNumber[ 5 ], szOption[ 75 ], i
for( i = 0; i < g_iAchCount; i++ ) {
num_to_str( i+1, iNumber, 4 )
formatex( szOption, sizeof( szOption ), "%s \yYour Stats\R \w)\r %d\d /\r %d\w (", g_iAchsMotd[ i ], g_iAchsMaxPoints[ i ], g_iAchLevel[ id ][ i ] )
menu_additem( menu, szOption, iNumber )
}
for( new iWeap = 0; iWeap < WEAPON_SIZE; iWeap++ ) {
i++
num_to_str( i+1, iNumber, 4 )
formatex( szOption, sizeof( szOption ), "%s \yYour Stats\R \w)\r %d\d /\r %d\w (", g_szWeaponNames2[ iWeap ], g_iAchsWeaponMaxKills[ iWeap ], g_iPlayersKills[ id ][ g_iWeaponIDs[ iWeap ] ] )
menu_additem( menu, szOption, iNumber )
}


menu_setprop( menu, MPROP_EXIT , MEXIT_NORMAL )
menu_display( id, menu, iPage )
}

public DescriptionMenu_Handle( id, menu, item )
{
if( item == MENU_EXIT )
{
menu_destroy( menu )
return PLUGIN_HANDLED
}

new data[ 6 ], iName[ 64 ]
new access, callback

menu_item_getinfo( menu, item, access, data, 5, iName, 63, callback )
player_menu_info( id, menu, menu, iPage )

new key = str_to_num( data )
new key_2 = ( key-g_iAchCount-2 )
switch ( key )
{
case 1..30: Print( id, "^4%s^1 %s", g_szAchievementTag, g_iAchsDesciption[ key-1 ] )
case 31..38: Print( id, "^4%s^1 Get a total of^3 %d^1 kills with a^4 %s^1!", g_szAchievementTag, g_iAchsWeaponMaxKills[ key_2 ], g_szWeaponNames2[ key_2 ] )
case 39: Print( id, "^4%s^1 Throw a total of^3 %d^4 %s^1!", g_szAchievementTag, g_iAchsWeaponMaxKills[ key_2 ], g_szWeaponNames2[ key_2 ] )
case 40..54: Print( id, "^4%s^1 Get a total of^3 %d^1 kills with a^4 %s^1!", g_szAchievementTag, g_iAchsWeaponMaxKills[ key_2 ], g_szWeaponNames2[ key_2 ] )
case 55: Print( id, "^4%s^1 Throw a total of^3 %d^4 %s^1!", g_szAchievementTag, g_iAchsWeaponMaxKills[ key_2 ], g_szWeaponNames2[ key_2 ] )
case 56..60: Print( id, "^4%s^1 Get a total of^3 %d^1 kills with a^4 %s^1!", g_szAchievementTag, g_iAchsWeaponMaxKills[ key_2 ], g_szWeaponNames2[ key_2 ] )
}

Ach_HelpMenu( id, iPage )

return PLUGIN_HANDLED
}

public CmdMainMenu( id )
{
Ach_StartMenu( id )
}

public Ach_StartMenu( id )
{
new Float:g_Number = ( g_iAchLevel[ id ][ COMPLETED_ACHIEVEMENTS ]*1.0 )
new Float:g_Number2 = ( g_iAchsMaxPoints[ COMPLETED_ACHIEVEMENTS ]*1.0 )
new Float:g_Number3 = g_Number/g_Number2*100
//Menu Title
new title[ 64 ]; formatex( title, sizeof( title ) - 1, "\yMain Menu^n\wYou are\r %.f percent\w completed!^n", g_Number3 )
//Create the menu
new menu = menu_create( title, "StartMenu_Handle" )
menu_additem( menu, "\wInfo", "1", 0 )
menu_additem( menu, "\wAchievements\r Player Info", "2", 0 )
menu_additem( menu, "\wAchievement\y Help", "3", 0 )
menu_additem( menu, "\wAdmin Cvar Settings\y Help", "4", ADMIN_CVAR )
menu_display( id, menu )
}

public StartMenu_Handle( id, menu, item )
{
if( item == MENU_EXIT )
{
menu_destroy( menu )
return PLUGIN_HANDLED
}

new data[ 6 ], iName[ 64 ]
new access, callback

menu_item_getinfo( menu, item, access, data, 5, iName, 63, callback )

new key = str_to_num( data )
switch( key )
{
case 1:
{
Print( id, "^4[AMXX]^1 This server is using^3 Achievements^4 v%s^1, by^3 Pastout!", VERSION )
Ach_StartMenu( id )
}
case 2:
{
Ach_PlayerInfoMenu( id )
}
case 3:
{
Ach_HelpMenu( id, iPage )
}
case 4:
{
Ach_AdminCvarMenu( id )
}
}
return PLUGIN_HANDLED
}

new const g_szGetCvar_String[][] =
{
"\rOff",
"\yDisplay Only to Player",
"\wDisplay to Everyone"
}

public Ach_AdminCvarMenu( id )
{
//Menu Title
new title[ 64 ]; formatex( title, sizeof( title ) - 1, "\rAdmin\w Cvar Settings Menu^n" )
//Create the menu
new menu = menu_create( title, "AdminCvarMenu_Handle" )
new szOption[ 75 ]
formatex( szOption, sizeof( szOption ), "Show Author Info %s", get_pcvar_num( g_pCvar_ShowInfo ) == 0 ? "\rOff" : "\yOn" )
menu_additem( menu, szOption, "1", ADMIN_CVAR )
formatex( szOption, sizeof( szOption ), "Death Message %s", get_pcvar_num( g_pCvar_DeathMessage ) == 0 ? "\rOff" : "\yOn" )
menu_additem( menu, szOption, "2", ADMIN_CVAR )
formatex( szOption, sizeof( szOption ), "Flash Message %s", get_pcvar_num( g_pCvar_FlashMessage ) == 0 ? "\rOff" : "\yOn" )
menu_additem( menu, szOption, "3", ADMIN_CVAR )
formatex( szOption, sizeof( szOption ), "Bomb Message %s", get_pcvar_num( g_pCvar_BombMessage ) == 0 ? "\rOff" : "\yOn" )
menu_additem( menu, szOption, "4", ADMIN_CVAR )
formatex( szOption, sizeof( szOption ), "Play Sound %s", get_pcvar_num( g_pCvar_PlaySound ) == 0 ? "\rOff" : "\yOn" )
menu_additem( menu, szOption, "5", ADMIN_CVAR )
if( get_pcvar_num( g_pCvar_Reward ) == 0 )
{
menu_additem( menu, "Reward Cash \rOff", "6", ADMIN_CVAR )
}
else
{
formatex( szOption, sizeof( szOption ), "Reward Cash \y%d", get_pcvar_num( g_pCvar_Reward ) )
menu_additem( menu, szOption, "6", ADMIN_CVAR )
}
formatex( szOption, sizeof( szOption ), "Achievement Message %s", g_szGetCvar_String[ get_pcvar_num( g_pCvar_Message ) ] )
menu_additem( menu, szOption, "7", ADMIN_CVAR )
menu_display( id, menu )
}

public AdminCvarMenu_Handle( id, menu, item )
{
if( item == MENU_EXIT )
{
menu_destroy( menu )
return PLUGIN_HANDLED
}

new data[ 6 ], iName[ 64 ]
new access, callback

menu_item_getinfo( menu, item, access, data, 5, iName, 63, callback )

new key = str_to_num( data )
switch( key )
{
case 1: ToggleCvar( g_pCvar_ShowInfo )
case 2: ToggleCvar( g_pCvar_DeathMessage )
case 3: ToggleCvar( g_pCvar_FlashMessage )
case 4: ToggleCvar( g_pCvar_BombMessage )
case 5: ToggleCvar( g_pCvar_PlaySound )
case 6: DoEnterValue( id )
case 7: ToggleCvar( g_pCvar_Message )
}

Ach_AdminCvarMenu( id )
return PLUGIN_HANDLED
}

ToggleCvar( Cvar )
{
if( g_pCvar_Message == Cvar )
{
switch ( get_pcvar_num( Cvar ) )
{
case 2: set_pcvar_num( Cvar, 0 )
case 1: set_pcvar_num( Cvar, 2 )
case 0: set_pcvar_num( Cvar, 1 )
default: set_pcvar_num( Cvar, 2 )
}
}
else
{
switch ( get_pcvar_num( Cvar ) )
{
case 1: set_pcvar_num( Cvar, 0 )
case 0: set_pcvar_num( Cvar, 1 )
default: set_pcvar_num( Cvar, 1 )
}
}
}

DoEnterValue( id )
{
client_cmd(id, "messagemode Enter_Value")
}

public CmdEnterValue( id )
{
new arg[ 5 ]
read_argv( 1, arg, charsmax( arg ) )

if ( !strlen( arg ) )
{
Print( id, "Please type a new value." )
client_cmd( id, "messagemode Enter_Value" )
return PLUGIN_HANDLED
}
else if ( !IsStrFloat( arg ) )
{
Print( id, "You cannot use letters for this cvar! Please type a new value." )
client_cmd( id, "messagemode Enter_Value" )
return PLUGIN_HANDLED
}
new iCvar = str_to_num( arg )
set_pcvar_num( g_pCvar_Reward, iCvar )
Ach_AdminCvarMenu( id )
return PLUGIN_HANDLED
}

bool:IsStrFloat( string[] )
{
new len = strlen( string )
for( new i = 0; i < len; i++ )
{
switch ( string[ i ] )
{
case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '-', '*':continue;
default: return false;
}
}
return true
}

public Ach_PlayerInfoMenu( id )
{
new title[ 64 ]; formatex( title, sizeof( title ) - 1, "\rPlayer Info Achievements^n\w - \ySelect Player")
new menu = menu_create( title, "Ach_PlayerInfoMenu_Handle" )

new players[ 32 ], pnum, tempid
new szName[ 32 ], szTempid[ 10 ]

get_players( players, pnum, "h" )

for( new i; i < pnum; i++ )
{
tempid = players[ i ]

get_user_name( tempid, szName, charsmax( szName ) )
num_to_str( tempid, szTempid, 9 )

if( id == tempid )
menu_additem( menu, "\dYour Stats", szTempid, 0 )
else
menu_additem( menu, szName, szTempid, 0 )
}

menu_display( id, menu )
}

public Ach_PlayerInfoMenu_Handle( id, menu, item )
{
if( item == MENU_EXIT )
{
menu_destroy( menu )
if( GetBit( is_Connected, id ) )
Ach_StartMenu( id )
return PLUGIN_HANDLED
}

new data[ 6 ], iName[ 64 ]
new access, callback
menu_item_getinfo( menu, item, access, data, 5, iName, 63, callback )

g_iGetTempid[ id ] = str_to_num( data )

Ach_PlayerInfoDisplayMenu( id )

return PLUGIN_HANDLED
}

public Ach_PlayerInfoDisplayMenu( id )
{
new Float:g_Number = ( g_iAchLevel[ id ][ COMPLETED_ACHIEVEMENTS ]*1.0 )
new Float:g_Number2 = ( g_iAchsMaxPoints[ COMPLETED_ACHIEVEMENTS ]*1.0 )
new Float:g_Number3 = g_Number/g_Number2*100
new szName[ 32 ]; get_user_name( g_iGetTempid[ id ], szName, charsmax( szName ) )
//Menu Title
new title[ 128 ]; formatex( title, sizeof( title ) - 1, "\rAchievement\w Info Menu^n\w -\y %s\d is\r %.f Percent\w Completed!^n", szName, g_Number3 )
//Create the menu
new menu = menu_create( title, "DescriptionMenu_PlayerHandle" )

new iNumber[ 5 ], szOption[ 75 ], i
for( i = 0; i < g_iAchCount; i++ ) {
num_to_str( i+1, iNumber, 4 )
formatex( szOption, sizeof( szOption ), "%s \yStats\R \w)\r %d\d /\r %d\w (", g_iAchsMotd[ i ], g_iAchsMaxPoints[ i ], g_iAchLevel[ g_iGetTempid[ id ] ][ i ] )
menu_additem( menu, szOption, iNumber )
}
for( new iWeap = 0; iWeap < WEAPON_SIZE; iWeap++ ) {
i++
num_to_str( i+1, iNumber, 4 )
formatex( szOption, sizeof( szOption ), "%s \yStats\R \w)\r %d\d /\r %d\w (", g_szWeaponNames2[ iWeap ], g_iAchsWeaponMaxKills[ iWeap ], g_iPlayersKills[ g_iGetTempid[ id ] ][ g_iWeaponIDs[ iWeap ] ] )
menu_additem( menu, szOption, iNumber )
}


menu_setprop( menu, MPROP_EXIT , MEXIT_NORMAL )
menu_display( id, menu, iPage )

return PLUGIN_HANDLED
}

public DescriptionMenu_PlayerHandle( id, menu, item )
{
if( item == MENU_EXIT )
{
menu_destroy( menu )
if( GetBit( is_Connected, id ) )
Ach_PlayerInfoMenu( id )
return PLUGIN_HANDLED
}

new data[ 6 ], iName[ 64 ]
new access, callback

menu_item_getinfo( menu, item, access, data, 5, iName, 63, callback )
player_menu_info( id, menu, menu, iPage )

Ach_PlayerInfoDisplayMenu( id )

return PLUGIN_HANDLED
}

public plugin_end()
{
TrieDestroy( g_tWeaponNameToID )
#if !defined USING_SQL
nvault_close( g_iVault )
#endif
}

public Ham_CBasePlayer_Spawn( id )
{
if( !is_user_alive( id ) )
{
return HAM_IGNORED
}

SetBit( is_Alive, id )

return HAM_IGNORED;
}

public client_connect( id )
{
ResetStats( id )
}

public client_authorized( id )
{
if(/* is_user_bot( id ) ||*/ is_user_hltv( id ) )
{
SetBit( is_NotValidPlayer, id )
}

if( !GetBit( is_NotValidPlayer, id ) )
{
#if defined USING_REGEX
get_user_authid( id, g_iAuthID[ id ], charsmax( g_iAuthID[] ) )

if( !IsValidAuthid( g_iAuthID[ id ] ) )
{
g_iAuthID[ id ][ 0 ] = 0
}
else
{
g_iLoadStats( id )
}
#else
if( is_user_bot( id ) )
{
get_user_name( id, g_iAuthID[ id ], charsmax( g_iAuthID[] ) )
}
else if( !IsValidAuthid( g_iAuthID[ id ] ) )
{
get_user_ip( id, g_iAuthID[ id ], charsmax( g_iAuthID[] ) )
}
else
{
get_user_authid( id, g_iAuthID[ id ], charsmax( g_iAuthID[] ) )
}

g_iLoadStats( id )
#endif
}
}

public client_putinserver( id )
{
SetBit( is_Connected, id )
if( GetBit( is_Connected, id ) )
{
#if defined USING_REGEX
if( !IsUserAuthorized( id ) )
{
return
}
#endif
g_iJoinTime[ id ] = get_systime();

DelBit( is_Alive, id );

SetBit( g_iDeathMessages, id )
g_iAchLevel[ id ][ CONNECTIONS ]++

new szName[ 32 ]
get_user_name( id, szName, charsmax( szName ) )

switch( g_iAchLevel[ id ][ CONNECTIONS ] )
{
case 50: AchievementSecondary( id, 0 )

case 100: AchievementSecondary( id, 1 )

case 250: AchievementSecondary( id, 2 )

case MAX_CONNECTION:
{
Achievement( id, CONNECTIONS, -1 )
}
}
}
}

public client_disconnect( id )
{
#if defined USING_REGEX
if( !IsUserAuthorized( id ) )
{
return
}
#endif
if( !GetBit( is_NotValidPlayer, id ) )
{
g_iSaveStats( id )
}

g_iJoinTime[ id ] = 0;
DelBit( is_Connected, id );
DelBit( is_Alive, id )

#if defined USING_SQL
g_loaded_data[ id ] = 0
#endif
}

public FwdCmdStart( id, handle )
{
if ( !GetBit( is_Connected, id ) && !GetBit( is_Alive, id ) )
{
return FMRES_IGNORED
}
#if defined USING_REGEX
if( !IsUserAuthorized( id ) )
{
return FMRES_IGNORED
}
#endif

if( g_iAchLevel[ id ][ CAMP_FIRE ] < MAX_CAMP_FIRE )
{
if( entity_get_int( id, EV_INT_button ) & ( IN_MOVELEFT | IN_MOVERIGHT | IN_BACK | IN_FORWARD ) )
{
DelBit( iKillerHasNotMoved, id )
g_iKills[ id ] = 0
}
else
{
SetBit( iKillerHasNotMoved, id )
}
}

if( g_iAchLevel[ id ][ FLY_AWAY ] < MAX_FLY_AWAY || g_iAchLevel[ id ][ FLY_KILLER ] < MAX_FLY_KILLER)
{
if( entity_get_int( id, EV_INT_flags ) & FL_ONGROUND )
{
DelBit( is_VictimInAir, id )
}
else
{
SetBit( is_VictimInAir, id )
}
}

if( g_iAchLevel[ id ][ DISTANCE_WALKED ] < MAX_DISTANCE_WALKED && !GetBit( iKillerHasNotMoved, id ) )
{
new Float:vecOrigin[ 3 ]
entity_get_vector( id, EV_VEC_origin, vecOrigin )

if( !xs_vec_equal( vecOldOrigin[ id ], vecNullOrigin ) )
{
flDistance[ id ] += get_distance_f( vecOrigin, vecOldOrigin[ id ] )
}

xs_vec_copy( vecOrigin, vecOldOrigin[ id ] )

new szName[ 32 ]
get_user_name( id, szName, charsmax( szName ) )

switch( g_iAchLevel[ id ][ DISTANCE_WALKED ] )
{
case 0:
{
if( flDistance[ id ]/g_iFeet >= 1 )//baby steps
{
g_iAchLevel[ id ][ DISTANCE_WALKED ]++
AchievementSecondary( id, 3 )
}
}
case 1:
{
if( flDistance[ id ]/g_iFeet >= 5280 )//1 mile hey?
{
g_iAchLevel[ id ][ DISTANCE_WALKED ]++
AchievementSecondary( id, 4 )
}
}
case MAX_DISTANCE_WALKED:
{
if( flDistance[ id ]/g_iFeet >= 26400 )//Five miles hey? Is this possible IDK lol
{
Achievement( id, DISTANCE_WALKED, -1 )
}
}
}
}

return FMRES_IGNORED
}

ResetStats( id )
{
flDistance[ id ] = 0.0
xs_vec_copy( vecNullOrigin, vecOldOrigin[ id ] )
}

public Event_NewRound()
{
if ( task_exists( 2345 ) )
remove_task( 2345 )
if ( task_exists( 2346 ) )
remove_task( 2346 )

if( get_pcvar_num( g_pCvar_ShowInfo ) == 1 )
{
if( g_iRounds >= 10 ) {
Print( 0, "^4[AMXX]^1 This server is using^3 Achievements^4 v%s^1, by^3 Pastout!", VERSION )
Print( 0, "^4[AMXX]^1 Type^3 /help^1 for information about^4 achievements")
g_iRounds = 0
}

g_iRounds++
}

new iPlayers[ 32 ], iNum, iPlayer
get_players( iPlayers, iNum, "ch" )

for( new i = 0; i < iNum; i++ )
{
iPlayer = iPlayers[ i ]

g_iRoundSparys[ iPlayer ] = 0;
DelBit( StandAlone, iPlayer )
}

g_iBombPlant = false
g_iGetBombPlanted = 26

set_task( 1.0, "CheckBombPlantedTimer", 2345, _, _, "a", g_iGetBombPlanted )
}

public CheckBombPlantedTimer( )
{
g_iGetBombPlanted--

if( g_iGetBombPlanted >= 1 )
g_iGetBombDown = true
else
{
g_iGetBombDown = false
remove_task( 2345 )
}

}

public bomb_defused( iDefuser )
{
#if defined USING_REGEX
if( !IsUserAuthorized( iDefuser ) )
{
return PLUGIN_HANDLED
}
#endif
new szName[ 32 ]
get_user_name( iDefuser, szName, charsmax( szName ) )

if( g_iBombPlant && g_iAchLevel[ iDefuser ][ BOMB ] < MAX_BOMB )
{
g_iAchLevel[ iDefuser ][ BOMB ]++
Achievement( iDefuser, BOMB, -1 )
}

g_iAchLevel[ iDefuser ][ DEFUSED_BOMB ]++
switch( g_iAchLevel[ iDefuser ][ DEFUSED_BOMB ] )
{
case 5: AchievementSecondary( iDefuser, 5 )

case 10: AchievementSecondary( iDefuser, 6 )

case 15: AchievementSecondary( iDefuser, 7 )

case 20: AchievementSecondary( iDefuser, 8 )

case MAX_DEFUSED_BOMB:
{
Achievement( iDefuser, DEFUSED_BOMB, -1 )
}
}
if( get_pcvar_num( g_pCvar_BombMessage ) == 1 )
{
Print( 0, "^4[AMXX]^3 %s^1 has defused the^4 bomb.", szName )
}
#if defined USING_REGEX
return PLUGIN_HANDLED
#endif
}

public bomb_defusing( id )
{
if( get_pcvar_num( g_pCvar_BombMessage ) == 1 )
{
new szName[ 32 ]; get_user_name( id, szName, charsmax( szName ) )
Print( 0, "^4[AMXX]^3 %s^1 is defusing the^4 bomb^1 with%s a^3 kit^1.", szName, is_DefusingWithKit ? "" : "out" )
}
}

public bomb_planting( id )
{
if( get_pcvar_num( g_pCvar_BombMessage ) == 1 )
{
new szName[ 32 ]; get_user_name( id, szName, charsmax( szName ) )
Print( 0, "^4[AMXX]^3 %s^1 is planting the^4 bomb.", szName )
}
}

public bomb_planted( iPlanter )
{
#if defined USING_REGEX
if( !IsUserAuthorized( iPlanter ) )
{
return PLUGIN_HANDLED
}
#endif

g_iBombTime = get_pcvar_num( g_pCvarC4Timer )
set_task( 1.0, "CheckC4Timer", 2346, _, _, "a", g_iBombTime )

g_iAchLevel[ iPlanter ][ PLANT_BOMB_COUNT ]++

if( GetBit(is_Connected, iPlanter ) && GetBit( is_Alive, iPlanter ) )
{

if( g_iGetBombDown && g_iAchLevel[ iPlanter ][ PLANT_BOMB ] < MAX_PLANT_BOMB )
{
g_iAchLevel[ iPlanter ][ PLANT_BOMB ]++
Achievement( iPlanter, PLANT_BOMB, -1 )
}

switch( g_iAchLevel[ iPlanter ][ PLANT_BOMB_COUNT ] )
{
case MAX_PLANT_BOMB_COUNT:
{
Achievement( iPlanter, PLANT_BOMB_COUNT, -1 )
}
}
}
if( get_pcvar_num( g_pCvar_BombMessage ) == 1 )
{
new szName[ 32 ]; get_user_name( iPlanter, szName, charsmax( szName ) )
Print( 0, "^4[AMXX]^3 %s^1 has planted the^4 bomb.", szName )
}

g_C4Ent = fm_get_c4()
pev( g_C4Ent , pev_origin , g_fC4Origin )

#if defined USING_REGEX
return PLUGIN_HANDLED
#endif
}

public CheckC4Timer()
{
g_iBombTime --
if( g_iBombTime <= 1 )
{
g_iBombPlant = true
remove_task( 2346 )
}
}

public Event_GotBomb( id )
{
g_iPlanter = id
}

public bomb_explode( g_iPlayer )
{
if( get_pcvar_num( g_pCvar_BombMessage ) == 1 )
{
Print( 0, "^4[AMXX]^1 The^3 bomb^1 has^4 exploded." )
}
}

public client_death( iKiller, iVictim, iWeapon, iHitplace, TK )
{
#if defined USING_REGEX
if( !IsUserAuthorized( iKiller ) || !IsUserAuthorized( iVictim ) )
{
return PLUGIN_HANDLED
}
#endif

if( ( iWeapon == CSW_HEGRENADE ) && !TK && GetBit( is_Alive, iKiller ) )
{
g_iPlayersKills[ iKiller ][ CSW_HEGRENADE ]++
if( g_iPlayersKills[ iKiller ][ CSW_HEGRENADE ] == 25 )
{
Achievement( iKiller, -1, HEGRENADE )
}

g_iGrenadeKills[ iKiller ]++
if( g_iGrenadeKills[ iKiller ] >= 3 )
{
g_iAchLevel[ iKiller ][ HAT_TRICK ]++
switch( g_iAchLevel[ iKiller ][ HAT_TRICK ] )
{
case MAX_HAT_TRICK:
{
Achievement( iKiller, HAT_TRICK, -1 )
}
}
g_iGrenadeKills[ iKiller ] = 0
}
set_task( 0.3, "ResetGrenadeKills", iKiller )
}

#if defined USING_REGEX
return PLUGIN_HANDLED
#endif
}

public ResetGrenadeKills( iKiller )
if( GetBit( is_Connected, iKiller ) )
g_iGrenadeKills[ iKiller ] = 0;

public grenade_throw( id, grenadeIndex, weaponId )
{
#if defined USING_REGEX
if( !IsUserAuthorized( id ) )
{
return PLUGIN_HANDLED
}
#endif

switch( weaponId )
{
case CSW_FLASHBANG:
{
g_iPlayersKills[ id ][ CSW_FLASHBANG ]++

if( g_iPlayersKills[ id ][ CSW_FLASHBANG ] == MAX_FLASHBANG )
{
Achievement( id, -1, FLASHBANG )
}
}
case CSW_SMOKEGRENADE:
{
g_iPlayersKills[ id ][ CSW_SMOKEGRENADE ]++

if( g_iPlayersKills[ id ][ CSW_SMOKEGRENADE ] == MAX_SMOKEGRENADE )
{
Achievement( id, -1, SMOKEGRENADE )
}
}
}
#if defined USING_REGEX
return PLUGIN_HANDLED
#endif
}

get_user_flashed( id, &iPercent=0 )
{
new Float:flFlashedAt = get_pdata_float( id, m_flFlashedAt, XO_PLAYER )

if( !flFlashedAt )
{
return 0
}

new Float:flGameTime = get_gametime()
new Float:flTimeLeft = flGameTime - flFlashedAt
new Float:flFlashDuration = get_pdata_float( id, m_flFlashDuration, XO_PLAYER )
new Float:flFlashHoldTime = get_pdata_float( id, m_flFlashHoldTime, XO_PLAYER )
new Float:flTotalTime = flFlashHoldTime + flFlashDuration

if( flTimeLeft > flTotalTime )
{
return 0
}

new iFlashAlpha = get_pdata_int( id, m_iFlashAlpha, XO_PLAYER )

if( iFlashAlpha == ALPHA_FULLBLINDED )
{
if( get_pdata_float( id, m_flFlashedUntil, XO_PLAYER) - flGameTime > 0.0 )
{
iPercent = 100
}
else
{
iPercent = 100-floatround( ( ( flGameTime - ( flFlashedAt + flFlashHoldTime ) ) * 100.0 )/flFlashDuration )
}
}
else
{
iPercent = 100-floatround( ( ( flGameTime - flFlashedAt ) * 100.0 ) / flTotalTime )
}

return iFlashAlpha
}

public Event_PlayerKilled()
{
new iKiller = read_data( 1 )
new iVictim = read_data( 2 )

if( is_user_alive( iKiller ) )
SetBit( is_Alive, iKiller )
else
DelBit( is_Alive, iKiller )

if( !IsPlayer( iKiller ) || iKiller == iVictim )
{
return PLUGIN_HANDLED
}

#if defined USING_REGEX
if( !IsUserAuthorized( iKiller ) || !IsUserAuthorized( iVictim ) )
{
return PLUGIN_HANDLED
}
#endif

new headshot = read_data( 3 )
new g_iKiller[ 32 ], g_iVictim[ 32 ], g_iWeapon[ 16 ], g_iOrigin[ 3 ], g_iOrigin2[ 3 ]
read_data(4, g_iWeapon, 15)

get_user_origin( iKiller, g_iOrigin )
get_user_origin( iVictim, g_iOrigin2 )
new flDistance = get_distance( g_iOrigin, g_iOrigin2 )

get_user_name( iKiller, g_iKiller, charsmax( g_iKiller ) )
get_user_name( iVictim, g_iVictim, charsmax( g_iVictim ) )

if( GetBit( iKillerShot, iKiller ) )
{
g_iShotKills[ iKiller ]++
if( g_iShotKills[ iKiller ] >= 2 )
{
g_iAchLevel[ iKiller ][ AMMO_CONSERVATION ]++
switch( g_iAchLevel[ iKiller ][ AMMO_CONSERVATION ] )
{
case MAX_AMMO_CONSERVATION:
{
Achievement( iKiller, AMMO_CONSERVATION, -1 )
}
}
g_iShotKills[ iKiller ] = 0
}
}

if( headshot )
{

g_iAchLevel[ iKiller ][ HEAD_SHOTS ]++

switch( g_iAchLevel[ iKiller ][ HEAD_SHOTS ] )
{
case MAX_HEAD_SHOTS:
{
Achievement( iKiller, HEAD_SHOTS, -1 )
}
}
}

if( TrieGetCell( g_tWeaponNameToID, g_iWeapon, iWeaponID ) )
{
g_iPlayersKills[ iKiller ][ iWeaponID ]++

switch( iWeaponID )
{
case CSW_P228:
{
switch( g_iPlayersKills[ iKiller ][ iWeaponID ] )
{
case MAX_P228:
{
g_iAchLevel[ iKiller ][ PISTOL_MASTER ]++
g_iAchLevel[ iKiller ][ MASTER_AT_ARMS ]++
Achievement( iKiller, -1, P228 )
}
}
}
case CSW_SCOUT:
{
switch( g_iPlayersKills[ iKiller ][ iWeaponID ] )
{
case MAX_SCOUT:
{
g_iAchLevel[ iKiller ][ RIFLE_MASTER ]++
g_iAchLevel[ iKiller ][ MASTER_AT_ARMS ]++
Achievement( iKiller, -1, SCOUT )
}
}
}

case CSW_XM1014:
{
switch( g_iPlayersKills[ iKiller ][ iWeaponID ] )
{
case MAX_XM1014:
{
g_iAchLevel[ iKiller ][ MASTER_AT_ARMS ]++
g_iAchLevel[ iKiller ][ SHOTGUN_MASTER ]++
Achievement( iKiller, -1, XM1014 )
}
}
}

case CSW_MAC10:
{
switch( g_iPlayersKills[ iKiller ][ iWeaponID ] )
{
case MAX_MAC10:
{
g_iAchLevel[ iKiller ][ MASTER_AT_ARMS ]++
Achievement( iKiller, -1, MAC10 )
}
}
}
case CSW_AUG:
{
switch( g_iPlayersKills[ iKiller ][ iWeaponID ] )
{
case MAX_AUG:
{
g_iAchLevel[ iKiller ][ RIFLE_MASTER ]++
g_iAchLevel[ iKiller ][ MASTER_AT_ARMS ]++
Achievement( iKiller, -1, AUG )
}
}

}
/*
case CSW_SMOKEGRENADE:
{
switch( g_iPlayersKills[ iKiller ][ iWeaponID ] )
{

}
}*/
case CSW_ELITE:
{
switch( g_iPlayersKills[ iKiller ][ iWeaponID ] )
{
case MAX_ELITE:
{
g_iAchLevel[ iKiller ][ PISTOL_MASTER ]++
g_iAchLevel[ iKiller ][ MASTER_AT_ARMS ]++
Achievement( iKiller, -1, ELITE )
}
}
}
case CSW_FIVESEVEN:
{
switch( g_iPlayersKills[ iKiller ][ iWeaponID ] )
{
case MAX_FIVESEVEN:
{
g_iAchLevel[ iKiller ][ PISTOL_MASTER ]++
g_iAchLevel[ iKiller ][ MASTER_AT_ARMS ]++
Achievement( iKiller, -1, FIVESEVEN )
}
}
}
case CSW_UMP45:
{
switch( g_iPlayersKills[ iKiller ][ iWeaponID ] )
{
case MAX_UMP45:
{
g_iAchLevel[ iKiller ][ MASTER_AT_ARMS ]++
Achievement( iKiller, -1, UMP45 )
}
}
}
case CSW_SG550:
{
switch( g_iPlayersKills[ iKiller ][ iWeaponID ] )
{
case MAX_SG550:
{
g_iAchLevel[ iKiller ][ RIFLE_MASTER ]++
g_iAchLevel[ iKiller ][ MASTER_AT_ARMS ]++
Achievement( iKiller, -1, SG550 )
}
}
}
case CSW_GALIL:
{
switch( g_iPlayersKills[ iKiller ][ iWeaponID ] )
{
case MAX_GALIL:
{
g_iAchLevel[ iKiller ][ RIFLE_MASTER ]++
g_iAchLevel[ iKiller ][ MASTER_AT_ARMS ]++
Achievement( iKiller, -1, GALIL )
}
}
}
case CSW_FAMAS:
{
switch( g_iPlayersKills[ iKiller ][ iWeaponID ] )
{
case MAX_FAMAS:
{
g_iAchLevel[ iKiller ][ RIFLE_MASTER ]++
g_iAchLevel[ iKiller ][ MASTER_AT_ARMS ]++
Achievement( iKiller, -1, FAMAS )
}
}
}
case CSW_USP:
{
switch( g_iPlayersKills[ iKiller ][ iWeaponID ] )
{
case MAX_USP:
{
g_iAchLevel[ iKiller ][ PISTOL_MASTER ]++
g_iAchLevel[ iKiller ][ MASTER_AT_ARMS ]++
Achievement( iKiller, -1, USP )
}
}
}
case CSW_GLOCK18:
{
switch( g_iPlayersKills[ iKiller ][ iWeaponID ] )
{
case MAX_GLOCK18:
{
g_iAchLevel[ iKiller ][ PISTOL_MASTER ]++
g_iAchLevel[ iKiller ][ MASTER_AT_ARMS ]++
Achievement( iKiller, -1, GLOCK18 )
}
}
}
case CSW_AWP:
{
switch( g_iPlayersKills[ iKiller ][ iWeaponID ] )
{
case MAX_AWP:
{
g_iAchLevel[ iKiller ][ RIFLE_MASTER ]++
g_iAchLevel[ iKiller ][ MASTER_AT_ARMS ]++
Achievement( iKiller, -1, AWP )
}
}
}
case CSW_MP5NAVY:
{
switch( g_iPlayersKills[ iKiller ][ iWeaponID ] )
{
case MAX_MP5NAVY:
{
g_iAchLevel[ iKiller ][ MASTER_AT_ARMS ]++
Achievement( iKiller, -1, MP5NAVY )
}
}
}
case CSW_M249:
{
switch( g_iPlayersKills[ iKiller ][ iWeaponID ] )
{
case MAX_M249:
{
g_iAchLevel[ iKiller ][ MASTER_AT_ARMS ]++
Achievement( iKiller, -1, M249 )
}
}
}
case CSW_M3:
{
switch( g_iPlayersKills[ iKiller ][ iWeaponID ] )
{
case MAX_M3:
{
g_iAchLevel[ iKiller ][ MASTER_AT_ARMS ]++
g_iAchLevel[ iKiller ][ SHOTGUN_MASTER ]++
Achievement( iKiller, -1, M3 )
}
}
}
case CSW_M4A1:
{
switch( g_iPlayersKills[ iKiller ][ iWeaponID ] )
{
case MAX_M4A1:
{
g_iAchLevel[ iKiller ][ RIFLE_MASTER ]++
g_iAchLevel[ iKiller ][ MASTER_AT_ARMS ]++
Achievement( iKiller, -1, M4A1 )
}
}
}
case CSW_TMP:
{
switch( g_iPlayersKills[ iKiller ][ iWeaponID ] )
{
case MAX_TMP:
{
g_iAchLevel[ iKiller ][ MASTER_AT_ARMS ]++
Achievement( iKiller, -1, TMP )
}
}
}
case CSW_G3SG1:
{
switch( g_iPlayersKills[ iKiller ][ iWeaponID ] )
{
case MAX_G3SG1:
{
g_iAchLevel[ iKiller ][ RIFLE_MASTER ]++
g_iAchLevel[ iKiller ][ MASTER_AT_ARMS ]++
Achievement( iKiller, -1, G3SG1 )
}
}
}
/*
case CSW_FLASHBANG:
{
switch( g_iPlayersKills[ iKiller ][ iWeaponID ] )
{

}
}*/
case CSW_DEAGLE:
{
switch( g_iPlayersKills[ iKiller ][ iWeaponID ] )
{
case MAX_DEAGLE:
{
g_iAchLevel[ iKiller ][ PISTOL_MASTER ]++
g_iAchLevel[ iKiller ][ MASTER_AT_ARMS ]++
Achievement( iKiller, -1, DEAGLE )
}
}
}
case CSW_SG552:
{
switch( g_iPlayersKills[ iKiller ][ iWeaponID ] )
{
case MAX_SG552:
{
g_iAchLevel[ iKiller ][ RIFLE_MASTER ]++
g_iAchLevel[ iKiller ][ MASTER_AT_ARMS ]++
Achievement( iKiller, -1, SG552 )
}
}
}
case CSW_AK47:
{
switch( g_iPlayersKills[ iKiller ][ iWeaponID ] )
{
case MAX_AK47:
{
g_iAchLevel[ iKiller ][ RIFLE_MASTER ]++
g_iAchLevel[ iKiller ][ MASTER_AT_ARMS ]++
Achievement( iKiller, -1, AK47 )
}
}
}
case CSW_KNIFE:
{
switch( g_iPlayersKills[ iKiller ][ iWeaponID ] )
{
case MAX_KNIFE:
{
g_iAchLevel[ iKiller ][ MASTER_AT_ARMS ]++
Achievement( iKiller, -1, KNIFE )
}
}
}
case CSW_P90:
{
switch( g_iPlayersKills[ iKiller ][ iWeaponID ] )
{
case MAX_P90:
{
g_iAchLevel[ iKiller ][ MASTER_AT_ARMS ]++
Achievement( iKiller, -1, P90 )
}
}
}
}
}
new g_RoundDistance = floatround( flDistance/g_iFeet )

switch( g_iAchLevel[ iKiller ][ DISTANCE_KILLED ] )
{
case 0:
{
if( g_RoundDistance <= 5 )
{
g_iAchLevel[ iKiller ][ DISTANCE_KILLED ]++
AchievementSecondary( iKiller, 9 )
}
}

case 1:
{
if( 6 <= g_RoundDistance <= 50 )
{
g_iAchLevel[ iKiller ][ DISTANCE_KILLED ]++
AchievementSecondary( iKiller, 10 )
}
}

case 2:
{
if( 51 <= g_RoundDistance <= 99 )
{
g_iAchLevel[ iKiller ][ DISTANCE_KILLED ]++
AchievementSecondary( iKiller, 11 )
}
}

case 3:
{
if( 100 <= g_RoundDistance <= 150 )
{
g_iAchLevel[ iKiller ][ DISTANCE_KILLED ]++
AchievementSecondary( iKiller, 12 )
}
}
case MAX_DISTANCE_KILLED:
{
if( 151 <= g_RoundDistance <= 300 )
{
Achievement( iKiller, DISTANCE_KILLED, -1 )
}
}
}

g_iAchLevel[ iKiller ][ TOTAL_KILLS ]++
switch( g_iAchLevel[ iKiller ][ TOTAL_KILLS ] )
{
case 250:
{
AchievementSecondary( iKiller, 13 )
}
case MAX_TOTAL_KILLS:
{
Achievement( iKiller, TOTAL_KILLS, -1 )
}
}

switch( g_iAchLevel[ iKiller ][ PISTOL_MASTER ] )
{
case MAX_PISTOL_MASTER:
{
Achievement( iKiller, PISTOL_MASTER, -1 )
}
}

switch( g_iAchLevel[ iKiller ][ RIFLE_MASTER ] )
{
case MAX_RIFLE_MASTER:
{
Achievement( iKiller, RIFLE_MASTER, -1 )
}
}

switch( g_iAchLevel[ iKiller ][ SHOTGUN_MASTER ] )
{
case MAX_SHOTGUN_MASTER:
{
Achievement( iKiller, SHOTGUN_MASTER, -1 )
}
}

switch( g_iAchLevel[ iKiller ][ MASTER_AT_ARMS ] )
{
case MAX_MASTER_AT_ARMS:
{
Achievement( iKiller, MASTER_AT_ARMS, -1 )
}
}

if( GetBit( is_VictimInAir, iVictim ) )
{
g_iAchLevel[ iKiller ][ FLY_AWAY ]++
switch( g_iAchLevel[ iKiller ][ FLY_AWAY ] )
{
case MAX_FLY_AWAY:
{
Achievement( iKiller, FLY_AWAY, -1 )
}
}
}
if( GetBit( is_VictimInAir, iKiller ) )
{
g_iAchLevel[ iKiller ][ FLY_KILLER ]++
switch( g_iAchLevel[ iKiller ][ FLY_KILLER ] )
{
case MAX_FLY_KILLER:
{
Achievement( iKiller, FLY_KILLER, -1 )
}
}
}
new iPercent
if( get_user_flashed( iKiller, iPercent ) )
{
if( get_pcvar_num( g_pCvar_FlashMessage ) == 1 )
{
Print( 0, "^4[AMXX]^3 %s^4 was Flashed (^1%s^4) ^1%d%% and killed^4 %s", g_iKiller, iPercent == 100 ? "Full" : "Semi", iPercent, g_iVictim )
}
if( iPercent == 100 )
{
g_iAchLevel[ iKiller ][ SPRAY_N_PRAY ]++

switch( g_iAchLevel[ iKiller ][ SPRAY_N_PRAY ] )
{
case MAX_SPRAY_N_PRAY:
{
Achievement( iKiller, SPRAY_N_PRAY, -1 )
}
}
}

}
else
{
if( get_pcvar_num( g_pCvar_DeathMessage ) == 1 && GetBit( g_iDeathMessages, iKiller ) )
{
Print( 0, "^1%s^4 %s^3 [^1 %s^3 ]^1 with a^4 %s^1 with a distance of^4 %d F%st^1 away.", g_iKiller, headshot ? "Headshot" : "Killed", g_iVictim, g_iWeapon, g_RoundDistance, g_RoundDistance == 1 ? "ee" : "oo" )
}
}
new iPlayers[ 32 ], iNum, iPlayer, ctCount = 0, tCount = 0
get_players( iPlayers, iNum, "ach" )

for( new i = 0; i < iNum; i++ )
{
iPlayer = iPlayers[ i ]

static CsTeams:iTeam
iTeam = cs_get_user_team( iPlayer )

switch( iTeam )
{
case CS_TEAM_CT:
{
ctCount++
}

case CS_TEAM_T:
{
tCount++
}
}
}
static CsTeams:iTeam
iTeam = cs_get_user_team( iVictim )


if( iTeam == CS_TEAM_CT && ctCount == 1 && tCount >= 3 )
{
SetBit( StandAlone, iVictim )
}
if( iTeam == CS_TEAM_T && ctCount >= 3 && tCount == 1 )
{
SetBit( StandAlone, iVictim )
}

if( GetBit( StandAlone, iVictim ) )
{
g_iAchLevel[ iVictim ][ STAND_ALONE ]++
switch( g_iAchLevel[ iVictim ][ STAND_ALONE ] )
{
case MAX_STAND_ALONE:
{
Achievement( iVictim, STAND_ALONE, -1 )
}
}
DelBit( StandAlone, iVictim )
}



if( get_user_health( iKiller ) == 1 )
{
SetBit( OneHpHero, iKiller )
}

if( GetBit( OneHpHero, iKiller ) )
{
g_iAchLevel[ iKiller ][ ONE_HP_HERO ]++
switch( g_iAchLevel[ iKiller ][ ONE_HP_HERO ] )
{
case MAX_ONE_HP_HERO:
{
Achievement( iKiller, ONE_HP_HERO, -1 )
}
}
}

if( cs_get_user_team( iKiller ) == iTeam )
{
g_iAchLevel[ iKiller ][ BAD_FRIEND ]++
switch( g_iAchLevel[ iKiller ][ BAD_FRIEND ] )
{
case MAX_BAD_FRIEND:
{
Achievement( iKiller, BAD_FRIEND, -1 )
}
}
}

if( GetBit( iKillerHasNotMoved, iKiller ) )
{
g_iKills[ iKiller ]++
if( g_iKills[ iKiller ] >= 3 )
{

g_iAchLevel[ iKiller ][ CAMP_FIRE ]++
switch( g_iAchLevel[ iKiller ][ CAMP_FIRE ] )
{
case MAX_CAMP_FIRE:
{
Achievement( iKiller, CAMP_FIRE, -1 )
}
}
}
}

return PLUGIN_HANDLED
}

public Event_Spray( )
{
new iPlayer = read_data( 2 );

#if defined USING_REGEX
if( !IsUserAuthorized( iPlayer ) )
{
return PLUGIN_HANDLED
}
#endif

g_iAchLevel[ iPlayer ][ URBAN_DESIGNER ]++
switch( g_iAchLevel[ iPlayer ][ URBAN_DESIGNER ] )
{
case MAX_URBAN_DESIGNER:
{
Achievement( iPlayer, URBAN_DESIGNER, -1 )
}
}

g_iRoundSparys[ iPlayer ]++

if( g_iRoundSparys[ iPlayer ] == 3 )
{
g_iAchLevel[ iPlayer ][ GRAFFITI ]++
switch( g_iAchLevel[ iPlayer ][ GRAFFITI ] )
{
case MAX_GRAFFITI:
{
Achievement( iPlayer, GRAFFITI, -1 )
}
}
}
#if defined USING_REGEX
return PLUGIN_HANDLED
#endif
}

public Achievement( id, ACH_ITEM, ACH_WEAPON )
{
new szName[ 32 ]; get_user_name( id, szName, charsmax( szName ) )
new g_pCvarGet_Message = get_pcvar_num( g_pCvar_Message )
if( g_pCvarGet_Message == 2 )
{
new g_iPlayers[ 32 ], iPlayer, iNum
get_players( g_iPlayers, iNum )
for ( new i=0; i<iNum; i++ )
{
iPlayer = g_iPlayers[ i ]
if( id == iPlayer )
continue
Print( iPlayer, "^4%s^3 %s^1 has earned ^3'^1%s^3'^4 achievement!", g_szAchievementTag, szName, ACH_ITEM >= 0 ? g_iAchsMotd[ ACH_ITEM ] : g_iAchsWeap[ ACH_WEAPON ] )
}
}
if( g_pCvarGet_Message == 1 || g_pCvarGet_Message == 2 )
Print( id, "^4%s^3 You^1 have earned ^3'^1%s^3'^4 achievement!", g_szAchievementTag, ACH_ITEM >= 0 ? g_iAchsMotd[ ACH_ITEM ] : g_iAchsWeap[ ACH_WEAPON ] )

if( get_pcvar_num( g_pCvar_PlaySound ) == 1 )
client_cmd( id, "spk ^"sound/achieve.wav^"" )

new g_pCvarGet_Reward = get_pcvar_num( g_pCvar_Reward )
if( g_pCvarGet_Reward > 0 )
cs_set_user_money( id, cs_get_user_money( id ) + g_pCvarGet_Reward, 1 )

g_iAchLevel[ id ][ COMPLETED_ACHIEVEMENTS ]++
}

public AchievementSecondary( id, ACH_ITEM )
{
new szName[ 32 ]; get_user_name( id, szName, charsmax( szName ) )
new g_pCvarGet_Message = get_pcvar_num( g_pCvar_Message )
if( g_pCvarGet_Message == 2 )
{
new g_iPlayers[ 32 ], iPlayer, iNum
get_players( g_iPlayers, iNum )
for ( new i=0; i<iNum; i++ )
{
iPlayer = g_iPlayers[ i ]
if( id == iPlayer )
continue
Print( iPlayer, "^4%s^3 %s^1 has earned ^3'^1%s^3'^4 achievement!", g_szAchievementTag, szName, g_iAchsSecondary[ ACH_ITEM ] )
}
}
if( g_pCvarGet_Message == 1 || g_pCvarGet_Message == 2 )
Print( id, "^4%s^3 You^1 have earned ^3'^1%s^3'^4 achievement!", g_szAchievementTag, g_iAchsSecondary[ ACH_ITEM ] )

if( get_pcvar_num( g_pCvar_PlaySound ) == 1 )
client_cmd( id, "spk ^"sound/achieve.wav^"" )

new g_pCvarGet_Reward = get_pcvar_num( g_pCvar_Reward )
if( g_pCvarGet_Reward > 0 )
cs_set_user_money( id, cs_get_user_money( id ) + g_pCvarGet_Reward, 1 )

g_iAchLevel[ id ][ COMPLETED_ACHIEVEMENTS ]++
}

Print( index, const Msg[ ], { Float, Sql, Result, _ }:... ) {
new Buffer[ 190 ], Buffer2[ 192 ]
formatex( Buffer2, charsmax( Buffer2 ), "%s", Msg )
vformat( Buffer, charsmax( Buffer ), Buffer2, 3 )

if ( !index ) {

new g_iPlayers[ 32 ]
new iPlayer
new iNum
get_players( g_iPlayers, iNum )
for ( new i=0; i<iNum; i++ )
{
iPlayer = g_iPlayers[ i ]

message_begin( MSG_ONE_UNRELIABLE, g_iMsgSayText,_, iPlayer )
write_byte( iPlayer )
write_string( Buffer )
message_end( )
}
}
else {
if ( !GetBit( is_Connected, index ) )
return;

message_begin( MSG_ONE, g_iMsgSayText,_, index )
write_byte( index )
write_string( Buffer )
message_end( )
}
}

//#if defined USING_REGEX
IsValidAuthid( authid[] )
{
return ( regex_match_c( authid, g_SteamID_pattern, g_regex_return ) > 0 )
}
#if defined USING_REGEX
IsUserAuthorized( id )
{
return g_iAuthID[ id ][ 0 ] != 0
}
#endif

public g_iLoadStats( id )
{
#if defined USING_SQL
static query[ 128 ]
formatex( query, sizeof( query ) - 1, "SELECT data FROM Achievement WHERE authid = ^"%s^";", g_iAuthID[ id ] )

static data[ 2 ]
data[ 0 ] = id

SQL_ThreadQuery( g_sql_tuple, "QueryLoadData", query, data, sizeof( data ) )

#else
static data[ 256 ], timestamp
if( nvault_lookup( g_iVault, g_iAuthID[ id ], data, sizeof( data ) - 1, timestamp ) )
{
ParseLoadData( id, data )
return//
}
else
{
NewUser( id )
}
#endif
}

public NewUser( id )
{

for( new iLevel = 0; iLevel < g_iAchCount; iLevel++ )
{
g_iAchLevel[ id ][ iLevel ] = 0
}

for( new i = 0; i < WEAPON_SIZE; i++ )
{
g_iPlayersKills[ id ][ g_iWeaponIDs[ i ] ] = 0
}

}

#if defined USING_SQL
public QueryLoadData( failstate, Handle:query, error[], errnum, data[], size, Float:queuetime )
{
if( failstate == TQUERY_CONNECT_FAILED
|| failstate == TQUERY_QUERY_FAILED )
{
set_fail_state( error )
}
else
{
if( SQL_NumResults( query ) )
{
static sqldata[ 256 ]
SQL_ReadResult( query, 0, sqldata, sizeof( sqldata ) - 1 )
ParseLoadData( data[0], sqldata )
}
else
{
NewUser( data[ 0 ] )
}
}
}
#endif

ParseLoadData( id, data[ 256 ] )
{
new num[ 6 ]

for( new i = 0; i < WEAPON_SIZE; i++ )
{
strbreak( data, num, sizeof( num ) - 1, data, sizeof( data ) - 1 )
g_iPlayersKills[ id ][ g_iWeaponIDs[ i ] ] = clamp( str_to_num( num ), 0, g_iAchsWeaponMaxKills[ i ] )
}

for( new iLevel = 0; iLevel < g_iAchCount; iLevel++ )
{
strbreak( data, num, sizeof( num ) - 1, data, sizeof( data ) - 1 )
g_iAchLevel[ id ][ iLevel ] = clamp( str_to_num( num ), 0, g_iAchsMaxPoints[ iLevel ] )
}

#if defined USING_SQL
g_loaded_data[ id ] = 1
#endif
}

public g_iSaveStats( id )
{
#if defined USING_REGEX
if( !IsUserAuthorized( id ) ) return
#endif

static data[ 256 ]
new len

for( new i = 0; i < WEAPON_SIZE; i++ )
{
len += formatex( data[ len ], sizeof( data ) - len - 1, " %i", g_iPlayersKills[ id ][ g_iWeaponIDs[ i ] ] )
}

for( new iLevel = 0; iLevel < g_iAchCount; iLevel++ )
{
len += formatex( data[ len ], sizeof( data ) - len - 1, " %i", g_iAchLevel[ id ][ iLevel ] )
}

#if defined USING_SQL
static name[ 32 ]; get_user_name( id, name, charsmax( name ) )

static query[ 256 ]
if( g_loaded_data[ id ] )
{
formatex( query, sizeof( query ) - 1, "UPDATE Achievement SET name = ^"%s^", data = ^"%s^" WHERE authid = ^"%s^";", name, data, g_iAuthID[ id ] )
}
else
{
formatex( query, sizeof( query ) - 1, "INSERT INTO Achievement ( name, authid, data ) VALUES ( ^"%s^", ^"%s^", ^"%s^" );", name, g_iAuthID[ id ], data )
}

SQL_ThreadQuery( g_sql_tuple, "QuerySaveData", query )
#else
nvault_set( g_iVault, g_iAuthID[ id ], data )
#endif
}

#if defined USING_SQL
public QuerySaveData( failstate, Handle:query, error[], errnum, data[], size, Float:queuetime )
{
if( failstate == TQUERY_CONNECT_FAILED
|| failstate == TQUERY_QUERY_FAILED )
{
set_fail_state( error )
}
}
#endif

elf01

Пользователь
Регистрация
24 Мар 2018
Сообщения
153
Симпатии
7
Пол
Мужской
#3
elf01,
Пробуй (ничего не менял - стандарт)
А вы откомпилировали то, что я скинул? Или их с сайта. Я тут пару команд вызова, типо /help, закоментил. И кварам свои значения поставил.
Походу дело в компиляторе гадопакосном. Блин с офа качал же. Дома точ такой. На рабочем компе не компилет, а дома на ноуте нормально.
 

hooligan***

Пользователь
Регистрация
9 Июн 2017
Сообщения
355
Симпатии
101
Пол
Мужской
#5
Расскажите пожалуйста поподробнее про плагин, какие у него возможности?
Неплохо было бы создать плагин достижений как в го, или этот оптимизировать в плане сократить библиотеки
 

elf01

Пользователь
Регистрация
24 Мар 2018
Сообщения
153
Симпатии
7
Пол
Мужской
#6
elf01, убрать

Для компила на 1.8.3
Я вкурсе, но если убрать будут ошибки. По этому не трогал.
7 Июн 2018
Расскажите пожалуйста поподробнее про плагин, какие у него возможности?
Неплохо было бы создать плагин достижений как в го, или этот оптимизировать в плане сократить библиотеки
В посте есть ссылка, там прочтите