2018-09-12 16:43:07 +02:00
# pragma semicolon 1
2018-07-23 14:09:42 +02:00
# include <sourcemod>
# include <sdkhooks>
# include <sdktools>
2018-09-12 16:43:07 +02:00
# include <multicolors>
2018-07-23 14:09:42 +02:00
# include <zombiereloaded>
# pragma newdecls required
2018-09-12 16:43:07 +02:00
/* CONVARS */
ConVar g_hCVar_CollectablesEnabled ;
ConVar g_hCVar_RandomIntervalMin ;
ConVar g_hCVar_RandomIntervalMax ;
ConVar g_hCVar_InfectionEffectEnabled ;
ConVar g_hCVar_MilestoneInfection ;
ConVar g_hCVar_MilestoneGrenade ;
ConVar g_hCVar_MilestoneSkin ;
ConVar g_hCVar_HighscoreDisplay ;
ConVar g_hCVar_PlayerRequirement ;
ConVar g_hCVar_EntityLimit ;
/* DATABASE */
Database g_hDatabase ;
/* BOOLS */
2018-07-23 14:09:42 +02:00
bool g_bEnabled = true ;
2018-09-12 16:43:07 +02:00
bool g_bPreAdminChecked [ MAXPLAYERS + 1 ] ;
bool g_bResponseFailed [ MAXPLAYERS + 1 ] ;
bool g_bResponsePassed [ MAXPLAYERS + 1 ] ;
2018-07-23 14:09:42 +02:00
2018-09-12 16:43:07 +02:00
/* INTEGERS */
int g_iCollected [ MAXPLAYERS + 1 ] ;
int g_iCounter = 0 ;
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
2018-07-23 17:06:03 +02:00
public Plugin myinfo =
2018-07-23 14:09:42 +02:00
{
2018-10-03 12:39:37 +02:00
name = " UNLOZE Season Event (XMAS) " ,
2018-07-23 17:06:03 +02:00
author = " Neon " ,
2018-10-03 12:39:37 +02:00
description = " UNLOZE Season Event (XMAS) " ,
2018-09-12 16:43:07 +02:00
version = " 2.0 " ,
2018-07-23 17:06:03 +02:00
url = " https://steamcommunity.com/id/n3ontm "
2018-07-23 14:09:42 +02:00
} ;
2018-09-12 16:43:07 +02:00
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
2018-07-23 14:09:42 +02:00
public void OnPluginStart ( )
2018-07-23 17:06:03 +02:00
{
2018-09-12 16:43:07 +02:00
g_hCVar_CollectablesEnabled = CreateConVar ( " sm_unloze_season_collectables_enabled " , " 1 " , " Spawn Collectables. " , 0 , true , 0.0 , true , 1.0 ) ;
g_hCVar_RandomIntervalMin = CreateConVar ( " sm_unloze_season_random_interval_min " , " 60 " , " Minimum Interval between spawning Collectables. " , 0 , true , 0.0 ) ;
g_hCVar_RandomIntervalMax = CreateConVar ( " sm_unloze_season_random_interval_max " , " 120 " , " Maximum Interval between spawning Collectables. " , 0 , true , 0.0 ) ;
g_hCVar_InfectionEffectEnabled = CreateConVar ( " sm_unloze_season_infection_effect_enabled " , " 1 " , " Spawn Props on Infection. " , 0 , true , 0.0 , true , 1.0 ) ;
g_hCVar_MilestoneInfection = CreateConVar ( " sm_unloze_season_milestone_infection " , " 25 " , " Amount of Collectables you need to unlock the Infection Effect. " , 0 , true , 0.0 ) ;
g_hCVar_MilestoneGrenade = CreateConVar ( " sm_unloze_season_milestone_grenade " , " 75 " , " Amount of Collectables you need to unlock the Grenade Skin. " , 0 , true , 0.0 ) ;
g_hCVar_MilestoneSkin = CreateConVar ( " sm_unloze_season_milestone_skin " , " 150 " , " Amount of Collectables you need to unlock the Skin(s). " , 0 , true , 0.0 ) ;
g_hCVar_HighscoreDisplay = CreateConVar ( " sm_unloze_season_highscore_display " , " 5 " , " Amount of Players to display via sm_highscore " , 0 , true , 0.0 ) ;
g_hCVar_PlayerRequirement = CreateConVar ( " sm_unloze_season_player_requirement " , " 10 " , " Amount of Players needed to spawn Collectables. " , 0 , true , 0.0 ) ;
g_hCVar_EntityLimit = CreateConVar ( " sm_unloze_season_entity_limit " , " 2000 " , " Entity Safety Limit. " , 0 , true , 0.0 ) ;
2018-07-23 17:06:03 +02:00
HookEvent ( " round_start " , OnRoundStart , EventHookMode_Post ) ;
2018-09-12 16:43:07 +02:00
2018-10-03 12:39:37 +02:00
RegConsoleCmd ( " sm_presents " , Command_Collected , " Shows the total amount of Presents you have collected so far " ) ;
2018-11-28 12:44:34 +01:00
RegConsoleCmd ( " sm_xmas " , Command_Collected , " Shows the total amount of Presents you have collected so far " ) ;
2018-10-03 12:39:37 +02:00
RegConsoleCmd ( " sm_highscore " , Command_HighScore , " Shows the Present HighScore " ) ;
2018-09-12 16:43:07 +02:00
AutoExecConfig ( ) ;
char sError [ 256 ] ;
if ( SQL_CheckConfig ( " season " ) )
g_hDatabase = SQL_Connect ( " season " , true , sError , sizeof ( sError ) ) ;
if ( g_hDatabase = = null )
LogError ( " Could not connect to database: %s " , sError ) ;
2018-07-23 14:09:42 +02:00
}
2018-09-12 16:43:07 +02:00
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
2018-07-23 14:09:42 +02:00
public void OnMapStart ( )
2018-07-23 17:06:03 +02:00
{
2018-07-23 14:09:42 +02:00
AddFileToDownloadsTable ( " models/player/stenli/smite/fenrir.phy " ) ;
AddFileToDownloadsTable ( " models/player/stenli/smite/fenrir.sw.vtx " ) ;
AddFileToDownloadsTable ( " models/player/stenli/smite/fenrir.vvd " ) ;
AddFileToDownloadsTable ( " models/player/stenli/smite/fenrir.dx80.vtx " ) ;
AddFileToDownloadsTable ( " models/player/stenli/smite/fenrir.dx90.vtx " ) ;
2018-07-23 17:06:03 +02:00
AddFileToDownloadsTable ( " models/player/stenli/smite/fenrir.mdl " ) ;
2018-07-23 14:09:42 +02:00
AddFileToDownloadsTable ( " materials/models/player/stenli/smite/fenrir/body.vmt " ) ;
AddFileToDownloadsTable ( " materials/models/player/stenli/smite/fenrir/body.vtf " ) ;
AddFileToDownloadsTable ( " materials/models/player/stenli/smite/fenrir/body_n.vtf " ) ;
AddFileToDownloadsTable ( " materials/models/player/stenli/smite/fenrir/body_s.vtf " ) ;
AddFileToDownloadsTable ( " materials/models/player/stenli/smite/fenrir/lights.vmt " ) ;
PrecacheModel ( " models/player/stenli/smite/fenrir.mdl " ) ;
2018-07-23 17:06:03 +02:00
2018-07-23 14:09:42 +02:00
AddFileToDownloadsTable ( " models/player/vad36lollipop/lolli_new.vvd " ) ;
AddFileToDownloadsTable ( " models/player/vad36lollipop/lolli_new.dx80.vtx " ) ;
AddFileToDownloadsTable ( " models/player/vad36lollipop/lolli_new.dx90.vtx " ) ;
AddFileToDownloadsTable ( " models/player/vad36lollipop/lolli_new.mdl " ) ;
AddFileToDownloadsTable ( " models/player/vad36lollipop/lolli_new.phy " ) ;
2018-07-23 17:06:03 +02:00
AddFileToDownloadsTable ( " models/player/vad36lollipop/lolli_new.sw.vtx " ) ;
2018-07-23 14:09:42 +02:00
AddFileToDownloadsTable ( " materials/models/player/vad36lollipop/tx_ch_main_juliet_skin_d_cos11.vtf " ) ;
AddFileToDownloadsTable ( " materials/models/player/vad36lollipop/tx_ch_main_juliet_skin_n_cos11.vtf " ) ;
AddFileToDownloadsTable ( " materials/models/player/vad36lollipop/hat.vmt " ) ;
AddFileToDownloadsTable ( " materials/models/player/vad36lollipop/hat.vtf " ) ;
AddFileToDownloadsTable ( " materials/models/player/vad36lollipop/hat_n.vtf " ) ;
AddFileToDownloadsTable ( " materials/models/player/vad36lollipop/tx_ch_main_juliet_cloth.vmt " ) ;
AddFileToDownloadsTable ( " materials/models/player/vad36lollipop/tx_ch_main_juliet_cloth.vtf " ) ;
AddFileToDownloadsTable ( " materials/models/player/vad36lollipop/tx_ch_main_juliet_cloth_n.vtf " ) ;
AddFileToDownloadsTable ( " materials/models/player/vad36lollipop/tx_ch_main_juliet_hair_d_cos11.vmt " ) ;
AddFileToDownloadsTable ( " materials/models/player/vad36lollipop/tx_ch_main_juliet_hair_d_cos11.vtf " ) ;
AddFileToDownloadsTable ( " materials/models/player/vad36lollipop/tx_ch_main_juliet_hair_n_cos11.vtf " ) ;
AddFileToDownloadsTable ( " materials/models/player/vad36lollipop/tx_ch_main_juliet_skin_d_cos11.vmt " ) ;
PrecacheModel ( " models/player/vad36lollipop/lolli_new.mdl " ) ;
2018-07-23 17:06:03 +02:00
2018-07-23 14:09:42 +02:00
AddFileToDownloadsTable ( " models/player/vad36santa/red.dx80.vtx " ) ;
AddFileToDownloadsTable ( " models/player/vad36santa/red.dx90.vtx " ) ;
AddFileToDownloadsTable ( " models/player/vad36santa/red.mdl " ) ;
AddFileToDownloadsTable ( " models/player/vad36santa/red.phy " ) ;
AddFileToDownloadsTable ( " models/player/vad36santa/red.sw.vtx " ) ;
2018-07-23 17:06:03 +02:00
AddFileToDownloadsTable ( " models/player/vad36santa/red.vvd " ) ;
2018-07-23 14:09:42 +02:00
AddFileToDownloadsTable ( " materials/models/player/vad36santa/Santa_N.vtf " ) ;
AddFileToDownloadsTable ( " materials/models/player/vad36santa/Santa_D.vmt " ) ;
AddFileToDownloadsTable ( " materials/models/player/vad36santa/Santa_D.vtf " ) ;
AddFileToDownloadsTable ( " materials/models/player/vad36santa/Santa_D_B.vmt " ) ;
AddFileToDownloadsTable ( " materials/models/player/vad36santa/Santa_D_B.vtf " ) ;
PrecacheModel ( " models/player/vad36santa/red.mdl " ) ;
2018-07-23 17:06:03 +02:00
2018-07-23 14:09:42 +02:00
AddFileToDownloadsTable ( " models/zombieden/xmas/giftbox.dx80.vtx " ) ;
AddFileToDownloadsTable ( " models/zombieden/xmas/giftbox.dx90.vtx " ) ;
AddFileToDownloadsTable ( " models/zombieden/xmas/giftbox.mdl " ) ;
AddFileToDownloadsTable ( " models/zombieden/xmas/giftbox.phy " ) ;
AddFileToDownloadsTable ( " models/zombieden/xmas/giftbox.sw.vtx " ) ;
AddFileToDownloadsTable ( " models/zombieden/xmas/giftbox.vvd " ) ;
AddFileToDownloadsTable ( " materials/models/zombieden/xmas/gift.vmt " ) ;
AddFileToDownloadsTable ( " materials/models/zombieden/xmas/gift.vtf " ) ;
AddFileToDownloadsTable ( " materials/models/zombieden/xmas/gift_2.vmt " ) ;
AddFileToDownloadsTable ( " materials/models/zombieden/xmas/gift_2.vtf " ) ;
AddFileToDownloadsTable ( " materials/models/zombieden/xmas/gift_lightwarp.vtf " ) ;
PrecacheModel ( " models/zombieden/xmas/giftbox.mdl " ) ;
2018-07-23 17:06:03 +02:00
2018-07-23 14:09:42 +02:00
AddFileToDownloadsTable ( " models/models_kit/xmas/xmastree_mini.dx80.vtx " ) ;
AddFileToDownloadsTable ( " models/models_kit/xmas/xmastree_mini.dx90.vtx " ) ;
AddFileToDownloadsTable ( " models/models_kit/xmas/xmastree_mini.mdl " ) ;
AddFileToDownloadsTable ( " models/models_kit/xmas/xmastree_mini.phy " ) ;
AddFileToDownloadsTable ( " models/models_kit/xmas/xmastree_mini.sw.vtx " ) ;
AddFileToDownloadsTable ( " models/models_kit/xmas/xmastree_mini.vvd " ) ;
AddFileToDownloadsTable ( " materials/models/models_kit/xmas/xmastree_misca.vmt " ) ;
AddFileToDownloadsTable ( " materials/models/models_kit/xmas/xmastree_misca.vtf " ) ;
AddFileToDownloadsTable ( " materials/models/models_kit/xmas/xmastree_misca_skin2.vmt " ) ;
AddFileToDownloadsTable ( " materials/models/models_kit/xmas/xmastree_misca_skin2.vtf " ) ;
AddFileToDownloadsTable ( " materials/models/models_kit/xmas/xmastree_miscb.vmt " ) ;
AddFileToDownloadsTable ( " materials/models/models_kit/xmas/xmastree_miscb.vtf " ) ;
AddFileToDownloadsTable ( " materials/models/models_kit/xmas/xmastree_miscb_skin2.vmt " ) ;
AddFileToDownloadsTable ( " materials/models/models_kit/xmas/xmastree_miscb_skin2.vtf " ) ;
AddFileToDownloadsTable ( " materials/models/models_kit/xmas/xmastree_miscb_spec.vtf " ) ;
PrecacheModel ( " models/models_kit/xmas/xmastree_mini.mdl " ) ;
2018-07-23 17:06:03 +02:00
2018-07-23 14:09:42 +02:00
AddFileToDownloadsTable ( " models/models_kit/xmas/xmas_teddybear.dx80.vtx " ) ;
AddFileToDownloadsTable ( " models/models_kit/xmas/xmas_teddybear.dx90.vtx " ) ;
AddFileToDownloadsTable ( " models/models_kit/xmas/xmas_teddybear.mdl " ) ;
AddFileToDownloadsTable ( " models/models_kit/xmas/xmas_teddybear.phy " ) ;
AddFileToDownloadsTable ( " models/models_kit/xmas/xmas_teddybear.sw.vtx " ) ;
AddFileToDownloadsTable ( " models/models_kit/xmas/xmas_teddybear.vvd " ) ;
AddFileToDownloadsTable ( " materials/models/models_kit/xmas/xmastree_misca.vmt " ) ;
AddFileToDownloadsTable ( " materials/models/models_kit/xmas/xmastree_misca.vtf " ) ;
AddFileToDownloadsTable ( " materials/models/models_kit/xmas/xmastree_misca_skin2.vmt " ) ;
AddFileToDownloadsTable ( " materials/models/models_kit/xmas/xmastree_misca_skin2.vtf " ) ;
AddFileToDownloadsTable ( " materials/models/models_kit/xmas/xmastree_miscb.vmt " ) ;
AddFileToDownloadsTable ( " materials/models/models_kit/xmas/xmastree_miscb.vtf " ) ;
AddFileToDownloadsTable ( " materials/models/models_kit/xmas/xmastree_miscb_skin2.vmt " ) ;
AddFileToDownloadsTable ( " materials/models/models_kit/xmas/xmastree_miscb_skin2.vtf " ) ;
AddFileToDownloadsTable ( " materials/models/models_kit/xmas/xmastree_miscb_spec.vtf " ) ;
PrecacheModel ( " models/models_kit/xmas/xmas_teddybear.mdl " ) ;
AddFileToDownloadsTable ( " models/weapons/w_revenge_xmas_candy.dx80.vtx " ) ;
AddFileToDownloadsTable ( " models/weapons/w_revenge_xmas_candy.dx90.vtx " ) ;
AddFileToDownloadsTable ( " models/weapons/w_revenge_xmas_candy.mdl " ) ;
AddFileToDownloadsTable ( " models/weapons/w_revenge_xmas_candy.phy " ) ;
AddFileToDownloadsTable ( " models/weapons/w_revenge_xmas_candy.sw.vtx " ) ;
AddFileToDownloadsTable ( " models/weapons/w_revenge_xmas_candy.vvd " ) ;
AddFileToDownloadsTable ( " materials/models/weapons/v_models/xmas_candy/cane.vmt " ) ;
2018-07-23 17:06:03 +02:00
AddFileToDownloadsTable ( " materials/models/weapons/v_models/xmas_candy/cane.vtf " ) ;
2018-07-23 14:09:42 +02:00
PrecacheModel ( " models/weapons/w_revenge_xmas_candy.mdl " ) ;
2018-07-23 17:06:03 +02:00
2018-07-23 14:09:42 +02:00
AddFileToDownloadsTable ( " models/johny-srka/snowman.dx80.vtx " ) ;
AddFileToDownloadsTable ( " models/johny-srka/snowman.dx90.vtx " ) ;
AddFileToDownloadsTable ( " models/johny-srka/snowman.mdl " ) ;
AddFileToDownloadsTable ( " models/johny-srka/snowman.phy " ) ;
AddFileToDownloadsTable ( " models/johny-srka/snowman.sw.vtx " ) ;
AddFileToDownloadsTable ( " models/johny-srka/snowman.vvd " ) ;
AddFileToDownloadsTable ( " materials/models/johny-srka/black_felt.vmt " ) ;
AddFileToDownloadsTable ( " materials/models/johny-srka/black_felt.vtf " ) ;
AddFileToDownloadsTable ( " materials/models/johny-srka/fabricpatterns0017_m.vmt " ) ;
AddFileToDownloadsTable ( " materials/models/johny-srka/fabricpatterns0017_m.vtf " ) ;
AddFileToDownloadsTable ( " materials/models/johny-srka/snowfloor002a.vmt " ) ;
AddFileToDownloadsTable ( " materials/models/johny-srka/snowfloor002a.vtf " ) ;
AddFileToDownloadsTable ( " materials/models/johny-srka/wood_old.vmt " ) ;
AddFileToDownloadsTable ( " materials/models/johny-srka/wood_old.vtf " ) ;
2018-07-23 17:06:03 +02:00
PrecacheModel ( " models/johny-srka/snowman.mdl " ) ;
2018-07-23 14:09:42 +02:00
AddFileToDownloadsTable ( " models/weapons/w_snowball_thrown.dx80.vtx " ) ;
AddFileToDownloadsTable ( " models/weapons/w_snowball_thrown.dx90.vtx " ) ;
AddFileToDownloadsTable ( " models/weapons/w_snowball_thrown.mdl " ) ;
AddFileToDownloadsTable ( " models/weapons/w_snowball_thrown.phy " ) ;
AddFileToDownloadsTable ( " models/weapons/w_snowball_thrown.sw.vtx " ) ;
AddFileToDownloadsTable ( " models/weapons/w_snowball_thrown.vvd " ) ;
AddFileToDownloadsTable ( " materials/models/weapons/v_models/snooball/s.vmt " ) ;
AddFileToDownloadsTable ( " materials/models/weapons/v_models/snooball/s.vtf " ) ;
2018-07-23 17:06:03 +02:00
AddFileToDownloadsTable ( " materials/models/weapons/v_models/snooball/s_norm.vtf " ) ;
2018-07-23 14:09:42 +02:00
PrecacheModel ( " models/weapons/w_snowball_thrown.mdl " ) ;
2018-07-23 17:06:03 +02:00
2018-07-23 14:09:42 +02:00
AddFileToDownloadsTable ( " models/weapons/w_ornament_thrown.dx80.vtx " ) ;
AddFileToDownloadsTable ( " models/weapons/w_ornament_thrown.dx90.vtx " ) ;
AddFileToDownloadsTable ( " models/weapons/w_ornament_thrown.mdl " ) ;
AddFileToDownloadsTable ( " models/weapons/w_ornament_thrown.phy " ) ;
AddFileToDownloadsTable ( " models/weapons/w_ornament_thrown.sw.vtx " ) ;
2018-07-23 17:06:03 +02:00
AddFileToDownloadsTable ( " models/weapons/w_ornament_thrown.vvd " ) ;
2018-07-23 14:09:42 +02:00
AddFileToDownloadsTable ( " materials/models/weapons/v_models/ornament/ornament.vmt " ) ;
AddFileToDownloadsTable ( " materials/models/weapons/v_models/ornament/ornament.vtf " ) ;
AddFileToDownloadsTable ( " materials/models/weapons/v_models/ornament/reflect.vtf " ) ;
2018-07-23 17:06:03 +02:00
PrecacheModel ( " models/weapons/w_ornament_thrown.mdl " ) ;
2018-07-23 14:09:42 +02:00
AddFileToDownloadsTable ( " models/weapons/w_santa_hat_thrown.dx80.vtx " ) ;
AddFileToDownloadsTable ( " models/weapons/w_santa_hat_thrown.dx90.vtx " ) ;
AddFileToDownloadsTable ( " models/weapons/w_santa_hat_thrown.mdl " ) ;
AddFileToDownloadsTable ( " models/weapons/w_santa_hat_thrown.phy " ) ;
AddFileToDownloadsTable ( " models/weapons/w_santa_hat_thrown.sw.vtx " ) ;
2018-07-23 17:06:03 +02:00
AddFileToDownloadsTable ( " models/weapons/w_santa_hat_thrown.vvd " ) ;
2018-07-23 14:09:42 +02:00
AddFileToDownloadsTable ( " materials/models/weapons/v_models/eq_fraggrenade/bonnet.vmt " ) ;
AddFileToDownloadsTable ( " materials/models/weapons/v_models/eq_fraggrenade/bonnet.vtf " ) ;
2018-07-23 17:06:03 +02:00
PrecacheModel ( " models/weapons/w_santa_hat_thrown.mdl " ) ;
2018-07-23 14:09:42 +02:00
AddFileToDownloadsTable ( " sound/unl1/season/hohohoho.wav " ) ;
2018-07-23 17:06:03 +02:00
PrecacheSound ( " sound/unl1/season/hohohoho.wav " ) ;
2018-11-28 12:44:34 +01:00
2018-07-23 14:09:42 +02:00
float fRandomInterval = GetRandomFloat ( GetConVarFloat ( g_hCVar_RandomIntervalMin ) , GetConVarFloat ( g_hCVar_RandomIntervalMax ) ) ;
CreateTimer ( fRandomInterval , SpawnCollectable , INVALID_HANDLE , TIMER_FLAG_NO_MAPCHANGE ) ;
}
2018-09-12 16:43:07 +02:00
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnRebuildAdminCache ( AdminCachePart part )
{
if ( part ! = AdminCache_Admins )
return ;
CreateTimer ( 1.0 , OnRebuildAdminCachePost , INVALID_HANDLE , TIMER_FLAG_NO_MAPCHANGE ) ;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action OnRebuildAdminCachePost ( Handle hTimer )
{
for ( int client = 1 ; client < = MaxClients ; client + + )
{
if ( g_bResponsePassed [ client ] & & g_bPreAdminChecked [ client ] )
CheckAndAddFlag ( client ) ;
}
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnClientConnected ( int client )
{
g_bPreAdminChecked [ client ] = false ;
g_bResponseFailed [ client ] = false ;
g_bResponsePassed [ client ] = false ;
g_iCollected [ client ] = 0 ;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnClientDisconnect ( int client )
{
g_bPreAdminChecked [ client ] = false ;
g_bResponseFailed [ client ] = false ;
g_bResponsePassed [ client ] = false ;
g_iCollected [ client ] = 0 ;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnClientAuthorized ( int client , const char [ ] sSteamID32 )
{
if ( IsFakeClient ( client ) )
return ;
char sSteamID [ 32 ] ;
GetClientAuthId ( client , AuthId_Steam2 , sSteamID , sizeof ( sSteamID ) ) ;
char sQuery [ 255 ] ;
2018-10-03 12:39:37 +02:00
Format ( sQuery , sizeof ( sQuery ) , " SELECT collected FROM xmas_table WHERE steam_auth = '%s' " , sSteamID ) ;
2018-09-12 16:43:07 +02:00
SQL_TQuery ( g_hDatabase , TQueryCBConnect , sQuery , GetClientUserId ( client ) ) ;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void TQueryCBConnect ( Handle owner , Handle rs , const char [ ] error , any data )
{
int client = 0 ;
if ( ( client = GetClientOfUserId ( data ) ) = = 0 )
return ;
if ( SQL_GetRowCount ( rs ) > 0 )
{
int iField ;
SQL_FetchRow ( rs ) ;
SQL_FieldNameToNum ( rs , " collected " , iField ) ;
g_iCollected [ client ] = SQL_FetchInt ( rs , iField ) ;
}
2018-10-03 12:28:58 +02:00
delete rs ;
2018-09-12 16:43:07 +02:00
g_bResponsePassed [ client ] = true ;
if ( g_bPreAdminChecked [ client ] )
NotifyPostAdminCheck ( client ) ;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action OnClientPreAdminCheck ( int client )
{
g_bPreAdminChecked [ client ] = true ;
if ( g_bResponsePassed [ client ] | | g_bResponseFailed [ client ] )
return Plugin_Continue ;
RunAdminCacheChecks ( client ) ;
return Plugin_Handled ;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
2018-07-23 14:09:42 +02:00
public void OnClientPostAdminFilter ( int client )
{
2018-09-12 16:43:07 +02:00
CheckAndAddFlag ( client ) ;
2018-07-23 14:09:42 +02:00
}
2018-09-12 16:43:07 +02:00
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
2018-07-23 14:09:42 +02:00
public void OnRoundStart ( Event hEvent , const char [ ] sEvent , bool bDontBroadcast )
2018-07-23 17:06:03 +02:00
{
2018-09-12 16:43:07 +02:00
g_iCounter = 0 ;
2018-07-23 14:09:42 +02:00
CreateTimer ( 10.0 , CheckPlayerCount , INVALID_HANDLE , TIMER_FLAG_NO_MAPCHANGE ) ;
}
2018-09-12 16:43:07 +02:00
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
2018-07-23 14:09:42 +02:00
public Action CheckPlayerCount ( Handle timer )
{
g_bEnabled = true ;
2018-09-12 16:43:07 +02:00
if ( GetClientCount ( true ) < g_hCVar_PlayerRequirement . IntValue )
2018-07-23 14:09:42 +02:00
{
g_bEnabled = false ;
2018-09-12 16:43:07 +02:00
CPrintToChatAll ( " {green}[UNLOZE XMAS] {white}Minimum Player Requirement to spawn Presents: {green}%d {white} - Currently online: {red}%d{white}. " , g_hCVar_PlayerRequirement . IntValue , GetClientCount ( true ) ) ;
2018-07-23 14:09:42 +02:00
}
}
2018-09-12 16:43:07 +02:00
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action Command_HighScore ( int client , int args )
2018-07-23 17:06:03 +02:00
{
2018-09-12 16:43:07 +02:00
char sQuery [ 255 ] ;
2018-10-03 12:39:37 +02:00
Format ( sQuery , sizeof ( sQuery ) , " SELECT * from xmas_table order by collected desc limit %d " , g_hCVar_HighscoreDisplay . IntValue ) ;
2018-09-12 16:43:07 +02:00
SQL_TQuery ( g_hDatabase , TQueryCBHighscore , sQuery , GetClientUserId ( client ) ) ;
2018-07-23 14:09:42 +02:00
return Plugin_Handled ;
}
2018-09-12 16:43:07 +02:00
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void TQueryCBHighscore ( Handle owner , Handle rs , const char [ ] error , any data )
2018-07-23 14:09:42 +02:00
{
2018-09-12 16:43:07 +02:00
int client = 0 ;
if ( ( client = GetClientOfUserId ( data ) ) = = 0 )
return ;
2018-07-23 17:06:03 +02:00
char sName [ MAX_NAME_LENGTH ] ;
2018-09-12 16:43:07 +02:00
char sBuffer [ 2048 ] = " {green}[UNLOZE XMAS] {white}TOP COLLECTORS: \n " ;
2018-07-23 14:09:42 +02:00
char sTempBuffer [ 1024 ] = " " ;
2018-07-23 17:06:03 +02:00
2018-09-12 16:43:07 +02:00
for ( int i = 1 ; i < = g_hCVar_HighscoreDisplay . IntValue ; i + + )
2018-07-23 14:09:42 +02:00
{
2018-09-12 16:43:07 +02:00
int iField ;
SQL_FetchRow ( rs ) ;
SQL_FieldNameToNum ( rs , " name " , iField ) ;
SQL_FetchString ( rs , iField , sName , sizeof ( sName ) ) ;
SQL_FieldNameToNum ( rs , " collected " , iField ) ;
int iCollected = SQL_FetchInt ( rs , iField ) ;
2018-07-23 17:06:03 +02:00
2018-07-23 14:09:42 +02:00
Format ( sTempBuffer , sizeof ( sTempBuffer ) , " {green}%d: %s - {red}%d \n " , i , sName , iCollected ) ;
2018-07-23 17:06:03 +02:00
StrCat ( sBuffer , sizeof ( sBuffer ) , sTempBuffer ) ;
}
2018-07-23 14:09:42 +02:00
delete rs ;
2018-09-12 16:43:07 +02:00
CPrintToChat ( client , sBuffer ) ;
2018-07-23 14:09:42 +02:00
}
2018-09-12 16:43:07 +02:00
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
2018-07-23 14:09:42 +02:00
public Action Command_Collected ( int client , int args )
{
2018-09-12 16:43:07 +02:00
char sSteamID [ 32 ] ;
GetClientAuthId ( client , AuthId_Steam2 , sSteamID , sizeof ( sSteamID ) ) ;
2018-07-23 14:09:42 +02:00
2018-09-12 16:43:07 +02:00
char sQuery [ 255 ] ;
2018-10-03 12:39:37 +02:00
Format ( sQuery , sizeof ( sQuery ) , " SELECT collected FROM xmas_table WHERE steam_auth = '%s' " , sSteamID ) ;
2018-09-12 16:43:07 +02:00
SQL_TQuery ( g_hDatabase , TQueryCBCollected , sQuery , GetClientUserId ( client ) ) ;
2018-07-23 14:09:42 +02:00
return Plugin_Handled ;
}
2018-09-12 16:43:07 +02:00
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void TQueryCBCollected ( Handle owner , Handle rs , const char [ ] error , any data )
2018-07-23 14:09:42 +02:00
{
2018-09-12 16:43:07 +02:00
int client = 0 ;
2018-07-23 17:06:03 +02:00
2018-09-12 16:43:07 +02:00
if ( ( client = GetClientOfUserId ( data ) ) = = 0 )
return ;
2018-07-23 17:06:03 +02:00
2018-09-12 16:43:07 +02:00
if ( SQL_GetRowCount ( rs ) > 0 )
2018-07-23 14:09:42 +02:00
{
int iField ;
2018-09-12 16:43:07 +02:00
SQL_FetchRow ( rs ) ;
SQL_FieldNameToNum ( rs , " collected " , iField ) ;
g_iCollected [ client ] = SQL_FetchInt ( rs , iField ) ;
2018-07-23 14:09:42 +02:00
}
2018-09-12 16:43:07 +02:00
else
g_iCollected [ client ] = 0 ;
2018-07-23 14:09:42 +02:00
delete rs ;
2018-09-12 16:43:07 +02:00
CPrintToChat ( client , " {green}[UNLOZE XMAS] {white}You have collected {green}%d {white}presents so far. " , g_iCollected [ client ] ) ;
if ( ( g_iCollected [ client ] > g_hCVar_MilestoneInfection . IntValue ) & & ( g_iCollected [ client ] > g_hCVar_MilestoneSkin . IntValue ) )
CPrintToChat ( client , " {green}[UNLOZE XMAS] {white}You have unlocked {red}all rewards{white} already. " ) ;
if ( g_iCollected [ client ] < g_hCVar_MilestoneInfection . IntValue )
CPrintToChat ( client , " {green}[UNLOZE XMAS] {white}You need to collect {green}%d {white}more presents to unlock {red}INFECTION EFFECTS{white}. " , g_hCVar_MilestoneInfection . IntValue - g_iCollected [ client ] ) ;
if ( g_iCollected [ client ] < g_hCVar_MilestoneGrenade . IntValue )
CPrintToChat ( client , " {green}[UNLOZE XMAS] {white}You need to collect {green}%d {white}more presents to unlock {red}GRENADE SKINS{white}. " , g_hCVar_MilestoneGrenade . IntValue - g_iCollected [ client ] ) ;
if ( g_iCollected [ client ] < g_hCVar_MilestoneSkin . IntValue )
CPrintToChat ( client , " {green}[UNLOZE XMAS] {white}You need to collect {green}%d {white}more presents to unlock {red}XMAS PLAYER SKINS{white}. " , g_hCVar_MilestoneSkin . IntValue - g_iCollected [ client ] ) ;
2018-07-23 14:09:42 +02:00
}
2018-09-12 16:43:07 +02:00
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
2018-07-23 14:09:42 +02:00
public Action SpawnCollectable ( Handle timer )
{
2018-09-12 16:43:07 +02:00
float fRandomInterval = GetRandomFloat ( g_hCVar_RandomIntervalMin . FloatValue , g_hCVar_RandomIntervalMax . FloatValue ) ;
2018-07-23 14:09:42 +02:00
CreateTimer ( fRandomInterval , SpawnCollectable , INVALID_HANDLE , TIMER_FLAG_NO_MAPCHANGE ) ;
2018-09-12 16:43:07 +02:00
if ( ! ( g_hCVar_CollectablesEnabled . BoolValue ) | | ! ( g_bEnabled ) )
2018-07-23 14:09:42 +02:00
return ;
2018-07-23 17:06:03 +02:00
2018-09-12 16:43:07 +02:00
int iTarget = GetTargetClient ( ) ;
2018-11-28 12:44:34 +01:00
if ( ! IsValidClient ( iTarget , false ) )
return ;
2018-09-12 16:43:07 +02:00
float fOrigin [ 3 ] ;
GetClientAbsOrigin ( iTarget , fOrigin ) ;
// Rotating
int iRotating = CreateEntityAtOrigin ( " func_rotating " , fOrigin ) ;
2018-11-28 12:44:34 +01:00
DispatchKeyFormat ( iRotating , " targetname " , " season_rotating_%d " , g_iCounter ) ;
2018-09-12 16:43:07 +02:00
DispatchKeyFormat ( iRotating , " maxspeed " , " 20 " ) ;
2018-11-28 12:44:34 +01:00
DispatchKeyFormat ( iRotating , " spawnflags " , " 65 " ) ;
2018-09-12 16:43:07 +02:00
SpawnAndActivate ( iRotating ) ;
// make the trigger work.
SetEntityBBox ( iRotating , view_as < float > ( { - 10.0 , - 1.0 , - 1.0 } ) , view_as < float > ( { 1.0 , 1.0 , 1.0 } ) ) ;
SetEntityProps ( iRotating ) ;
2018-07-23 17:06:03 +02:00
2018-09-12 16:43:07 +02:00
// Model
int iModel = CreateEntityAtOrigin ( " prop_dynamic_override " , fOrigin ) ;
DispatchKeyFormat ( iModel , " targetname " , " season_prop_%d " , g_iCounter ) ;
2018-11-28 12:44:34 +01:00
DispatchKeyFormat ( iModel , " model " , " models/zombieden/xmas/giftbox.mdl " ) ;
2018-09-12 16:43:07 +02:00
DispatchKeyFormat ( iModel , " modelscale " , " 0.8 " ) ;
DispatchKeyFormat ( iModel , " disablebonefollowers " , " 1 " ) ;
SpawnAndActivate ( iModel ) ;
ParentToEntity ( iModel , iRotating ) ;
int iRandomSkin = GetRandomInt ( 0 , 1 ) ;
if ( iRandomSkin = = 0 )
SetVariantString ( " 0 " ) ;
else if ( iRandomSkin = = 1 )
SetVariantString ( " 1 " ) ;
AcceptEntityInput ( iModel , " Skin " ) ;
// Particle
int iParticle = CreateEntityAtOrigin ( " info_particle_system " , fOrigin ) ;
DispatchKeyFormat ( iParticle , " targetname " , " season_particle_%d " , g_iCounter ) ;
DispatchKeyFormat ( iParticle , " effect_name " , " achieved " ) ;
SpawnAndActivate ( iParticle ) ;
ParentToEntity ( iParticle , iRotating ) ;
// Trigger
int iTrigger = CreateEntityAtOrigin ( " trigger_multiple " , fOrigin ) ;
2018-11-28 12:44:34 +01:00
DispatchKeyFormat ( iTrigger , " targetname " , " season_trigger_%d " , g_iCounter ) ;
DispatchKeyFormat ( iTrigger , " spawnflags " , " 1 " ) ;
DispatchKeyFormat ( iTrigger , " startdisabled " , " 1 " ) ;
2018-09-12 16:43:07 +02:00
DispatchKeyFormat ( iTrigger , " OnUser1 " , " season_hitbox_%d,FireUser2,,0,1 " , g_iCounter ) ;
SpawnAndActivate ( iTrigger ) ;
ParentToEntity ( iTrigger , iRotating ) ;
// make the trigger work.
SetEntityBBox ( iTrigger , view_as < float > ( { - 16.0 , - 16.0 , - 1.0 } ) , view_as < float > ( { 16.0 , 16.0 , 32.0 } ) ) ;
SetEntityProps ( iTrigger ) ;
HookSingleEntityOutput ( iTrigger , " OnStartTouch " , HookCallbackTrigger , false ) ;
// Ambient
int iSound = CreateEntityAtOrigin ( " ambient_generic " , fOrigin ) ;
DispatchKeyFormat ( iSound , " targetname " , " season_sound_%d " , g_iCounter ) ;
DispatchKeyFormat ( iSound , " spawnflags " , " 49 " ) ;
DispatchKeyFormat ( iSound , " radius " , " 2000 " ) ;
DispatchKeyFormat ( iSound , " message " , " unl1/season/hohohoho.wav " ) ;
DispatchKeyFormat ( iSound , " volume " , " 10 " ) ;
DispatchKeyFormat ( iSound , " health " , " 10 " ) ;
DispatchKeyFormat ( iSound , " pitch " , " 100 " ) ;
DispatchKeyFormat ( iSound , " pitchstart " , " 100 " ) ;
SpawnAndActivate ( iSound ) ;
ParentToEntity ( iSound , iRotating ) ;
// Hitbox
int iHitbox = CreateEntityAtOrigin ( " func_physbox_multiplayer " , fOrigin ) ;
DispatchKeyFormat ( iHitbox , " targetname " , " season_hitbox_%d " , g_iCounter ) ;
2018-11-28 12:44:34 +01:00
DispatchKeyFormat ( iHitbox , " model " , " models/zombieden/xmas/giftbox.mdl " ) ;
2018-09-12 16:43:07 +02:00
DispatchKeyFormat ( iHitbox , " modelscale " , " 0.8 " ) ;
DispatchKeyFormat ( iHitbox , " disableshadows " , " 1 " ) ;
2018-11-28 12:44:34 +01:00
DispatchKeyFormat ( iHitbox , " disablereceiveshadows " , " 1 " ) ;
DispatchKeyFormat ( iHitbox , " DisableBoneFollowers " , " 1 " ) ;
2018-09-12 16:43:07 +02:00
DispatchKeyFormat ( iHitbox , " rendermode " , " 10 " ) ;
DispatchKeyFormat ( iHitbox , " PerformanceMode " , " 1 " ) ;
2018-11-28 12:44:34 +01:00
DispatchKeyFormat ( iHitbox , " material " , " 3 " ) ;
2018-09-12 16:43:07 +02:00
DispatchKeyFormat ( iHitbox , " health " , " 200 " ) ;
DispatchKeyFormat ( iHitbox , " physdamagescale " , " 1.0 " ) ;
DispatchKeyFormat ( iHitbox , " OnBreak " , " season_rotating_%d,KillHierarchy,,2.5,1 " , g_iCounter ) ;
DispatchKeyFormat ( iHitbox , " OnBreak " , " season_particle_%d,Start,,0,1 " , g_iCounter ) ;
2018-11-28 12:44:34 +01:00
DispatchKeyFormat ( iHitbox , " OnBreak " , " season_sound_%d,PlaySound,,0,1 " , g_iCounter ) ;
DispatchKeyFormat ( iHitbox , " OnBreak " , " season_sound_%d,Kill,,2.4,1 " , g_iCounter ) ;
2018-09-12 16:43:07 +02:00
DispatchKeyFormat ( iHitbox , " OnUser1 " , " season_rotating_%d,KillHierarchy,,59.0,1 " , g_iCounter ) ;
2018-11-28 12:44:34 +01:00
DispatchKeyFormat ( iHitbox , " OnUser1 " , " season_sound_%d,Kill,,59.0,1 " , g_iCounter ) ;
2018-09-12 16:43:07 +02:00
DispatchKeyFormat ( iHitbox , " OnUser2 " , " season_rotating_%d,KillHierarchy,,0,1 " , g_iCounter ) ;
2018-11-28 12:44:34 +01:00
DispatchKeyFormat ( iHitbox , " OnUser2 " , " season_sound_%d,Kill,,0,1 " , g_iCounter ) ;
2018-09-12 16:43:07 +02:00
SpawnAndActivate ( iHitbox ) ;
ParentToEntity ( iHitbox , iRotating ) ;
HookSingleEntityOutput ( iHitbox , " OnBreak " , HookCallback , true ) ;
AcceptEntityInput ( iHitbox , " FireUser1 " ) ;
2018-07-23 14:09:42 +02:00
AcceptEntityInput ( iTrigger , " Enable " ) ;
2018-07-23 17:06:03 +02:00
2018-09-12 16:43:07 +02:00
int iEntityLimit = g_hCVar_EntityLimit . IntValue ;
2018-07-23 17:06:03 +02:00
2018-09-12 16:43:07 +02:00
if ( ( iRotating > iEntityLimit ) | | ( iParticle > iEntityLimit ) | | ( iModel > iEntityLimit ) | | ( iHitbox > iEntityLimit ) | | ( iTrigger > iEntityLimit ) | | ( iSound > iEntityLimit ) )
2018-07-23 14:09:42 +02:00
{
AcceptEntityInput ( iHitbox , " FireUser2 " ) ;
CPrintToChatAll ( " {green}[Unloze XMAS] {white}Present removed due to {red}critical amount of entities{white}! " ) ;
2018-07-23 17:06:03 +02:00
}
2018-09-12 16:43:07 +02:00
g_iCounter + = 1 ;
2018-07-23 14:09:42 +02:00
}
2018-09-12 16:43:07 +02:00
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
2018-07-23 14:09:42 +02:00
public int GetTargetClient ( )
2018-07-23 17:06:03 +02:00
{
2018-09-12 16:43:07 +02:00
int iEligibleClients [ MAXPLAYERS + 1 ] ;
2018-07-23 17:06:03 +02:00
int iClientCount = 0 ;
2018-09-12 16:43:07 +02:00
2018-07-23 14:09:42 +02:00
for ( int i = 1 ; i < = MaxClients ; i + + )
{
if ( IsClientInGame ( i ) & & IsPlayerAlive ( i ) & & ( ZR_IsClientHuman ( i ) ) )
{
iEligibleClients [ iClientCount ] = i ;
iClientCount + = 1 ;
}
2018-07-23 17:06:03 +02:00
}
2018-09-12 16:43:07 +02:00
2018-07-23 14:09:42 +02:00
if ( iClientCount = = 0 )
2018-07-23 17:06:03 +02:00
return - 1 ;
2018-09-12 16:43:07 +02:00
2018-07-23 14:09:42 +02:00
int randomIndex = GetRandomInt ( 0 , iClientCount - 1 ) ;
return iEligibleClients [ randomIndex ] ;
}
2018-09-12 16:43:07 +02:00
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
2018-07-23 14:09:42 +02:00
public void HookCallbackTrigger ( const char [ ] output , int caller , int activator , float delay )
2018-07-23 17:06:03 +02:00
{
2018-09-12 16:43:07 +02:00
if ( ZR_IsClientZombie ( activator ) )
2018-07-23 14:09:42 +02:00
{
UnhookSingleEntityOutput ( caller , " OnStartTouch " , HookCallbackTrigger ) ;
AcceptEntityInput ( caller , " FireUser1 " ) ;
2018-09-12 16:43:07 +02:00
CPrintToChatAll ( " {green}[UNLOZE XMAS] {white}Zombies {red}destroyed{white} a present! " ) ;
2018-07-23 14:09:42 +02:00
}
}
2018-09-12 16:43:07 +02:00
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
2018-07-23 14:09:42 +02:00
public void HookCallback ( const char [ ] output , int caller , int activator , float delay )
2018-07-23 17:06:03 +02:00
{
2018-07-23 14:09:42 +02:00
for ( int client = 1 ; client < = MaxClients ; client + + )
{
2018-09-12 16:43:07 +02:00
if ( IsValidClient ( client ) & & ! IsClientSourceTV ( client ) & & IsPlayerAlive ( client ) & & ZR_IsClientHuman ( client ) )
2018-07-23 14:09:42 +02:00
{
2018-09-12 16:43:07 +02:00
char sSteamID [ 32 ] ;
GetClientAuthId ( client , AuthId_Steam2 , sSteamID , sizeof ( sSteamID ) ) ;
2018-07-23 17:06:03 +02:00
2018-11-28 12:44:34 +01:00
char sName [ MAX_NAME_LENGTH ] ;
GetClientName ( client , sName , sizeof ( sName ) ) ;
2018-07-23 14:09:42 +02:00
char sQuery [ 255 ] ;
2018-11-28 12:44:34 +01:00
Format ( sQuery , sizeof ( sQuery ) , " INSERT INTO xmas_table (steam_auth,name,collected) VALUES ('%s','%s',1) ON DUPLICATE KEY UPDATE collected=collected+1; " , sSteamID , sName ) ;
SQL_FastQuery ( g_hDatabase , sQuery ) ;
2018-07-23 14:09:42 +02:00
2018-11-28 12:44:34 +01:00
g_iCollected [ client ] + = 1 ;
CheckAndAddFlag ( client ) ;
2018-07-23 17:06:03 +02:00
2018-11-28 12:44:34 +01:00
CPrintToChat ( client , " {green}[UNLOZE XMAS] {white}Your Team opened a present! You have collected {green}%d {white}presents so far. " , g_iCollected [ client ] ) ;
if ( g_iCollected [ client ] = = g_hCVar_MilestoneInfection . IntValue )
CPrintToChat ( client , " {green}[UNLOZE XMAS] {white}Congratulations! You have unlocked {red}INFECTION EFFECTS{white}! " ) ;
2018-07-23 17:06:03 +02:00
2018-11-28 12:44:34 +01:00
if ( g_iCollected [ client ] = = g_hCVar_MilestoneGrenade . IntValue )
CPrintToChat ( client , " {green}[UNLOZE XMAS] {white}Congratulations! You have unlocked {red}GRENADE SKINS{white}! " ) ;
2018-07-23 17:06:03 +02:00
2018-11-28 12:44:34 +01:00
if ( g_iCollected [ client ] = = g_hCVar_MilestoneSkin . IntValue )
CPrintToChat ( client , " {green}[UNLOZE XMAS] {white}Congratulations! You have unlocked {red}XMAS SKINS{white}! " ) ;
}
2018-07-23 14:09:42 +02:00
}
}
public void ZR_OnClientInfected ( int client , int attacker , bool motherInfect , bool respawnOverride , bool respawn )
{
2018-11-28 12:44:34 +01:00
if ( ! IsValidClient ( attacker ) )
return ;
2018-09-12 16:43:07 +02:00
if ( g_hCVar_InfectionEffectEnabled . BoolValue & & ( ( g_iCollected [ client ] > = g_hCVar_MilestoneInfection . IntValue ) | | g_iCollected [ attacker ] > = g_hCVar_MilestoneInfection . IntValue ) )
2018-07-23 14:09:42 +02:00
{
float fInfectionOrigin [ 3 ] ;
GetClientAbsOrigin ( client , fInfectionOrigin ) ;
2018-07-23 17:06:03 +02:00
2018-09-12 16:43:07 +02:00
// Rotating
int iRotating = CreateEntityAtOrigin ( " func_rotating " , fInfectionOrigin ) ;
DispatchKeyFormat ( iRotating , " targetname " , " season_infection_rotating_%d " , g_iCounter ) ;
2018-11-28 12:44:34 +01:00
DispatchKeyFormat ( iRotating , " maxspeed " , " 13 " ) ;
2018-09-12 16:43:07 +02:00
DispatchKeyFormat ( iRotating , " spawnflags " , " 65 " ) ;
2018-11-28 12:44:34 +01:00
DispatchKeyFormat ( iRotating , " OnUser1 " , " !self,KillHierarchy,,45,1 " ) ;
DispatchKeyFormat ( iRotating , " OnUser2 " , " !self,KillHierarchy,,0,1 " ) ;
2018-09-12 16:43:07 +02:00
SpawnAndActivate ( iRotating ) ;
// make the trigger work.
SetEntityBBox ( iRotating , view_as < float > ( { - 10.0 , - 1.0 , - 1.0 } ) , view_as < float > ( { 1.0 , 1.0 , 1.0 } ) ) ;
SetEntityProps ( iRotating ) ;
int iModel = CreateEntityAtOrigin ( " prop_dynamic_override " , fInfectionOrigin ) ;
DispatchKeyFormat ( iModel , " targetname " , " season_infection_prop_%d " , g_iCounter ) ;
2018-07-23 17:06:03 +02:00
int iRandomSkin = GetRandomInt ( 0 , 4 ) ;
2018-07-23 14:09:42 +02:00
if ( iRandomSkin = = 0 )
{
2018-09-12 16:43:07 +02:00
DispatchKeyFormat ( iModel , " model " , " models/models_kit/xmas/xmastree_mini.mdl " ) ;
DispatchKeyFormat ( iModel , " modelscale " , " 0.35 " ) ;
DispatchKeyFormat ( iModel , " angles " , " 0 0 0 " ) ;
2018-07-23 17:06:03 +02:00
}
2018-07-23 14:09:42 +02:00
else if ( iRandomSkin = = 1 )
{
2018-09-12 16:43:07 +02:00
DispatchKeyFormat ( iModel , " model " , " models/weapons/w_revenge_xmas_candy.mdl " ) ;
DispatchKeyFormat ( iModel , " modelscale " , " 1.2 " ) ;
DispatchKeyFormat ( iModel , " angles " , " -27 0 0 " ) ;
2018-07-23 17:06:03 +02:00
}
2018-07-23 14:09:42 +02:00
else if ( iRandomSkin = = 2 )
{
2018-09-12 16:43:07 +02:00
DispatchKeyFormat ( iModel , " model " , " models/johny-srka/snowman.mdl " ) ;
DispatchKeyFormat ( iModel , " modelscale " , " 0.45 " ) ;
DispatchKeyFormat ( iModel , " angles " , " 0 0 0 " ) ;
2018-07-23 17:06:03 +02:00
}
2018-07-23 14:09:42 +02:00
else if ( iRandomSkin = = 3 )
{
2018-09-12 16:43:07 +02:00
DispatchKeyFormat ( iModel , " model " , " models/weapons/w_santa_hat_thrown.mdl " ) ;
DispatchKeyFormat ( iModel , " modelscale " , " 2.7 " ) ;
DispatchKeyFormat ( iModel , " angles " , " 0 0 -90 " ) ;
2018-07-23 14:09:42 +02:00
fInfectionOrigin [ 2 ] + = 7 ;
}
else if ( iRandomSkin = = 4 )
{
2018-09-12 16:43:07 +02:00
DispatchKeyFormat ( iModel , " model " , " models/models_kit/xmas/xmas_teddybear.mdl " ) ;
DispatchKeyFormat ( iModel , " modelscale " , " 0.7 " ) ;
DispatchKeyFormat ( iModel , " angles " , " 0 0 0 " ) ;
2018-07-23 17:06:03 +02:00
}
2018-09-12 16:43:07 +02:00
DispatchKeyFormat ( iModel , " disableshadows " , " 1 " ) ;
DispatchKeyFormat ( iModel , " disablereceiveshadows " , " 1 " ) ;
2018-11-28 12:44:34 +01:00
DispatchKeyFormat ( iModel , " DisableBoneFollowers " , " 1 " ) ;
2018-09-12 16:43:07 +02:00
DispatchKeyValueVector ( iModel , " origin " , fInfectionOrigin ) ;
SpawnAndActivate ( iModel ) ;
ParentToEntity ( iModel , iRotating ) ;
AcceptEntityInput ( iRotating , " FireUser1 " ) ;
int iEntityLimit = g_hCVar_EntityLimit . IntValue ;
if ( ( iModel > iEntityLimit ) | | ( iRotating > iEntityLimit ) )
2018-07-23 14:09:42 +02:00
{
2018-09-12 16:43:07 +02:00
AcceptEntityInput ( iRotating , " FireUser2 " ) ;
2018-07-23 14:09:42 +02:00
CPrintToChatAll ( " {green}[Unloze XMAS] {white}Infection Effect removed due to {red}critical amount of entities{white}! " ) ;
2018-07-23 17:06:03 +02:00
}
2018-09-12 16:43:07 +02:00
g_iCounter + = 1 ;
2018-07-23 14:09:42 +02:00
}
}
2019-09-10 16:33:50 +02:00
public void OnEntitySpawned ( int Entity , const char [ ] sClassname )
2018-07-23 14:09:42 +02:00
{
2018-07-23 17:06:03 +02:00
int iOwner = GetEntPropEnt ( Entity , Prop_Data , " m_hOwnerEntity " ) ;
2018-09-12 16:43:07 +02:00
if ( ! IsValidClient ( iOwner ) )
return ;
if ( g_iCollected [ iOwner ] > = g_hCVar_MilestoneGrenade . IntValue )
2018-07-23 14:09:42 +02:00
{
2018-11-28 12:44:34 +01:00
SetEntityRenderMode ( Entity , RENDER_NONE ) ;
float fNadeOrigin [ 3 ] ;
GetEntPropVector ( Entity , Prop_Send , " m_vecOrigin " , fNadeOrigin ) ;
int iNadeProp = CreateEntityAtOrigin ( " prop_dynamic_override " , fNadeOrigin ) ;
DispatchKeyFormat ( iNadeProp , " targetname " , " season_nade_prop_%d " , g_iCounter ) ;
DispatchKeyFormat ( iNadeProp , " disableshadows " , " 1 " ) ;
DispatchKeyFormat ( iNadeProp , " disablereceiveshadows " , " 1 " ) ;
DispatchKeyFormat ( iNadeProp , " DisableBoneFollowers " , " 1 " ) ;
2018-09-12 16:43:07 +02:00
int iRandomSkin = GetRandomInt ( 0 , 3 ) ;
if ( iRandomSkin = = 0 )
2018-07-23 17:06:03 +02:00
{
2018-11-28 12:44:34 +01:00
DispatchKeyFormat ( iNadeProp , " model " , " models/weapons/w_snowball_thrown.mdl " ) ;
DispatchKeyFormat ( iNadeProp , " modelscale " , " 3.0 " ) ;
2018-09-12 16:43:07 +02:00
}
else if ( iRandomSkin = = 1 )
{
2018-11-28 12:44:34 +01:00
DispatchKeyFormat ( iNadeProp , " model " , " models/zombieden/xmas/giftbox.mdl " ) ;
DispatchKeyFormat ( iNadeProp , " modelscale " , " 0.6 " ) ;
2018-09-12 16:43:07 +02:00
iRandomSkin = GetRandomInt ( 0 , 1 ) ;
2018-07-23 14:09:42 +02:00
if ( iRandomSkin = = 0 )
{
2018-11-28 12:44:34 +01:00
DispatchKeyFormat ( iNadeProp , " skin " , " 0 " ) ;
2018-07-23 17:06:03 +02:00
}
2018-07-23 14:09:42 +02:00
else if ( iRandomSkin = = 1 )
{
2018-11-28 12:44:34 +01:00
DispatchKeyFormat ( iNadeProp , " skin " , " 1 " ) ;
2018-07-23 14:09:42 +02:00
}
2018-09-12 16:43:07 +02:00
}
else if ( iRandomSkin = = 2 )
{
2018-11-28 12:44:34 +01:00
DispatchKeyFormat ( iNadeProp , " model " , " models/weapons/w_ornament_thrown.mdl " ) ;
DispatchKeyFormat ( iNadeProp , " modelscale " , " 2.0 " ) ;
2018-09-12 16:43:07 +02:00
}
else if ( iRandomSkin = = 3 )
{
2018-11-28 12:44:34 +01:00
DispatchKeyFormat ( iNadeProp , " model " , " models/weapons/w_santa_hat_thrown.mdl " ) ;
DispatchKeyFormat ( iNadeProp , " modelscale " , " 2.3 " ) ;
2018-07-23 14:09:42 +02:00
}
2018-11-28 12:44:34 +01:00
SpawnAndActivate ( iNadeProp ) ;
ParentToEntity ( iNadeProp , Entity ) ;
2018-07-23 17:06:03 +02:00
}
2018-07-23 14:09:42 +02:00
}
2018-09-12 16:43:07 +02:00
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
stock int IsValidClient ( int client , bool nobots = true )
2018-07-23 14:09:42 +02:00
{
if ( client < = 0 | | client > MaxClients | | ! IsClientConnected ( client ) | | ( nobots & & IsFakeClient ( client ) ) )
return false ;
2018-09-12 16:43:07 +02:00
2018-07-23 14:09:42 +02:00
return IsClientInGame ( client ) ;
2018-09-12 16:43:07 +02:00
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void CheckAndAddFlag ( int client )
{
if ( g_iCollected [ client ] > = g_hCVar_MilestoneSkin . IntValue )
AddUserFlags ( client , Admin_Custom4 ) ;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
stock int CreateEntityAtOrigin ( const char [ ] classname , const float origin [ 3 ] )
{
int entity = CreateEntityByName ( classname ) ;
TeleportEntity ( entity , origin , NULL_VECTOR , NULL_VECTOR ) ;
return entity ;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
stock bool DispatchKeyFormat ( int entity , const char [ ] key , const char [ ] value , any . . . )
{
char buffer [ 1024 ] ;
VFormat ( buffer , sizeof ( buffer ) , value , 4 ) ;
DispatchKeyValue ( entity , key , buffer ) ;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
stock void SpawnAndActivate ( int entity )
{
DispatchSpawn ( entity ) ;
ActivateEntity ( entity ) ;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
stock void ParentToEntity ( int entity , int parent )
{
SetVariantString ( " !activator " ) ;
AcceptEntityInput ( entity , " SetParent " , parent , parent ) ;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
stock void SetEntityBBox ( int entity , const float mins [ 3 ] , const float maxs [ 3 ] )
{
SetEntPropVector ( entity , Prop_Send , " m_vecMins " , mins ) ;
SetEntPropVector ( entity , Prop_Send , " m_vecMaxs " , maxs ) ;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
stock void SetEntityProps ( int entity )
{
SetEntProp ( entity , Prop_Send , " m_nSolidType " , 3 ) ;
SetEntProp ( entity , Prop_Send , " m_fEffects " , 32 ) ;
}