PHP Code:
#include < amxmodx >
#include < cstrike >
#include < fun >
#include < fakemeta >
#include < hamsandwich >
new const SPY_CHANCE = 5;
new const SPY_MODEL[ ] = "";
new const SPY_WEAPONS[ ] = {
CSW_KNIFE,
CSW_ELITE
};
new const SPY_HEALTH = 100;
new const g_szWeaponClassnames[ ][ ] =
{
"",
"weapon_p228",
"",
"weapon_scout",
"weapon_hegrenade",
"weapon_xm1014",
"weapon_c4",
"weapon_mac10",
"weapon_aug",
"weapon_smokegrenade",
"weapon_elite",
"weapon_fiveseven",
"weapon_ump45",
"weapon_sg550",
"weapon_galil",
"weapon_famas",
"weapon_usp",
"weapon_glock18",
"weapon_awp",
"weapon_mp5navy",
"weapon_m249",
"weapon_m3",
"weapon_m4a1",
"weapon_tmp",
"weapon_g3sg1",
"weapon_flashbang",
"weapon_deagle",
"weapon_sg552",
"weapon_ak47",
"weapon_knife",
"weapon_p90"
};
enum AmmoTypes
{
AMMO_CLIP,
AMMO_BACKPACK
};
new const g_iWeaponMaxAmmo[ sizeof( g_szWeaponClassnames ) ][ AmmoTypes ] =
{
{ 0, 0 },
{ 13, 52 },
{ 0, 0 },
{ 10, 90 },
{ 0, 0 },
{ 7, 32 },
{ 0, 0 },
{ 30, 100 },
{ 30, 90 },
{ 0, 0 },
{ 30, 120 },
{ 20, 100 },
{ 25, 100 },
{ 30, 90 },
{ 35, 90 },
{ 25, 90 },
{ 12, 100 },
{ 20, 120 },
{ 10, 30 },
{ 30, 120 },
{ 100, 200 },
{ 8, 32 },
{ 30, 90 },
{ 30, 120 },
{ 20, 90 },
{ 0, 0 },
{ 7, 35 },
{ 30, 90 },
{ 30, 90 },
{ 0, 0 },
{ 50, 100 }
};
new bool:g_bSpy;
new g_iMsgId_TeamInfo;
public plugin_precache( ) {
new szModel[ 128 ];
formatex( szModel, 127, "models/player/%s/%s.mdl", SPY_MODEL, SPY_MODEL );
precache_model( szModel );
}
public plugin_init( ) {
register_plugin( "T Spy", "0.0.1", "Exolent" );
register_event( "HLTV", "EventNewRound", "a", "1=0", "2=0" );
RegisterHam( Ham_Spawn, "player", "FwdPlayerSpawn", 1 );
g_iMsgId_TeamInfo = get_user_msgid( "TeamInfo" );
}
public EventNewRound( ) {
g_bSpy = false;
}
public FwdPlayerSpawn( iPlayer ) {
if( !g_bSpy
&& is_user_alive( iPlayer )
&& cs_get_user_team( iPlayer ) == CS_TEAM_T ) {
if( random_num( 1, 100 ) <= SPY_CHANCE ) {
g_bSpy = true;
new iBlock = get_msg_block( g_iMsgId_TeamInfo );
set_msg_block( g_iMsgId_TeamInfo, BLOCK_SET );
fm_cs_set_user_team( iPlayer, CS_TEAM_CT );
ExecuteHamB( Ham_CS_RoundRespawn, iPlayer );
fm_cs_set_user_team( iPlayer, CS_TEAM_T );
set_msg_block( g_iMsgId_TeamInfo, iBlock );
cs_set_user_model( iPlayer, SPY_MODEL );
strip_user_weapons( iPlayer );
new iWeapon, iEntity, iAmmo;
for( new i = 0; i < sizeof( SPY_WEAPONS ); i++ ) {
iWeapon = SPY_WEAPONS[ i ];
iEntity = give_item( iPlayer, g_szWeaponClassnames[ iWeapon ] );
iAmmo = g_iWeaponMaxAmmo[ iWeapon ][ AMMO_CLIP ];
if( iAmmo ) {
cs_set_weapon_ammo( iEntity, iAmmo );
}
iAmmo = g_iWeaponMaxAmmo[ iWeapon ][ AMMO_BACKPACK ];
if( iAmmo ) {
cs_set_user_bpammo( iPlayer, iWeapon, iAmmo );
}
}
set_user_health( iPlayer, SPY_HEALTH );
client_print( iPlayer, print_center, "You are a SPY! (%i%% chance)", SPY_CHANCE );
}
}
}
// ConnorMcLeod
fm_cs_set_user_team(id, {CsTeams,_}:iTeam, {CsInternalModel,_}:iModel = CsInternalModel:CS_DONTCHANGE)
{
static const OFFSET_TEAM = 114;
static const OFFSET_INTERNALMODEL = 126;
if( iTeam > CS_TEAM_SPECTATOR )
return;
set_pdata_int(id, OFFSET_TEAM, _:iTeam);
if( iModel )
{
set_pdata_int(id, OFFSET_INTERNALMODEL, _:iModel);
}
dllfunc(DLLFunc_ClientUserInfoChanged, id, engfunc(EngFunc_GetInfoKeyBuffer, id));
static const szTeams[] = { "UNASSIGNED" , "TERRORIST" , "CT" , "SPECTATOR" };
emessage_begin(MSG_ALL, g_iMsgId_TeamInfo);
ewrite_byte(id);
ewrite_string(szTeams[_:iTeam]);
emessage_end();
}