Try this version.
PHP Code:
#include < amxmodx >
#include < amxmisc >
#include < cstrike >
#include < engine >
#include < fun >
#include < fakemeta >
#include < hamsandwich >
new const PLUGIN_NAME[ ] = "HideNSeek";
new const PLUGIN_VERS[ ] = "3.0.0";
new const PLUGIN_AUTH[ ] = "Exolent";
const FFADE_IN = 0x0000;
const m_pPlayer = 41;
const OFFSET_WEAPONS = 4;
const m_iHideHUD = 361;
const HIDE_MONEY = ( 1 << 5 );
const m_pActiveItem = 373;
enum // StatusValue flags for first argument
{
SV_FLAG_TEAMMATE = 1,
SV_FLAG_PLAYERID,
SV_FLAG_PLAYERHP
};
enum // StatusValue values for the SV_FLAG_TEAMMATE flag
{
SV_TEAMVALUE_FRIEND = 1,
SV_TEAMVALUE_ENEMY,
SV_TEAMVALUE_HOSTAGE
};
enum NadeTypes
{
NADE_HE,
NADE_FL,
NADE_SM
};
new const g_szNadeNames[ NadeTypes ][ ] =
{
"HE Grenade",
"Flashbang",
"Smoke Grenade"
};
new const g_iNadeIds[ NadeTypes ] =
{
CSW_HEGRENADE,
CSW_FLASHBANG,
CSW_SMOKEGRENADE
};
new const g_iNadeLimit[ NadeTypes ] =
{
1,
2,
1
};
new const g_szNadeWeaponNames[ NadeTypes ][ ] =
{
"weapon_hegrenade",
"weapon_flashbang",
"weapon_smokegrenade"
};
enum NadeInfo
{
NADE_COUNT,
NADE_CHANCE
};
enum ArmorInfo
{
ARMOR_VALUE,
CsArmorType:ARMOR_TYPE
};
new const g_szTeamToCvar[ CsTeams ][ ] =
{
"",
"hider",
"seeker",
""
};
new const g_szNadeTypeToCvar[ NadeTypes ][ ] =
{
"grenade",
"flash",
"smoke"
};
new const g_szNadeInfoToCvar[ NadeInfo ][ ] =
{
"count",
"chance"
};
new const g_szArmorInfoToCvar[ ArmorInfo ][ ] =
{
"value",
"type"
};
enum
{
R,
G,
B,
A
};
enum ( += 1000 )
{
TASK_ID_BLANK = 0,
TASK_ID_HIDETIMER,
TASK_ID_SWAPTEAMS,
TASK_ID_CHECKMODEL,
TASK_ID_GIVEWEAPONS,
TASK_ID_PLUGININFO
};
new const g_iPlayerTasks[ ] =
{
TASK_ID_CHECKMODEL,
TASK_ID_GIVEWEAPONS,
TASK_ID_PLUGININFO
};
new g_iHideTimer;
const SWAP_PER_INTERVAL = 5;
const Float:SWAP_INTERVAL = 0.5;
new g_iSwapStartIndex;
new bool:g_bSpawnedOnce[ 33 ];
new bool:g_bWeaponsGiven;
new g_iRoundsLost;
new bool:g_bDisableSlash = true;
new Trie:g_tTeamModels[ CsTeams ];
new Trie:g_tRemoveEntities;
new g_iMsgId_SayText;
new g_iMsgId_ScoreInfo;
new g_iMsgId_ScreenFade;
new g_iMsgId_StatusText;
new g_iMsgId_StatusValue;
new g_iMaxPlayers;
new pCvar_NoSlow;
new pCvar_HideTime;
new pCvar_Money;
new pCvar_SilentFeet;
new pCvar_NubSlash;
new pCvar_TimerSpeech;
new pCvar_DisableKill;
new pCvar_HiderSurviveFrags;
new pCvar_GameType;
new pCvar_ChatPrefix;
new pCvar_ColorHud;
new pCvar_ColorBlind;
new pCvar_HiderKnifeVisible;
new pCvar_NadeInfo[ CsTeams ][ NadeTypes ][ NadeInfo ];
new pCvar_ArmorInfo[ CsTeams ][ ArmorInfo ];
/* Cached cvar variables + their default values */
new bool:g_bNoSlow = false;
new g_iHideTime = 10;
new g_iMoneyValue = 0; // -1 = don't change money, 0 = hide money and set to 0, > 0 = set to that value
new g_iSilentFeet = ( 1 << _:CS_TEAM_T );
new g_iNubSlashRounds = 3; // 0 to allow slashing, -1 for forever disable slashing
new bool:g_bTimerSpeech = true;
new bool:g_bDisableKillCommand = true;
new g_iHiderSurviveFrags = 1;
new g_szGameType[ 32 ] = "HideNSeek";
new g_szChatPrefix[ 16 ] = "[ HNS ]";
new g_iHudColors[ 3 ] =
{
0, // Red
255, // Green
0 // Blue
};
new g_iBlindColors[ 4 ] =
{
0, // Red
0, // Green
0, // Blue
255 // Alpha
};
new bool:g_bVisibleTerrKnife = true;
new g_iNadeInfo[ CsTeams ][ NadeTypes ][ NadeInfo ] =
{
// Spectator
{
// HE
{
0, // Count
0 // Chance
},
// Flash
{
0, // Count
0 // Chance
},
// Smoke
{
0, // Count
0 // Chance
}
},
// Hider
{
// HE
{
1, // Count
100 // Chance
},
// Flash
{
2, // Count
100 // Chance
},
// Smoke
{
1, // Count
100 // Chance
}
},
// Seeker
{
// HE
{
0, // Count
0 // Chance
},
// Flash
{
0, // Count
0 // Chance
},
// Smoke
{
0, // Count
0 // Chance
}
},
// Spectator
{
// HE
{
0, // Count
0 // Chance
},
// Flash
{
0, // Count
0 // Chance
},
// Smoke
{
0, // Count
0 // Chance
}
}
};
new g_iArmorInfo[ CsTeams ][ ArmorInfo ] =
{
// Spectator
{
// Value
0,
// Type
CS_ARMOR_NONE
},
// Hider
{
// Value
100,
// Type
CS_ARMOR_VESTHELM
},
// Seeker
{
// Value
100,
// Type
CS_ARMOR_VESTHELM
},
// Spectator
{
// Value
0,
// Type
CS_ARMOR_NONE
}
};
/* End of cvars */
RegisterCvars( )
{
new szValue[ 32 ];
num_to_str( _:g_bNoSlow, szValue, 31 );
pCvar_NoSlow = register_cvar( "hns_noslow", szValue );
num_to_str( g_iHideTime, szValue, 31 );
pCvar_HideTime = register_cvar( "hns_hidetime", szValue );
num_to_str( g_iMoneyValue, szValue, 31 );
pCvar_Money = register_cvar( "hns_money", szValue );
num_to_str( g_iSilentFeet, szValue, 31 );
pCvar_SilentFeet = register_cvar( "hns_silentfeet", szValue );
num_to_str( g_iNubSlashRounds, szValue, 31 );
pCvar_NubSlash = register_cvar( "hns_nubslash", szValue );
num_to_str( _:g_bTimerSpeech, szValue, 31 );
pCvar_TimerSpeech = register_cvar( "hns_timer_speech", szValue );
num_to_str( _:g_bDisableKillCommand, szValue, 31 );
pCvar_DisableKill = register_cvar( "hns_disable_kill", szValue );
num_to_str( g_iHiderSurviveFrags, szValue, 31 );
pCvar_HiderSurviveFrags = register_cvar( "hns_hider_survive_frags", szValue );
pCvar_GameType = register_cvar( "hns_gametype", g_szGameType );
pCvar_ChatPrefix = register_cvar( "hns_chat_prefix", g_szChatPrefix );
new iLen;
for( new i = 0; i < sizeof( g_iHudColors ); i++ )
{
iLen += formatex( szValue[ iLen ], 31 - iLen, "%s%i", iLen ? " " : "", g_iHudColors[ i ] );
}
pCvar_ColorHud = register_cvar( "hns_color_hud", szValue );
iLen = 0;
for( new i = 0; i < sizeof( g_iBlindColors ); i++ )
{
iLen += formatex( szValue[ iLen ], 31 - iLen, "%s%i", iLen ? " " : "", g_iBlindColors[ i ] );
}
pCvar_ColorBlind = register_cvar( "hns_color_blind", szValue );
num_to_str( _:g_bVisibleTerrKnife, szValue, 31 );
pCvar_HiderKnifeVisible = register_cvar( "hns_hider_knife_visible", szValue );
new NadeTypes:iNadeType, NadeInfo:iNadeInfo, szCvar[ 64 ];
for( new CsTeams:iTeam = CS_TEAM_T; iTeam <= CS_TEAM_CT; iTeam++ )
{
for( iNadeType = NadeTypes:0; iNadeType < NadeTypes; iNadeType++ )
{
for( iNadeInfo = NadeInfo:0; iNadeInfo < NadeInfo; iNadeInfo++ )
{
formatex( szCvar, 63, "hns_%s_%s_%s", g_szTeamToCvar[ iTeam ], g_szNadeTypeToCvar[ iNadeType ], g_szNadeInfoToCvar[ iNadeInfo ] );
num_to_str( g_iNadeInfo[ iTeam ][ iNadeType ][ iNadeInfo ], szValue, 31 );
pCvar_NadeInfo[ iTeam ][ iNadeType ][ iNadeInfo ] = register_cvar( szCvar, szValue );
}
}
}
new ArmorInfo:iArmorInfo;
for( new CsTeams:iTeam = CS_TEAM_T; iTeam <= CS_TEAM_CT; iTeam++ )
{
for( iArmorInfo = ArmorInfo:0; iArmorInfo < ArmorInfo; iArmorInfo++ )
{
formatex( szCvar, 63, "hns_%s_armor_%s", g_szTeamToCvar[ iTeam ], g_szArmorInfoToCvar[ iArmorInfo ] );
num_to_str( g_iArmorInfo[ iTeam ][ iArmorInfo ], szValue, 31 );
pCvar_ArmorInfo[ iTeam ][ iArmorInfo ] = register_cvar( szCvar, szValue );
}
}
}
CacheCvars( )
{
static szColor[ 16 ], szPart[ 4 ], i, CsTeams:iTeam, NadeTypes:iNadeType, NadeInfo:iNadeInfo, ArmorInfo:iArmorInfo;
g_bNoSlow = bool:get_pcvar_num( pCvar_NoSlow );
g_iHideTime = get_pcvar_num( pCvar_HideTime );
g_iMoneyValue = get_pcvar_num( pCvar_Money );
g_bVisibleTerrKnife = bool:get_pcvar_num( pCvar_HiderKnifeVisible );
g_iSilentFeet = get_pcvar_num( pCvar_SilentFeet );
g_iNubSlashRounds = get_pcvar_num( pCvar_NubSlash );
g_bTimerSpeech = bool:get_pcvar_num( pCvar_TimerSpeech );
g_bDisableKillCommand = bool:get_pcvar_num( pCvar_DisableKill );
g_iHiderSurviveFrags = get_pcvar_num( pCvar_HiderSurviveFrags );
get_pcvar_string( pCvar_GameType, g_szGameType, 31 );
get_pcvar_string( pCvar_ChatPrefix, g_szChatPrefix, 15 );
get_pcvar_string( pCvar_ColorHud, szColor, 15 );
//parse( szColor, szParts[ R ], 3, szParts[ G ], 3, szParts[ B ], 3 );
for( i = 0; i < sizeof( g_iHudColors ); i++ )
{
strbreak( szColor, szPart, 3, szColor, 15 );
g_iHudColors[ i ] = clamp( str_to_num( szPart ), 0, 255 );
}
get_pcvar_string( pCvar_ColorBlind, szColor, 15 );
//parse( szColor, szParts[ R ], 3, szParts[ G ], 3, szParts[ B ], 3, szParts[ A ], 3 );
for( i = 0; i < sizeof( g_iBlindColors ); i++ )
{
strbreak( szColor, szPart, 3, szColor, 15 );
g_iBlindColors[ i ] = clamp( str_to_num( szPart ), 0, 255 );
}
for( iTeam = CS_TEAM_T; iTeam <= CS_TEAM_CT; iTeam++ )
{
for( iNadeType = NadeTypes:0; iNadeType < NadeTypes; iNadeType++ )
{
for( iNadeInfo = NadeInfo:0; iNadeInfo < NadeInfo; iNadeInfo++ )
{
g_iNadeInfo[ iTeam ][ iNadeType ][ iNadeInfo ] = get_pcvar_num( pCvar_NadeInfo[ iTeam ][ iNadeType ][ iNadeInfo ] );
}
}
for( iArmorInfo = ArmorInfo:0; iArmorInfo < ArmorInfo; iArmorInfo++ )
{
g_iArmorInfo[ iTeam ][ iArmorInfo ] = get_pcvar_num( pCvar_ArmorInfo[ iTeam ][ iArmorInfo ] );
}
}
}
public plugin_precache( )
{
new iEntity = create_entity( "hostage_entity" );
entity_set_origin( iEntity, Float:{ 0.0, 0.0, -55000.0 } );
entity_set_size( iEntity, Float:{ -1.0, -1.0, -1.0 }, Float:{ 1.0, 1.0, 1.0 } );
DispatchSpawn( iEntity );
iEntity = create_entity( "player_weaponstrip" );
DispatchKeyValue( iEntity, "targetname", "stripper" );
DispatchSpawn( iEntity );
iEntity = create_entity( "game_player_equip" );
DispatchKeyValue( iEntity, "weapon_knife", "1" );
DispatchKeyValue( iEntity, "targetname", "equipment" );
iEntity = create_entity( "multi_manager" );
DispatchKeyValue( iEntity, "stripper", "0" );
DispatchKeyValue( iEntity, "equipment", "0.5" );
DispatchKeyValue( iEntity, "targetname", "game_playerspawn" );
DispatchKeyValue( iEntity, "spawnflags", "1" );
DispatchSpawn( iEntity );
iEntity = create_entity( "info_map_parameters" );
DispatchKeyValue( iEntity, "buying", "3" );
DispatchSpawn( iEntity );
new const szRemoveEntities[][] =
{
"func_bomb_target",
"info_bomb_target",
"hostage_entity",
"monster_scientist",
"func_hostage_rescue",
"info_hostage_rescue",
"info_vip_start",
"func_vip_safetyzone",
"func_escapezone",
"armoury_entity",
"info_map_parameters",
"player_weaponstrip",
"game_player_equip",
"func_buyzone"
};
g_tRemoveEntities = TrieCreate( );
for( new i = 0; i < sizeof( szRemoveEntities ); i++ )
{
TrieSetCell( g_tRemoveEntities, szRemoveEntities[ i ], i );
}
register_forward( FM_Spawn, "FwdSpawn" );
}
public FwdSpawn( iEntity )
{
static szClassname[ 32 ];
entity_get_string( iEntity, EV_SZ_classname, szClassname, 31 );
if( TrieKeyExists( g_tRemoveEntities, szClassname ) )
{
remove_entity( iEntity );
return FMRES_SUPERCEDE;
}
return FMRES_IGNORED;
}
public pfn_keyvalue( iEntity )
{
static szClassname[ 32 ], szKey[ 32 ], szValue[ 32 ];
copy_keyvalue( szClassname, 31, szKey, 31, szValue, 31 );
if( equal( szClassname, "multi_manager" )
&& equal( szKey, "targetname" )
&& equal( szValue, "game_playerspawn" ) )
{
remove_entity( iEntity );
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}
public plugin_init( )
{
register_plugin( PLUGIN_NAME, PLUGIN_VERS, PLUGIN_AUTH );
register_cvar( PLUGIN_NAME, PLUGIN_VERS, ( FCVAR_SERVER | FCVAR_SPONLY ) );
register_event( "HLTV", "EventNewRound", "a", "1=0", "2=0" );
register_event( "TextMsg", "EventRoundRestart", "a", "2&#Game_C", "2&#Game_w" );
register_event( "SendAudio", "EventHidersWin", "a", "2=%!MRAD_terwin" );
register_event( "ResetHUD", "EventResetHud", "be" );
register_event( "Money", "EventMoney", "be" );
register_logevent( "EventRoundStart", 2, "1=Round_Start" );
register_logevent( "EventRoundEnd", 2, "1=Round_End" );
RegisterHam( Ham_Item_Deploy, "weapon_knife", "FwdKnifeDeploy", 1 );
RegisterHam( Ham_Weapon_PrimaryAttack, "weapon_knife", "FwdKnifePrimAttack" );
RegisterHam( Ham_Weapon_SecondaryAttack, "weapon_knife", "FwdKnifeSecAttack" );
RegisterHam( Ham_Spawn, "player", "FwdPlayerSpawn", 1 );
register_forward( FM_GetGameDescription, "FwdGetGameDescription" );
g_iMsgId_SayText = get_user_msgid( "SayText" );
g_iMsgId_ScoreInfo = get_user_msgid( "ScoreInfo" );
g_iMsgId_ScreenFade = get_user_msgid( "ScreenFade" );
g_iMsgId_StatusText = get_user_msgid( "StatusText" );
g_iMsgId_StatusValue = get_user_msgid( "StatusValue" );
set_msg_block( get_user_msgid( "HostagePos" ), BLOCK_SET );
set_msg_block( g_iMsgId_StatusText, BLOCK_SET );
set_msg_block( g_iMsgId_StatusValue, BLOCK_SET );
register_message( get_user_msgid( "HideWeapon" ), "MessageHideWeapon" );
register_message( g_iMsgId_ScreenFade, "MessageScreenFade" );
register_message( get_user_msgid( "TextMsg" ), "MessageTextMsg" );
RegisterCvars( );
g_iMaxPlayers = get_maxplayers( );
new const szTeamModels[ CsTeams ][ 4 ][ ] =
{
{ "", "", "", "" },
{ "leet", "arctic", "terror", "guerilla" },
{ "gign", "sas", "gsg9", "urban" },
{ "", "", "", "" }
};
new i;
for( new CsTeams:iTeam = CS_TEAM_T; iTeam <= CS_TEAM_CT; iTeam++ )
{
g_tTeamModels[ iTeam ] = TrieCreate( );
for( i = 0; i < 4; i++ )
{
TrieSetCell( g_tTeamModels[ iTeam ], szTeamModels[ iTeam ][ i ], 1 );
}
}
}
public plugin_end( )
{
for( new CsTeams:iTeam = CS_TEAM_T; iTeam <= CS_TEAM_CT; iTeam++ )
{
TrieDestroy( g_tTeamModels[ iTeam ] );
}
}
public client_disconnect( client )
{
static i;
for( i = 0; i < sizeof( g_iPlayerTasks ); i++ )
{
remove_task( client + g_iPlayerTasks[ i ] );
}
g_bSpawnedOnce[ client ] = false;
}
public client_PreThink( client )
{
if( is_user_alive( client ) )
{
if( g_bNoSlow )
{
entity_set_float( client, EV_FL_fuser2, 0.0 );
}
static CsTeams:iTeam;
iTeam = cs_get_user_team( client );
if( g_iSilentFeet & ( 1 << _:iTeam ) )
{
entity_set_int( client, EV_INT_flTimeStepSound, 999 );
}
if( iTeam == CS_TEAM_CT )
{
if( g_iHideTimer > 0 )
{
entity_set_float( client, EV_FL_maxspeed, -1.0 );
static Float:vVelocity[ 3 ];
entity_get_vector( client, EV_VEC_velocity, vVelocity );
vVelocity[ 0 ] = 0.0;
vVelocity[ 1 ] = 0.0;
entity_set_vector( client, EV_VEC_velocity, vVelocity );
set_user_godmode( client, 1 );
}
else if( g_iHideTimer == 0 )
{
set_user_godmode( client, 0 );
}
}
static iTarget, iBody;
get_user_aiming( client, iTarget, iBody );
static iOldTarget[ 33 ], iResetCount[ 33 ];
if( ( 1 <= iTarget <= g_iMaxPlayers ) && is_user_alive( iTarget ) )
{
static iOld, bool:bIsTeammate;
iOld = iOldTarget[ client ];
bIsTeammate = bool:( cs_get_user_team( iTarget ) == iTeam );
if( !iOld )
{
if( bIsTeammate )
{
UTIL_StatusValue( client, SV_FLAG_TEAMMATE, SV_TEAMVALUE_FRIEND );
}
else
{
UTIL_StatusValue( client, SV_FLAG_TEAMMATE, SV_TEAMVALUE_ENEMY );
}
}
if( iOld != iTarget )
{
iOldTarget[ client ] = iTarget;
UTIL_StatusValue( client, SV_FLAG_PLAYERID, iTarget );
}
if( !iOld )
{
if( bIsTeammate )
{
static szMessage[ 192 ];
formatex( szMessage, 191, "Friend: %%p2 - Health: %i%%%%", get_user_health( iTarget ) );
UTIL_StatusText( client, szMessage );
}
else
{
UTIL_StatusText( client, "Enemy: %p2" );
}
}
}
else if( iOldTarget[ client ] )
{
iOldTarget[ client ] = 0;
iResetCount[ client ] = 100;
}
else if( iResetCount[ client ] > 0 && --iResetCount[ client ] == 0 )
{
UTIL_StatusValue( client, SV_FLAG_PLAYERID, 0 );
UTIL_StatusText( client, "" );
}
}
}
public client_kill( client )
{
if( g_bDisableKillCommand )
{
static Float:fLastMessage[ 33 ], Float:fGametime;
fGametime = get_gametime( );
if( fLastMessage[ client ] >= ( fGametime + 1.0 ) )
{
console_print( client, "You cannot kill yourself in HideNSeek!" );
PrintChat( client, "You^3 cannot kill yourself^1 in HideNSeek!" );
fLastMessage[ client ] = fGametime;
}
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}
public EventNewRound( )
{
CacheCvars( );
if( g_bDisableSlash
&& ( g_iRoundsLost >= g_iNubSlashRounds > 0 || !g_iNubSlashRounds ) )
{
g_bDisableSlash = false;
if( g_iNubSlashRounds )
{
PrintChat( 0, "The seekers have^3 lost %i round%s^1 and can now^3 use slash^1!", g_iNubSlashRounds, g_iNubSlashRounds == 1 ? "" : "s" );
}
}
else if( !g_bDisableSlash && g_iNubSlashRounds == -1 )
{
g_bDisableSlash = true;
}
g_bWeaponsGiven = false;
}
public EventRoundRestart( )
{
g_iHideTimer = -1;
g_iRoundsLost = 0;
g_bDisableSlash = true;
}
public EventHidersWin( )
{
if( g_bDisableSlash )
{
g_iRoundsLost++;
}
if( g_iHiderSurviveFrags )
{
static i, iFrags;
for( i = 1; i <= g_iMaxPlayers; i++ )
{
if( is_user_alive( i ) && cs_get_user_team( i ) == CS_TEAM_T )
{
iFrags = get_user_frags( i ) + g_iHiderSurviveFrags;
set_user_frags( i, iFrags );
UTIL_ScoreInfo( i, iFrags, cs_get_user_deaths( i ), CS_TEAM_T );
PrintChat( i, "You earned^3 %i frag%s^1 for surviving the round!", g_iHiderSurviveFrags, g_iHiderSurviveFrags == 1 ? "" : "s" );
}
}
}
}
public EventResetHud( client )
{
if( !g_iMoneyValue )
{
UTIL_HideWeapon( client, HIDE_MONEY );
}
}
public EventMoney( client )
{
if( g_iMoneyValue >= 0 )
{
cs_set_user_money( client, g_iMoneyValue, _:( g_iMoneyValue > 0 ) );
if( !g_iMoneyValue )
{
UTIL_HideWeapon( client, HIDE_MONEY );
}
}
}
public EventRoundStart( )
{
remove_task( TASK_ID_HIDETIMER );
g_iHideTimer = g_iHideTime;
TaskHideTimer( );
}
public EventRoundEnd( )
{
remove_task( TASK_ID_HIDETIMER );
}
public FwdKnifeDeploy( iEntity )
{
if( !g_bVisibleTerrKnife )
{
static client;
client = get_pdata_cbase( iEntity, m_pPlayer, OFFSET_WEAPONS );
if( cs_get_user_team( client ) == CS_TEAM_T )
{
entity_set_string( client, EV_SZ_viewmodel, "" );
entity_set_string( client, EV_SZ_weaponmodel, "" );
}
}
}
public FwdKnifePrimAttack( iEntity )
{
static client;
client = get_pdata_cbase( iEntity, m_pPlayer, OFFSET_WEAPONS );
if( is_user_alive( client ) )
{
switch( cs_get_user_team( client ) )
{
case CS_TEAM_T:
{
return HAM_SUPERCEDE;
}
case CS_TEAM_CT:
{
if( g_bDisableSlash )
{
ExecuteHamB( Ham_Weapon_SecondaryAttack, iEntity );
return HAM_SUPERCEDE;
}
}
}
}
return HAM_IGNORED;
}
public FwdKnifeSecAttack( iEntity )
{
static client;
client = get_pdata_cbase( iEntity, m_pPlayer, OFFSET_WEAPONS );
if( is_user_alive( client ) && cs_get_user_team( client ) == CS_TEAM_T )
{
return HAM_SUPERCEDE;
}
return HAM_IGNORED;
}
public FwdPlayerSpawn( client )
{
if( is_user_alive( client ) )
{
static CsTeams:iTeam;
iTeam = cs_get_user_team( client );
if( iTeam == CS_TEAM_T || iTeam == CS_TEAM_CT )
{
static iParams[ 2 ];
iParams[ 0 ] = _:iTeam;
set_task( 0.3, "TaskCheckModel", client + TASK_ID_CHECKMODEL, iParams, 2 );
if( g_bWeaponsGiven )
{
set_task( 0.6, "TaskGiveWeapons", client + TASK_ID_GIVEWEAPONS, iParams, 2 );
}
}
if( !g_bSpawnedOnce[ client ] )
{
TaskShowPluginInfo( client + TASK_ID_PLUGININFO );
g_bSpawnedOnce[ client ] = true;
}
}
}
public FwdGetGameDescription( )
{
if( g_szGameType[ 0 ] )
{
forward_return( FMV_STRING, g_szGameType );
return FMRES_SUPERCEDE;
}
return FMRES_IGNORED;
}
public MessageHideWeapon( iMsgId, iDest, client )
{
if( !g_iMoneyValue )
{
set_msg_arg_int( 1, ARG_BYTE, ( get_msg_arg_int( 1 ) | HIDE_MONEY ) );
//UTIL_HideWeapon( client, HIDE_MONEY );
}
}
public MessageScreenFade( iMsgId, iDest, client )
{
if( get_msg_arg_int( 4 ) == 255
&& get_msg_arg_int( 5 ) == 255
&& get_msg_arg_int( 6 ) == 255 )
{
switch( cs_get_user_team( client ) )
{
case CS_TEAM_T:
{
return PLUGIN_HANDLED;
}
case CS_TEAM_CT:
{
if( g_iHideTimer > 0 )
{
return PLUGIN_HANDLED;
}
}
}
}
return PLUGIN_CONTINUE;
}
public MessageTextMsg( iMsgId, iDest, client )
{
static const szTerroristMessage[ ] = "#Terrorists_Win";
static const szHostageMessage[ ] = "#Hostages_Not_Rescued";
static const szCTMessage[ ] = "#CTs_Win";
static szMessage[ 192 ];
get_msg_arg_string( 2, szMessage, 31 );
if( equal( szMessage, szTerroristMessage )
|| equal( szMessage, szHostageMessage ) )
{
set_msg_arg_string( 2, "Hiders Win!" );
copy( szMessage, 191, "Hiders Won Round^nNo Team Change" );
}
else if( equal( szMessage, szCTMessage ) )
{
set_msg_arg_string( 2, "Seekers Win!" );
copy( szMessage, 191, "Seekers Won Round^nSwitching Teams" );
SwapTeams( );
}
else
{
return;
}
set_hudmessage( g_iHudColors[ R ], g_iHudColors[ G ], g_iHudColors[ B ], -1.0, -1.0, 0, 0.0, 5.0, 0.1, 0.1, 1 );
show_hudmessage( 0, "%s", szMessage );
}
public TaskHideTimer( )
{
if( g_iHideTimer > 0 )
{
static iHider, iSeeker;
GetHiderAndSeeker( iHider, iSeeker );
if( !iHider || !iSeeker )
{
g_iHideTimer = 0;
}
}
static CsTeams:iTeam, client;
if( g_iHideTimer > 0 )
{
static szSound[ 16 ];
if( g_bTimerSpeech )
{
num_to_word( g_iHideTimer, szSound, 15 );
}
for( client = 1; client <= g_iMaxPlayers; client++ )
{
if( is_user_connected( client ) )
{
iTeam = cs_get_user_team( client );
if( iTeam == CS_TEAM_T || iTeam == CS_TEAM_CT )
{
if( iTeam == CS_TEAM_CT && is_user_alive( client ) )
{
UTIL_ScreenFade( client, 1.5, g_iBlindColors[ R ], g_iBlindColors[ G ], g_iBlindColors[ B ], g_iBlindColors[ A ] );
}
set_hudmessage( g_iHudColors[ R ], g_iHudColors[ G ], g_iHudColors[ B ], -1.0, -1.0, 0, 0.0, 1.1, 0.1, 0.1, 1 );
show_hudmessage( client, "Hiders have %i second%s to hide!", g_iHideTimer, g_iHideTimer == 1 ? "" : "s" );
if( g_bTimerSpeech )
{
client_cmd( client, "spk vox/%s.wav", szSound );
}
}
}
}
}
else if( g_iHideTimer == 0 )
{
static iParams[ 2 ];
for( client = 1; client <= g_iMaxPlayers; client++ )
{
if( is_user_connected( client ) )
{
iTeam = cs_get_user_team( client );
if( iTeam == CS_TEAM_T || iTeam == CS_TEAM_CT )
{
if( iTeam == CS_TEAM_CT && is_user_alive( client ) )
{
UTIL_ScreenFade( client, 0.0, 0, 0, 0, 0 );
ResetMaxspeed( client );
}
set_hudmessage( g_iHudColors[ R ], g_iHudColors[ G ], g_iHudColors[ B ], -1.0, -1.0, 0, 0.0, 1.1, 0.1, 0.1, 1 );
show_hudmessage( client, "Ready or not, Here we come!" );
iParams[ 0 ] = _:iTeam;
TaskGiveWeapons( iParams, client + TASK_ID_GIVEWEAPONS );
}
}
}
g_bWeaponsGiven = true;
}
else
{
for( client = 1; client <= g_iMaxPlayers; client++ )
{
if( is_user_connected( client ) )
{
if( is_user_alive( client ) && cs_get_user_team( client ) == CS_TEAM_CT )
{
UTIL_ScreenFade( client, 0.0, 0, 0, 0, 0 );
ResetMaxspeed( client );
}
}
}
return;
}
g_iHideTimer--;
set_task( 1.0, "TaskHideTimer", TASK_ID_HIDETIMER );
}
public TaskSwapTeams( )
{
static iCount, client;
iCount = 0;
for( client = g_iSwapStartIndex; client <= g_iMaxPlayers; client++ )
{
if( is_user_connected( client ) )
{
if( iCount >= SWAP_PER_INTERVAL )
{
g_iSwapStartIndex = client;
set_task( SWAP_INTERVAL, "TaskSwapTeams", TASK_ID_SWAPTEAMS );
return;
}
switch( cs_get_user_team( client ) )
{
case CS_TEAM_T:
{
cs_set_user_team( client, CS_TEAM_CT, CS_CT_GIGN );
iCount++;
}
case CS_TEAM_CT:
{
cs_set_user_team( client, CS_TEAM_T, CS_T_LEET );
iCount++;
}
}
}
}
}
public TaskCheckModel( iParams[ ], iTaskId )
{
static CsTeams:iTeam, client;
iTeam = CsTeams:iParams[ 0 ];
client = iTaskId - TASK_ID_CHECKMODEL;
static szModel[ 32 ];
cs_get_user_model( client, szModel, 31 );
if( !TrieKeyExists( g_tTeamModels[ iTeam ], szModel ) )
{
static const szDefaultModels[ CsTeams ][ ] =
{
"",
"leet",
"gign",
""
};
cs_set_user_model( client, szDefaultModels[ iTeam ] );
}
}
public TaskGiveWeapons( iParams[ ], iTaskId )
{
static CsTeams:iTeam, client;
iTeam = CsTeams:iParams[ 0 ];
client = iTaskId - TASK_ID_GIVEWEAPONS;
static NadeTypes:iNade, iLimit, iGiveMax, iChance, iTries, iGiven;
for( iNade = NadeTypes:0; iNade < NadeTypes; iNade++ )
{
iLimit = g_iNadeLimit[ iNade ];
iGiveMax = g_iNadeInfo[ iTeam ][ iNade ][ NADE_COUNT ];
iChance = g_iNadeInfo[ iTeam ][ iNade ][ NADE_CHANCE ];
iGiven = 0;
for( iTries = 0; iTries < iGiveMax; iTries++ )
{
if( iChance == 100 || random_num( 1, 100 ) <= iChance )
{
iGiven++;
}
}
if( iGiven )
{
for( iTries = 0; iTries < iGiven; iTries++ )
{
if( iTries < iLimit )
{
give_item( client, g_szNadeWeaponNames[ iNade ] );
}
else
{
cs_set_user_bpammo( client, g_iNadeIds[ iNade ], iGiven );
break;
}
}
if( iChance != 100 )
{
PrintChat( client, "You received^3 %i^1 of^3 %i %s%s^1! (%i%% chance per)",\
iGiven,\
iGiveMax,\
g_szNadeNames[ iNade ],\
iGiveMax == 1 ? "" : "s",\
iChance
);
}
}
}
cs_set_user_armor( client, g_iArmorInfo[ iTeam ][ ARMOR_VALUE ], g_iArmorInfo[ iTeam ][ ARMOR_TYPE ] );
}
public TaskShowPluginInfo( iTaskId )
{
PrintChat( iTaskId - TASK_ID_PLUGININFO, "This server is using^3 %s^4 v%s^1, by^3 %s^1!", PLUGIN_NAME, PLUGIN_VERS, PLUGIN_AUTH );
set_task( 360.0, "TaskShowPluginInfo", iTaskId );
}
GetHiderAndSeeker( &iHider, &iSeeker, &iHiderAlive=0 )
{
iHider = 0;
iSeeker = 0;
iHiderAlive = 0;
static i;
for( i = 1; i <= g_iMaxPlayers; i++ )
{
if( is_user_connected( i ) )
{
switch( cs_get_user_team( i ) )
{
case CS_TEAM_T:
{
if( !iHider )
{
iHider = i;
if( !iHiderAlive && is_user_alive( i ) )
{
iHiderAlive = i;
if( iSeeker )
{
return 1;
}
}
}
}
case CS_TEAM_CT:
{
if( !iSeeker )
{
iSeeker = i;
if( iHider && iHiderAlive )
{
return 1;
}
}
}
}
}
}
return 0;
}
SwapTeams( )
{
g_iRoundsLost = 0;
g_bDisableSlash = true;
g_iSwapStartIndex = 1;
TaskSwapTeams( );
}
ResetMaxspeed( const client )
{
static Float:fMaxSpeed;
// Jon
ExecuteHamB( Ham_CS_Item_GetMaxSpeed, get_pdata_cbase( client, m_pActiveItem ), fMaxSpeed );
/*switch( get_user_weapon( client ) )
{
case CSW_SG550, CSW_AWP, CSW_G3SG1:
{
fMaxSpeed = 210.0;
}
case CSW_M249:
{
fMaxSpeed = 220.0;
}
case CSW_AK47:
{
fMaxSpeed = 221.0;
}
case CSW_M3, CSW_M4A1:
{
fMaxSpeed = 230.0;
}
case CSW_SG552:
{
fMaxSpeed = 235.0;
}
case CSW_XM1014, CSW_AUG, CSW_GALIL, CSW_FAMAS:
{
fMaxSpeed = 240.0;
}
case CSW_P90:
{
fMaxSpeed = 245.0;
}
case CSW_SCOUT:
{
fMaxSpeed = 260.0;
}
default:
{
fMaxSpeed = 250.0;
}
}*/
entity_set_float( client, EV_FL_maxspeed, fMaxSpeed );
}
SecondsToScreenFadeUnits( const Float:fSeconds, const bool:bClamp=true )
{
static iUnits;
iUnits = floatround( fSeconds * float( 1 << 12 ) );
if( bClamp )
{
iUnits = clamp( iUnits, 0, 0xFFFF );
}
return iUnits;
}
PrintChat( const client, const szMessageFormat[ ], any:... )
{
static szMessage[ 192 ], iLen;
iLen = formatex( szMessage, 191, "^4%s^1 ", g_szChatPrefix );
vformat( szMessage[ iLen ], 191 - iLen, szMessageFormat, 3 );
if( client )
{
UTIL_SayText( client, client, szMessage );
}
else
{
static i;
for( i = 1; i <= g_iMaxPlayers; i++ )
{
if( is_user_connected( i ) )
{
UTIL_SayText( i, i, szMessage );
}
}
}
}
UTIL_HideWeapon( const client, const iFlags )
{
set_pdata_int( client, m_iHideHUD, ( get_pdata_int( client, m_iHideHUD ) | iFlags ) );
}
UTIL_SayText( const iReceiver, const iSender, const szMessage[ ] )
{
message_begin( iReceiver ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, g_iMsgId_SayText, _, iReceiver );
write_byte( iSender );
write_string( szMessage );
message_end( );
}
UTIL_ScoreInfo( const client, const iFrags, const iDeaths, const CsTeams:iTeam )
{
message_begin( MSG_BROADCAST, g_iMsgId_ScoreInfo );
write_byte( client );
write_short( iFrags );
write_short( iDeaths );
write_short( 0 );
write_short( _:iTeam );
message_end( );
}
UTIL_ScreenFade( const client, const Float:fDuration, const iRed, const iGreen, const iBlue, const iAlpha )
{
message_begin( client ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, g_iMsgId_ScreenFade, _, client );
write_short( SecondsToScreenFadeUnits( fDuration ) );
write_short( SecondsToScreenFadeUnits( fDuration * 0.75 ) );
write_short( FFADE_IN );
write_byte( iRed );
write_byte( iGreen );
write_byte( iBlue );
write_byte( iAlpha );
message_end( );
}
UTIL_StatusText( const client, const szMessage[ ] )
{
message_begin( client ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, g_iMsgId_StatusText, _, client );
write_byte( 0 );
write_string( szMessage );
message_end( );
}
UTIL_StatusValue( const client, const iFlag, const iValue )
{
message_begin( client ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, g_iMsgId_StatusValue, _, client );
write_byte( iFlag );
write_short( iValue );
message_end( );
}