Hooked autobuy/rebuy, added fog to visual effects, create effect functions in visualeffects.inc, fixed ambience, hooked mp_restartgame, mother count is rounded to nearest instead of ceiling, recoded cvars.inc and added logging, recoded event.inc, killed respawn timers on round end.
This commit is contained in:
parent
65411df2c0
commit
abd38ee033
|
@ -23,12 +23,12 @@
|
||||||
// External api (not done)
|
// External api (not done)
|
||||||
//#include "zr/global"
|
//#include "zr/global"
|
||||||
|
|
||||||
// Cvars (core)
|
|
||||||
#include "zr/cvars"
|
|
||||||
|
|
||||||
// Log (core)
|
// Log (core)
|
||||||
#include "zr/log"
|
#include "zr/log"
|
||||||
|
|
||||||
|
// Cvars (core)
|
||||||
|
#include "zr/cvars"
|
||||||
|
|
||||||
// Translations (core)
|
// Translations (core)
|
||||||
#include "zr/translation"
|
#include "zr/translation"
|
||||||
|
|
||||||
|
@ -90,6 +90,8 @@
|
||||||
#include "zr/sayhooks"
|
#include "zr/sayhooks"
|
||||||
#include "zr/zadmin"
|
#include "zr/zadmin"
|
||||||
#include "zr/commands"
|
#include "zr/commands"
|
||||||
|
|
||||||
|
// Event
|
||||||
#include "zr/event"
|
#include "zr/event"
|
||||||
|
|
||||||
public Plugin:myinfo =
|
public Plugin:myinfo =
|
||||||
|
@ -120,12 +122,13 @@ public OnPluginStart()
|
||||||
|
|
||||||
// ======================================================================
|
// ======================================================================
|
||||||
|
|
||||||
|
// Log
|
||||||
|
LogInit();
|
||||||
|
|
||||||
// Cvars
|
// Cvars
|
||||||
CvarsInit();
|
CvarsInit();
|
||||||
CvarsHook();
|
|
||||||
|
|
||||||
// TODO: Be modulized/recoded.
|
// TODO: Be modulized/recoded.
|
||||||
HookEvents();
|
|
||||||
HookChatCmds();
|
HookChatCmds();
|
||||||
CreateCommands();
|
CreateCommands();
|
||||||
HookCommands();
|
HookCommands();
|
||||||
|
@ -138,6 +141,9 @@ public OnPluginStart()
|
||||||
// Damage
|
// Damage
|
||||||
DamageInit();
|
DamageInit();
|
||||||
|
|
||||||
|
// Event
|
||||||
|
EventInit();
|
||||||
|
|
||||||
// ======================================================================
|
// ======================================================================
|
||||||
|
|
||||||
g_bMarket = LibraryExists("market");
|
g_bMarket = LibraryExists("market");
|
||||||
|
|
190
src/zr/cvars.inc
190
src/zr/cvars.inc
|
@ -9,14 +9,21 @@
|
||||||
* ============================================================================
|
* ============================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @section Locked cvar value defines.
|
||||||
|
*/
|
||||||
|
#define CVARS_AUTOTEAMBALANCE_LOCKED 0
|
||||||
|
#define CVARS_LIMITTEAMS_LOCKED 0
|
||||||
|
/**
|
||||||
|
* @endsection
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of cvars used by the plugin.
|
* List of cvars used by the plugin.
|
||||||
*/
|
*/
|
||||||
enum CvarsList
|
enum CvarsList
|
||||||
{
|
{
|
||||||
Handle:CVAR_ENABLE,
|
Handle:CVAR_ENABLE,
|
||||||
Handle:CVAR_LOG,
|
|
||||||
Handle:CVAR_LOGFLAGS,
|
|
||||||
Handle:CVAR_CLASSES_SPAWN,
|
Handle:CVAR_CLASSES_SPAWN,
|
||||||
Handle:CVAR_CLASSES_RANDOM,
|
Handle:CVAR_CLASSES_RANDOM,
|
||||||
Handle:CVAR_CLASSES_DEFAULT_ZOMBIE,
|
Handle:CVAR_CLASSES_DEFAULT_ZOMBIE,
|
||||||
|
@ -56,6 +63,14 @@ enum CvarsList
|
||||||
Handle:CVAR_VEFFECTS_LIGHTSTYLE_VALUE,
|
Handle:CVAR_VEFFECTS_LIGHTSTYLE_VALUE,
|
||||||
Handle:CVAR_VEFFECTS_SKY,
|
Handle:CVAR_VEFFECTS_SKY,
|
||||||
Handle:CVAR_VEFFECTS_SKY_PATH,
|
Handle:CVAR_VEFFECTS_SKY_PATH,
|
||||||
|
Handle:CVAR_VEFFECTS_FOG,
|
||||||
|
Handle:CVAR_VEFFECTS_FOG_OVERRIDE,
|
||||||
|
Handle:CVAR_VEFFECTS_FOG_PCOLOR,
|
||||||
|
Handle:CVAR_VEFFECTS_FOG_SCOLOR,
|
||||||
|
Handle:CVAR_VEFFECTS_FOG_DENSITY,
|
||||||
|
Handle:CVAR_VEFFECTS_FOG_STARTDIST,
|
||||||
|
Handle:CVAR_VEFFECTS_FOG_ENDDIST,
|
||||||
|
Handle:CVAR_VEFFECTS_FOG_FARZ,
|
||||||
Handle:CVAR_SEFFECTS_MOAN,
|
Handle:CVAR_SEFFECTS_MOAN,
|
||||||
Handle:CVAR_SEFFECTS_GROAN,
|
Handle:CVAR_SEFFECTS_GROAN,
|
||||||
Handle:CVAR_SEFFECTS_DEATH,
|
Handle:CVAR_SEFFECTS_DEATH,
|
||||||
|
@ -96,10 +111,37 @@ enum CvarsList
|
||||||
*/
|
*/
|
||||||
new g_hCvarsList[CvarsList];
|
new g_hCvarsList[CvarsList];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @section Global cvar handles.
|
||||||
|
*/
|
||||||
|
new Handle:g_hAutoTeamBalance = INVALID_HANDLE;
|
||||||
|
new Handle:g_hLimitTeams = INVALID_HANDLE;
|
||||||
|
new Handle:g_hRestartGame = INVALID_HANDLE;
|
||||||
|
/**
|
||||||
|
* @endsection
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cvars module init function.
|
* Cvars module init function.
|
||||||
*/
|
*/
|
||||||
CvarsInit()
|
CvarsInit()
|
||||||
|
{
|
||||||
|
// Retrieve handles of CS:S cvars.
|
||||||
|
g_hAutoTeamBalance = FindConVar("mp_autoteambalance");
|
||||||
|
g_hLimitTeams = FindConVar("mp_limitteams");
|
||||||
|
g_hRestartGame = FindConVar("mp_restartgame");
|
||||||
|
|
||||||
|
// Create zombiereloaded cvars.
|
||||||
|
CvarsCreate();
|
||||||
|
|
||||||
|
// Hook cvars.
|
||||||
|
CvarsHook();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create all cvars for plugin.
|
||||||
|
*/
|
||||||
|
CvarsCreate()
|
||||||
{
|
{
|
||||||
// Cvar naming guidelines:
|
// Cvar naming guidelines:
|
||||||
// 1. Prefix: "zr_"
|
// 1. Prefix: "zr_"
|
||||||
|
@ -126,9 +168,7 @@ CvarsInit()
|
||||||
// Log (core)
|
// Log (core)
|
||||||
// ===========================
|
// ===========================
|
||||||
|
|
||||||
g_hCvarsList[CVAR_LOG] = CreateConVar("zr_log", "1", "");
|
// Cvars created in log.inc, because of compilation problems when creating them here.
|
||||||
g_hCvarsList[CVAR_LOGFLAGS] = CreateConVar("zr_logflags", "331", "");
|
|
||||||
// Old Desc: Logging flags. Log messages to sourcemod logs, server console or client console. Use zr_log_flags to see a list of flags. (0: Disable)
|
|
||||||
|
|
||||||
// ===========================
|
// ===========================
|
||||||
// Translations (core)
|
// Translations (core)
|
||||||
|
@ -198,7 +238,7 @@ CvarsInit()
|
||||||
|
|
||||||
g_hCvarsList[CVAR_ROUNDEND_OVERLAY] = CreateConVar("zr_roundend_overlay", "1", "");
|
g_hCvarsList[CVAR_ROUNDEND_OVERLAY] = CreateConVar("zr_roundend_overlay", "1", "");
|
||||||
// Old Desc: Shows an overlay to all clients when a team wins. (0: Disable)
|
// Old Desc: Shows an overlay to all clients when a team wins. (0: Disable)
|
||||||
g_hCvarsList[CVAR_ROUNDEND_OVERLAY_HUMAN] = CreateConVar("zr_roundend_overlays_human", "");
|
g_hCvarsList[CVAR_ROUNDEND_OVERLAY_HUMAN] = CreateConVar("zr_roundend_overlays_human", "overlays/zr/humans_win");
|
||||||
// Old Desc: overlays/zr/humans_win", "Path to \"humans win\" overlay
|
// Old Desc: overlays/zr/humans_win", "Path to \"humans win\" overlay
|
||||||
g_hCvarsList[CVAR_ROUNDEND_OVERLAY_ZOMBIE] = CreateConVar("zr_roundend_overlays_zombie", "overlays/zr/zombies_win", "");
|
g_hCvarsList[CVAR_ROUNDEND_OVERLAY_ZOMBIE] = CreateConVar("zr_roundend_overlays_zombie", "overlays/zr/zombies_win", "");
|
||||||
// Old Desc: Path to \"zombies win\" overlay
|
// Old Desc: Path to \"zombies win\" overlay
|
||||||
|
@ -207,8 +247,8 @@ CvarsInit()
|
||||||
// Infect (core)
|
// Infect (core)
|
||||||
// ===========================
|
// ===========================
|
||||||
|
|
||||||
g_hCvarsList[CVAR_INFECT_MZOMBIE_RATIO] = CreateConVar("zr_infect_motherzombie_ratio", "5", "");
|
g_hCvarsList[CVAR_INFECT_MZOMBIE_RATIO] = CreateConVar("zr_infect_mzombie_ratio", "5", "");
|
||||||
g_hCvarsList[CVAR_INFECT_MZOMBIE_RESPAWN] = CreateConVar("zr_infect_motherzombie_respawn", "0", "");
|
g_hCvarsList[CVAR_INFECT_MZOMBIE_RESPAWN] = CreateConVar("zr_infect_mzombie_respawn", "0", "");
|
||||||
g_hCvarsList[CVAR_INFECT_SPAWNTIME_MIN] = CreateConVar("zr_infect_spawntime_min", "30.0", "");
|
g_hCvarsList[CVAR_INFECT_SPAWNTIME_MIN] = CreateConVar("zr_infect_spawntime_min", "30.0", "");
|
||||||
g_hCvarsList[CVAR_INFECT_SPAWNTIME_MAX] = CreateConVar("zr_infect_spawntime_max", "50.0", "");
|
g_hCvarsList[CVAR_INFECT_SPAWNTIME_MAX] = CreateConVar("zr_infect_spawntime_max", "50.0", "");
|
||||||
g_hCvarsList[CVAR_INFECT_CONSECUTIVE_BLOCK] = CreateConVar("zr_infect_consecutive_block", "1", "");
|
g_hCvarsList[CVAR_INFECT_CONSECUTIVE_BLOCK] = CreateConVar("zr_infect_consecutive_block", "1", "");
|
||||||
|
@ -261,10 +301,28 @@ CvarsInit()
|
||||||
// Visual Effects (module)
|
// Visual Effects (module)
|
||||||
// ===========================
|
// ===========================
|
||||||
|
|
||||||
g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE] = CreateConVar("zr_veffects_lightstyle", "1", "");
|
// Lightstyle
|
||||||
|
|
||||||
|
g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE] = CreateConVar("zr_veffects_lightstyle", "0", "");
|
||||||
g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE_VALUE] = CreateConVar("zr_veffects_lightstyle_value", "a", "");
|
g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE_VALUE] = CreateConVar("zr_veffects_lightstyle_value", "a", "");
|
||||||
|
|
||||||
|
// Sky
|
||||||
|
|
||||||
g_hCvarsList[CVAR_VEFFECTS_SKY] = CreateConVar("zr_veffects_sky", "1", "");
|
g_hCvarsList[CVAR_VEFFECTS_SKY] = CreateConVar("zr_veffects_sky", "1", "");
|
||||||
g_hCvarsList[CVAR_VEFFECTS_SKY_PATH] = CreateConVar("zr_veffects_sky_path", "skybox/sky_c17_05bk.vmt", "");
|
g_hCvarsList[CVAR_VEFFECTS_SKY_PATH] = CreateConVar("zr_veffects_sky_path", "sky_fake_white.vmt", "");
|
||||||
|
|
||||||
|
// Fog
|
||||||
|
|
||||||
|
g_hCvarsList[CVAR_VEFFECTS_FOG] = CreateConVar("zr_veffects_fog", "0", "");
|
||||||
|
// NOTE DISABLE. SOURCEMOD DOESNT SUPPORT THIS YET.
|
||||||
|
g_hCvarsList[CVAR_VEFFECTS_FOG_OVERRIDE] = CreateConVar("zr_veffects_fog_override", "0", "");
|
||||||
|
// NOTE DISABLE. SOURCEMOD DOESNT SUPPORT THIS YET.
|
||||||
|
g_hCvarsList[CVAR_VEFFECTS_FOG_PCOLOR] = CreateConVar("zr_veffects_fog_pcolor", "255 255 255", "");
|
||||||
|
g_hCvarsList[CVAR_VEFFECTS_FOG_SCOLOR] = CreateConVar("zr_veffects_fog_scolor", "255 255 255", "");
|
||||||
|
g_hCvarsList[CVAR_VEFFECTS_FOG_DENSITY] = CreateConVar("zr_veffects_fog_density", "0.8", "");
|
||||||
|
g_hCvarsList[CVAR_VEFFECTS_FOG_STARTDIST] = CreateConVar("zr_veffects_fog_startdist", "0", "");
|
||||||
|
g_hCvarsList[CVAR_VEFFECTS_FOG_ENDDIST] = CreateConVar("zr_veffects_fog_enddist", "400", "");
|
||||||
|
g_hCvarsList[CVAR_VEFFECTS_FOG_FARZ] = CreateConVar("zr_veffects_fog_farz", "2000", "");
|
||||||
|
|
||||||
// ===========================
|
// ===========================
|
||||||
// Sound Effects (module)
|
// Sound Effects (module)
|
||||||
|
@ -371,53 +429,105 @@ CvarsInit()
|
||||||
g_hCvarsList[CVAR_ANTICAMP_UPDATE_INTERVAL] = CreateConVar("zr_anticamp_update_interval", "1", "");
|
g_hCvarsList[CVAR_ANTICAMP_UPDATE_INTERVAL] = CreateConVar("zr_anticamp_update_interval", "1", "");
|
||||||
// Old Desc: How often to update player locations (in seconds).
|
// Old Desc: How often to update player locations (in seconds).
|
||||||
|
|
||||||
// TODO: Recode.
|
// Auto-generate config file if it doesn't exist, then execute.
|
||||||
//HookConVarChange(g_hCvarsList[CVAR_ENABLE], EnableHook);
|
|
||||||
|
|
||||||
AutoExecConfig(true, "zombiereloaded", "sourcemod/zombiereloaded");
|
AutoExecConfig(true, "zombiereloaded", "sourcemod/zombiereloaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
CvarsHook()
|
/**
|
||||||
|
* Hook cvar changes.
|
||||||
|
*
|
||||||
|
* @param unhook If true, cvars will be unhooked, false to hook cvars.
|
||||||
|
*/
|
||||||
|
CvarsHook(bool:unhook = false)
|
||||||
{
|
{
|
||||||
SetConVarBool(FindConVar("mp_autoteambalance"), false);
|
// If unhook is true, then continue.
|
||||||
SetConVarInt(FindConVar("mp_limitteams"), 0);
|
if (unhook)
|
||||||
|
{
|
||||||
|
// Unhook all cvars.
|
||||||
|
UnhookConVarChange(g_hAutoTeamBalance, CvarsHookLocked);
|
||||||
|
UnhookConVarChange(g_hLimitTeams, CvarsHookLocked);
|
||||||
|
UnhookConVarChange(g_hRestartGame, CvarsHookRestartGame);
|
||||||
|
|
||||||
HookConVarChange(FindConVar("mp_autoteambalance"), AutoTeamBalanceHook);
|
// Stop after unhooking cvars.
|
||||||
HookConVarChange(FindConVar("mp_limitteams"), LimitTeamsHook);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set locked cvars to their locked value.
|
||||||
|
SetConVarInt(g_hAutoTeamBalance, CVARS_AUTOTEAMBALANCE_LOCKED);
|
||||||
|
SetConVarInt(g_hLimitTeams, CVARS_LIMITTEAMS_LOCKED);
|
||||||
|
|
||||||
|
// Hook cvar to prevent it from changing.
|
||||||
|
HookConVarChange(g_hAutoTeamBalance, CvarsHookLocked);
|
||||||
|
//HookConVarChange(hLimitTeams, CvarsHookLocked);
|
||||||
|
HookConVarChange(g_hRestartGame, CvarsHookRestartGame);
|
||||||
|
|
||||||
|
// Anticamp shtuff. (needs to be moved to anticamp if these hooks are necessary)
|
||||||
HookConVarChange(g_hCvarsList[CVAR_ANTICAMP], AnticampHook);
|
HookConVarChange(g_hCvarsList[CVAR_ANTICAMP], AnticampHook);
|
||||||
HookConVarChange(g_hCvarsList[CVAR_ANTICAMP_UPDATE_INTERVAL], UpdateIntervalHook);
|
HookConVarChange(g_hCvarsList[CVAR_ANTICAMP_UPDATE_INTERVAL], UpdateIntervalHook);
|
||||||
}
|
}
|
||||||
|
|
||||||
CvarsUnhook()
|
/**
|
||||||
|
* Cvar hook callback (mp_autoteambalance, mp_limitteams)
|
||||||
|
* Prevents changes to cvar.
|
||||||
|
*
|
||||||
|
* @param convar The cvar handle.
|
||||||
|
* @param oldvalue The value before the attempted change.
|
||||||
|
* @param newvalue The new value.
|
||||||
|
*/
|
||||||
|
public CvarsHookLocked(Handle:cvar, const String:oldvalue[], const String:newvalue[])
|
||||||
{
|
{
|
||||||
UnhookConVarChange(FindConVar("mp_autoteambalance"), AutoTeamBalanceHook);
|
// If cvar is mp_autoteambalance, then continue.
|
||||||
UnhookConVarChange(FindConVar("mp_limitteams"), LimitTeamsHook);
|
if (cvar == g_hAutoTeamBalance)
|
||||||
}
|
|
||||||
|
|
||||||
/*public EnableHook(Handle:convar, const String:oldValue[], const String:newValue[])
|
|
||||||
{
|
|
||||||
new bool:enable = bool:StringToInt(newValue);
|
|
||||||
|
|
||||||
if (enable)
|
|
||||||
{
|
{
|
||||||
HookEvents();
|
// Revert to locked value.
|
||||||
HookCvars();
|
SetConVarInt(g_hAutoTeamBalance, CVARS_AUTOTEAMBALANCE_LOCKED);
|
||||||
|
|
||||||
TerminateRound(3.0, Game_Commencing);
|
// If log flag check fails, then don't log.
|
||||||
|
if (LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_CORE))
|
||||||
|
{
|
||||||
|
LogMessageFormatted(-1, "Cvars", "Cvar Locked", "Cvar \"mp_autoteambalance\" was reverted back to \"CVARS_AUTOTEAMBALANCE_LOCKED\".", LOG_FORMAT_TYPE_FULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
// If cvar is mp_limitteams, then continue.
|
||||||
|
else if (cvar == g_hLimitTeams)
|
||||||
{
|
{
|
||||||
ZREnd();
|
// Revert to locked value.
|
||||||
|
SetConVarInt(g_hLimitTeams, CVARS_LIMITTEAMS_LOCKED);
|
||||||
|
|
||||||
|
// If log flag check fails, then don't log.
|
||||||
|
if (LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_CORE))
|
||||||
|
{
|
||||||
|
LogMessageFormatted(-1, "Cvars", "Cvar Locked", "Cvar \"mp_limitteams\" was reverted back to \"CVARS_LIMITTEAMS_LOCKED\".", LOG_FORMAT_TYPE_FULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
|
|
||||||
public AutoTeamBalanceHook(Handle:convar, const String:oldValue[], const String:newValue[])
|
|
||||||
{
|
|
||||||
SetConVarBool(FindConVar("mp_autoteambalance"), false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LimitTeamsHook(Handle:convar, const String:oldValue[], const String:newValue[])
|
/**
|
||||||
|
* Cvar hook callback (mp_restartgame)
|
||||||
|
* Stops restart and just ends the round.
|
||||||
|
*
|
||||||
|
* @param convar The cvar handle.
|
||||||
|
* @param oldvalue The value before the attempted change.
|
||||||
|
* @param newvalue The new value.
|
||||||
|
*/
|
||||||
|
public CvarsHookRestartGame(Handle:cvar, const String:oldvalue[], const String:newvalue[])
|
||||||
{
|
{
|
||||||
SetConVarInt(FindConVar("mp_limitteams"), 0);
|
// Prevent round restart.
|
||||||
|
SetConVarInt(cvar, 0);
|
||||||
|
|
||||||
|
// If value was invalid or 0, then stop.
|
||||||
|
new Float:delay = StringToFloat(newvalue);
|
||||||
|
if (delay <= 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Terminate the round with restart time as delay.
|
||||||
|
RoundEndRestart(delay);
|
||||||
|
|
||||||
|
// If log flag check fails, then don't log.
|
||||||
|
if (LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_CORE))
|
||||||
|
{
|
||||||
|
LogMessageFormatted(-1, "Cvars", "Restart Game", "\"mp_restartgame\" was caught and blocked, commencing round.", LOG_FORMAT_TYPE_FULL);
|
||||||
|
}
|
||||||
}
|
}
|
177
src/zr/event.inc
177
src/zr/event.inc
|
@ -1,38 +1,69 @@
|
||||||
/**
|
/*
|
||||||
* ====================
|
* ============================================================================
|
||||||
|
*
|
||||||
* Zombie:Reloaded
|
* Zombie:Reloaded
|
||||||
* File: events.inc
|
*
|
||||||
* Author: Greyscale
|
* File: (Core) event.inc
|
||||||
* ====================
|
* Description: Event hooking and forwarding.
|
||||||
|
*
|
||||||
|
* ============================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
HookEvents()
|
/**
|
||||||
|
* Init function for event module.
|
||||||
|
*/
|
||||||
|
EventInit()
|
||||||
{
|
{
|
||||||
HookEvent("round_start", RoundStart);
|
// Hook all events used by plugin.
|
||||||
HookEvent("round_freeze_end", RoundFreezeEnd);
|
EventHook();
|
||||||
HookEvent("round_end", RoundEnd);
|
|
||||||
HookEvent("player_team", PlayerTeam, EventHookMode_Pre);
|
|
||||||
HookEvent("player_spawn", PlayerSpawn);
|
|
||||||
HookEvent("player_hurt", PlayerHurt);
|
|
||||||
HookEvent("player_death", PlayerDeath);
|
|
||||||
HookEvent("player_jump", PlayerJump);
|
|
||||||
HookEvent("weapon_fire", WeaponFire);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UnhookEvents()
|
/**
|
||||||
|
* Hook events used by plugin.
|
||||||
|
*
|
||||||
|
* @param unhook If true, then unhook all events, if false, then hook.
|
||||||
|
*/
|
||||||
|
EventHook(bool:unhook = false)
|
||||||
{
|
{
|
||||||
UnhookEvent("round_start", RoundStart);
|
// If unhook is true, then continue.
|
||||||
UnhookEvent("round_freeze_end", RoundFreezeEnd);
|
if (unhook)
|
||||||
UnhookEvent("round_end", RoundEnd);
|
{
|
||||||
UnhookEvent("player_team", PlayerTeam, EventHookMode_Pre);
|
// Unhook all events.
|
||||||
UnhookEvent("player_spawn", PlayerSpawn);
|
UnhookEvent("round_start", EventRoundStart);
|
||||||
UnhookEvent("player_hurt", PlayerHurt);
|
UnhookEvent("round_freeze_end", EventRoundFreezeEnd);
|
||||||
UnhookEvent("player_death", PlayerDeath);
|
UnhookEvent("round_end", EventRoundEnd);
|
||||||
UnhookEvent("player_jump", PlayerJump);
|
UnhookEvent("player_team", EventPlayerTeam, EventHookMode_Pre);
|
||||||
UnhookEvent("weapon_fire", WeaponFire);
|
UnhookEvent("player_spawn", EventPlayerSpawn);
|
||||||
|
UnhookEvent("player_hurt", EventPlayerHurt);
|
||||||
|
UnhookEvent("player_death", EventPlayerDeath);
|
||||||
|
UnhookEvent("player_jump", EventPlayerJump);
|
||||||
|
UnhookEvent("weapon_fire", EventWeaponFire);
|
||||||
|
|
||||||
|
// Stop after unhooking events.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hook all events used by plugin.
|
||||||
|
HookEvent("round_start", EventRoundStart);
|
||||||
|
HookEvent("round_freeze_end", EventRoundFreezeEnd);
|
||||||
|
HookEvent("round_end", EventRoundEnd);
|
||||||
|
HookEvent("player_team", EventPlayerTeam, EventHookMode_Pre);
|
||||||
|
HookEvent("player_spawn", EventPlayerSpawn);
|
||||||
|
HookEvent("player_hurt", EventPlayerHurt);
|
||||||
|
HookEvent("player_death", EventPlayerDeath);
|
||||||
|
HookEvent("player_jump", EventPlayerJump);
|
||||||
|
HookEvent("weapon_fire", EventWeaponFire);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action:RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
|
/**
|
||||||
|
* Event callback (round_start)
|
||||||
|
* The round is starting.
|
||||||
|
*
|
||||||
|
* @param event The event handle.
|
||||||
|
* @param name Name of the event.
|
||||||
|
* @dontBroadcast If true, event is broadcasted to all clients, false if not.
|
||||||
|
*/
|
||||||
|
public Action:EventRoundStart(Handle:event, const String:name[], bool:dontBroadcast)
|
||||||
{
|
{
|
||||||
ZR_PrintToChat(0, "Round objective");
|
ZR_PrintToChat(0, "Round objective");
|
||||||
|
|
||||||
|
@ -44,7 +75,15 @@ public Action:RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
|
||||||
AntiStickOnRoundStart();
|
AntiStickOnRoundStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action:RoundFreezeEnd(Handle:event, const String:name[], bool:dontBroadcast)
|
/**
|
||||||
|
* Event callback (round_freeze_end)
|
||||||
|
* The freeze time is ending.
|
||||||
|
*
|
||||||
|
* @param event The event handle.
|
||||||
|
* @param name Name of the event.
|
||||||
|
* @dontBroadcast If true, event is broadcasted to all clients, false if not.
|
||||||
|
*/
|
||||||
|
public Action:EventRoundFreezeEnd(Handle:event, const String:name[], bool:dontBroadcast)
|
||||||
{
|
{
|
||||||
RemoveObjectives();
|
RemoveObjectives();
|
||||||
|
|
||||||
|
@ -55,7 +94,15 @@ public Action:RoundFreezeEnd(Handle:event, const String:name[], bool:dontBroadca
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action:RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
|
/**
|
||||||
|
* Event callback (round_end)
|
||||||
|
* The round is ending.
|
||||||
|
*
|
||||||
|
* @param event The event handle.
|
||||||
|
* @param name Name of the event.
|
||||||
|
* @dontBroadcast If true, event is broadcasted to all clients, false if not.
|
||||||
|
*/
|
||||||
|
public Action:EventRoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
|
||||||
{
|
{
|
||||||
// Get all required event info.
|
// Get all required event info.
|
||||||
new reason = GetEventInt(event, "reason");
|
new reason = GetEventInt(event, "reason");
|
||||||
|
@ -63,10 +110,19 @@ public Action:RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
|
||||||
// Forward event to modules.
|
// Forward event to modules.
|
||||||
RoundEndOnRoundEnd(reason);
|
RoundEndOnRoundEnd(reason);
|
||||||
InfectOnRoundEnd();
|
InfectOnRoundEnd();
|
||||||
|
RespawnOnRoundEnd();
|
||||||
ZTeleReset();
|
ZTeleReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action:PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast)
|
/**
|
||||||
|
* Event callback (player_team)
|
||||||
|
* Client is joining a team.
|
||||||
|
*
|
||||||
|
* @param event The event handle.
|
||||||
|
* @param name Name of the event.
|
||||||
|
* @dontBroadcast If true, event is broadcasted to all clients, false if not.
|
||||||
|
*/
|
||||||
|
public Action:EventPlayerTeam(Handle:event, const String:name[], bool:dontBroadcast)
|
||||||
{
|
{
|
||||||
// Get all required event info.
|
// Get all required event info.
|
||||||
new index = GetClientOfUserId(GetEventInt(event, "userid"));
|
new index = GetClientOfUserId(GetEventInt(event, "userid"));
|
||||||
|
@ -78,14 +134,19 @@ public Action:PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast)
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
|
/**
|
||||||
|
* Event callback (player_spawn)
|
||||||
|
* Client is spawning into the game.
|
||||||
|
*
|
||||||
|
* @param event The event handle.
|
||||||
|
* @param name Name of the event.
|
||||||
|
* @dontBroadcast If true, event is broadcasted to all clients, false if not.
|
||||||
|
*/
|
||||||
|
public Action:EventPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
|
||||||
{
|
{
|
||||||
// Get all required event info.
|
// Get all required event info.
|
||||||
new index = GetClientOfUserId(GetEventInt(event, "userid"));
|
new index = GetClientOfUserId(GetEventInt(event, "userid"));
|
||||||
|
|
||||||
// Call post player_spawn
|
|
||||||
CreateTimer(0.0, PlayerSpawnPost, index);
|
|
||||||
|
|
||||||
// Reset FOV and overlay.
|
// Reset FOV and overlay.
|
||||||
SetPlayerFOV(index, 90);
|
SetPlayerFOV(index, 90);
|
||||||
ClientCommand(index, "r_screenoverlay \"\"");
|
ClientCommand(index, "r_screenoverlay \"\"");
|
||||||
|
@ -124,13 +185,15 @@ public Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
|
||||||
ZR_PrintToChat(index, "!zmenu reminder");
|
ZR_PrintToChat(index, "!zmenu reminder");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action:PlayerSpawnPost(Handle:timer, any:client)
|
/**
|
||||||
{
|
* Event callback (player_hurt)
|
||||||
// Forward event to modules.
|
* Client is being hurt.
|
||||||
SEffectsOnClientSpawnPost(client);
|
*
|
||||||
}
|
* @param event The event handle.
|
||||||
|
* @param name Name of the event.
|
||||||
public Action:PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
|
* @dontBroadcast If true, event is broadcasted to all clients, false if not.
|
||||||
|
*/
|
||||||
|
public Action:EventPlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
|
||||||
{
|
{
|
||||||
// Get all required event info.
|
// Get all required event info.
|
||||||
new index = GetClientOfUserId(GetEventInt(event, "userid"));
|
new index = GetClientOfUserId(GetEventInt(event, "userid"));
|
||||||
|
@ -138,7 +201,7 @@ public Action:PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
|
||||||
new hitgroup = GetEventInt(event, "hitgroup");
|
new hitgroup = GetEventInt(event, "hitgroup");
|
||||||
new dmg_health = GetEventInt(event, "dmg_health");
|
new dmg_health = GetEventInt(event, "dmg_health");
|
||||||
|
|
||||||
decl String:weapon[32];
|
decl String:weapon[WEAPONS_MAX_LENGTH];
|
||||||
GetEventString(event, "weapon", weapon, sizeof(weapon));
|
GetEventString(event, "weapon", weapon, sizeof(weapon));
|
||||||
|
|
||||||
// Forward event to modules.
|
// Forward event to modules.
|
||||||
|
@ -150,10 +213,18 @@ public Action:PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
|
||||||
ZHPOnClientHurt(index);
|
ZHPOnClientHurt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
|
/**
|
||||||
|
* Event callback (player_death)
|
||||||
|
* Client has been killed.
|
||||||
|
*
|
||||||
|
* @param event The event handle.
|
||||||
|
* @param name Name of the event.
|
||||||
|
* @dontBroadcast If true, event is broadcasted to all clients, false if not.
|
||||||
|
*/
|
||||||
|
public Action:EventPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
|
||||||
{
|
{
|
||||||
// Get the weapon name.
|
// Get the weapon name.
|
||||||
decl String:weapon[32];
|
decl String:weapon[WEAPONS_MAX_LENGTH];
|
||||||
GetEventString(event, "weapon", weapon, sizeof(weapon));
|
GetEventString(event, "weapon", weapon, sizeof(weapon));
|
||||||
|
|
||||||
// If client is being infected, then stop.
|
// If client is being infected, then stop.
|
||||||
|
@ -190,7 +261,15 @@ public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
|
||||||
ZHPOnClientDeath(index);
|
ZHPOnClientDeath(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action:PlayerJump(Handle:event, const String:name[], bool:dontBroadcast)
|
/**
|
||||||
|
* Event callback (player_jump)
|
||||||
|
* Client is jumping.
|
||||||
|
*
|
||||||
|
* @param event The event handle.
|
||||||
|
* @param name Name of the event.
|
||||||
|
* @dontBroadcast If true, event is broadcasted to all clients, false if not.
|
||||||
|
*/
|
||||||
|
public Action:EventPlayerJump(Handle:event, const String:name[], bool:dontBroadcast)
|
||||||
{
|
{
|
||||||
// Get all required event info.
|
// Get all required event info.
|
||||||
new client = GetClientOfUserId(GetEventInt(event, "userid"));
|
new client = GetClientOfUserId(GetEventInt(event, "userid"));
|
||||||
|
@ -201,7 +280,15 @@ public Action:PlayerJump(Handle:event, const String:name[], bool:dontBroadcast)
|
||||||
JumpBoost(client, distance, height);
|
JumpBoost(client, distance, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action:WeaponFire(Handle:event, const String:name[], bool:dontBroadcast)
|
/**
|
||||||
|
* Event callback (weapon_fire)
|
||||||
|
* Weapon has been fired.
|
||||||
|
*
|
||||||
|
* @param event The event handle.
|
||||||
|
* @param name Name of the event.
|
||||||
|
* @dontBroadcast If true, event is broadcasted to all clients, false if not.
|
||||||
|
*/
|
||||||
|
public Action:EventWeaponFire(Handle:event, const String:name[], bool:dontBroadcast)
|
||||||
{
|
{
|
||||||
// Get all required event info.
|
// Get all required event info.
|
||||||
decl String:weapon[32];
|
decl String:weapon[32];
|
||||||
|
|
|
@ -82,7 +82,7 @@ HitgroupsLoad()
|
||||||
*/
|
*/
|
||||||
HitgroupsValidateConfig()
|
HitgroupsValidateConfig()
|
||||||
{
|
{
|
||||||
// If log flag check fails, don't log.
|
// If log flag check fails, then don't log.
|
||||||
if (!LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_HITGROUPS))
|
if (!LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_HITGROUPS))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -270,19 +270,6 @@ InfectOnRoundStart()
|
||||||
// Reset timer handle.
|
// Reset timer handle.
|
||||||
tInfect = INVALID_HANDLE;
|
tInfect = INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// x = client index.
|
|
||||||
for (new x = 1; x <= MaxClients; x++)
|
|
||||||
{
|
|
||||||
// If client isn't in-game, then stop.
|
|
||||||
if (!IsClientInGame(x))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Disable zombie flag on client.
|
|
||||||
bZombie[x] = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -437,7 +424,7 @@ public Action:InfectMotherZombie(Handle:timer)
|
||||||
ZRCountValidClients(zombiecount, humancount, _, true);
|
ZRCountValidClients(zombiecount, humancount, _, true);
|
||||||
|
|
||||||
// Calculate mother zombie count.
|
// Calculate mother zombie count.
|
||||||
new mothercount = RoundToCeil(float(humancount) / ratio);
|
new mothercount = RoundToNearest(float(humancount) / ratio);
|
||||||
|
|
||||||
// x = current mother zombie count.
|
// x = current mother zombie count.
|
||||||
for (new x = 0; x < mothercount; x++)
|
for (new x = 0; x < mothercount; x++)
|
||||||
|
@ -559,16 +546,10 @@ InfectClient(client, attacker = -1, bool:motherinfect = false)
|
||||||
|
|
||||||
// Forward event to modules.
|
// Forward event to modules.
|
||||||
ClassOnClientInfected(client, motherinfect);
|
ClassOnClientInfected(client, motherinfect);
|
||||||
|
RoundEndOnClientInfected();
|
||||||
SEffectsOnClientInfected(client);
|
SEffectsOnClientInfected(client);
|
||||||
ZHPOnClientInfected(client);
|
ZHPOnClientInfected(client);
|
||||||
TeleportOnClientInfected(client);
|
TeleportOnClientInfected(client);
|
||||||
|
|
||||||
// Terminate the round if the last player was infected.
|
|
||||||
new RoundEndOutcome:outcome;
|
|
||||||
if (RoundEndGetRoundStatus(outcome))
|
|
||||||
{
|
|
||||||
RoundEndTerminateRound(outcome);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -578,7 +559,7 @@ InfectClient(client, attacker = -1, bool:motherinfect = false)
|
||||||
*/
|
*/
|
||||||
InfectFireEffects(client)
|
InfectFireEffects(client)
|
||||||
{
|
{
|
||||||
// Create location and direction arrays.
|
// Initialize vector variables.
|
||||||
new Float:clientloc[3];
|
new Float:clientloc[3];
|
||||||
new Float:direction[3] = {0.0, 0.0, 0.0};
|
new Float:direction[3] = {0.0, 0.0, 0.0};
|
||||||
|
|
||||||
|
@ -586,87 +567,61 @@ InfectFireEffects(client)
|
||||||
GetClientAbsOrigin(client, clientloc);
|
GetClientAbsOrigin(client, clientloc);
|
||||||
clientloc[2] += 30;
|
clientloc[2] += 30;
|
||||||
|
|
||||||
// Get infection sound.
|
// If cvar contains path, then continue.
|
||||||
decl String:sound[PLATFORM_MAX_PATH];
|
decl String:sound[PLATFORM_MAX_PATH];
|
||||||
GetConVarString(g_hCvarsList[CVAR_INFECT_SOUND], sound, sizeof(sound));
|
GetConVarString(g_hCvarsList[CVAR_INFECT_SOUND], sound, sizeof(sound));
|
||||||
if (sound[0])
|
if (sound[0])
|
||||||
{
|
{
|
||||||
|
// Emit infect sound from infected client.
|
||||||
SEffectsEmitSoundFromClient(client, sound, SNDLEVEL_SCREAMING);
|
SEffectsEmitSoundFromClient(client, sound, SNDLEVEL_SCREAMING);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create an energy splash effect.
|
// If energy splash effect is enabled, then continue.
|
||||||
new bool:esplash = GetConVarBool(g_hCvarsList[CVAR_INFECT_ESPLASH]);
|
new bool:esplash = GetConVarBool(g_hCvarsList[CVAR_INFECT_ESPLASH]);
|
||||||
if (esplash)
|
if (esplash)
|
||||||
{
|
{
|
||||||
TE_SetupEnergySplash(clientloc, direction, true);
|
// Create energy splash effect.
|
||||||
TE_SendToAll();
|
VEffectsCreateEnergySplash(clientloc, direction, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create an explosion entity.
|
// Initialize explosion flags variable.
|
||||||
new explosion = CreateEntityByName("env_explosion");
|
new flags;
|
||||||
|
|
||||||
// If explosion entity is valid, then continue.
|
// Set "nofireball" flag if fireball is disabled.
|
||||||
if (explosion != -1)
|
new bool:fireball = GetConVarBool(g_hCvarsList[CVAR_INFECT_FIREBALL]);
|
||||||
|
if (!fireball)
|
||||||
{
|
{
|
||||||
// Get and set flags on explosion.
|
flags = flags | EXP_NOFIREBALL;
|
||||||
new flags = GetEntProp(explosion, Prop_Data, "m_spawnflags");
|
|
||||||
flags = flags | EXP_NODAMAGE | EXP_NODECAL;
|
|
||||||
|
|
||||||
// Set "nofireball" flag if fireball is disabled.
|
|
||||||
new bool:fireball = GetConVarBool(g_hCvarsList[CVAR_INFECT_FIREBALL]);
|
|
||||||
if (!fireball)
|
|
||||||
{
|
|
||||||
flags = flags | EXP_NOFIREBALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set "nosmoke" flag if smoke is disabled.
|
|
||||||
new bool:smoke = GetConVarBool(g_hCvarsList[CVAR_INFECT_SMOKE]);
|
|
||||||
if (!smoke)
|
|
||||||
{
|
|
||||||
flags = flags | EXP_NOSMOKE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set "nosparks" flag if sparks are disabled.
|
|
||||||
new bool:sparks = GetConVarBool(g_hCvarsList[CVAR_INFECT_SPARKS]);
|
|
||||||
if (!sparks)
|
|
||||||
{
|
|
||||||
flags = flags | EXP_NOSPARKS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set new flags on entity.
|
|
||||||
SetEntProp(explosion, Prop_Data, "m_spawnflags", flags);
|
|
||||||
|
|
||||||
// Spawn the entity into the world.
|
|
||||||
DispatchSpawn(explosion);
|
|
||||||
|
|
||||||
// Precache fireball model.
|
|
||||||
PrecacheModel("materials/sprites/xfireball3.vmt");
|
|
||||||
|
|
||||||
// Set origin and explosion key values on entity.
|
|
||||||
DispatchKeyValueVector(explosion, "origin", clientloc);
|
|
||||||
DispatchKeyValue(explosion, "fireballsprite", "materials/sprites/xfireball3.vmt");
|
|
||||||
|
|
||||||
// Tell the entity to explode.
|
|
||||||
AcceptEntityInput(explosion, "Explode");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set "nosmoke" flag if smoke is disabled.
|
||||||
|
new bool:smoke = GetConVarBool(g_hCvarsList[CVAR_INFECT_SMOKE]);
|
||||||
|
if (!smoke)
|
||||||
|
{
|
||||||
|
flags = flags | EXP_NOSMOKE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set "nosparks" flag if sparks are disabled.
|
||||||
|
new bool:sparks = GetConVarBool(g_hCvarsList[CVAR_INFECT_SPARKS]);
|
||||||
|
if (!sparks)
|
||||||
|
{
|
||||||
|
flags = flags | EXP_NOSPARKS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create explosion at client's origin.
|
||||||
|
VEffectsCreateExplosion(clientloc, flags);
|
||||||
|
|
||||||
// If shake effect is enabled, then continue.
|
// If shake effect is enabled, then continue.
|
||||||
new bool:shake = GetConVarBool(g_hCvarsList[CVAR_INFECT_SHAKE]);
|
new bool:shake = GetConVarBool(g_hCvarsList[CVAR_INFECT_SHAKE]);
|
||||||
if (shake)
|
if (shake)
|
||||||
{
|
{
|
||||||
// If shake usermsg isn't invalid, then continue.
|
// Get shake info.
|
||||||
new Handle:hShake = StartMessageOne("Shake", client);
|
new Float:shakeamp = GetConVarFloat(g_hCvarsList[CVAR_INFECT_SHAKE_AMP]);
|
||||||
if (hShake != INVALID_HANDLE)
|
new Float:shakefrequency = GetConVarFloat(g_hCvarsList[CVAR_INFECT_SHAKE_FREQUENCY]);
|
||||||
{
|
new Float:shakeduration = GetConVarFloat(g_hCvarsList[CVAR_INFECT_SHAKE_DURATION]);
|
||||||
// Write shake information to usermsg handle.
|
|
||||||
BfWriteByte(hShake, 0);
|
|
||||||
BfWriteFloat(hShake, GetConVarFloat(g_hCvarsList[CVAR_INFECT_SHAKE_AMP]));
|
|
||||||
BfWriteFloat(hShake, GetConVarFloat(g_hCvarsList[CVAR_INFECT_SHAKE_FREQUENCY]));
|
|
||||||
BfWriteFloat(hShake, GetConVarFloat(g_hCvarsList[CVAR_INFECT_SHAKE_DURATION]));
|
|
||||||
|
|
||||||
// End usermsg and sent to client.
|
// Shake client's screen.
|
||||||
EndMessage();
|
VEffectsShakeClientScreen(client, shakeamp, shakefrequency, shakeduration);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,23 @@
|
||||||
* @endsection
|
* @endsection
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @section Global handles for modules cvars.
|
||||||
|
*/
|
||||||
|
new Handle:g_hLog = INVALID_HANDLE;
|
||||||
|
new Handle:g_hLogFlags = INVALID_HANDLE;
|
||||||
|
/**
|
||||||
|
* @endsection
|
||||||
|
*/
|
||||||
|
|
||||||
|
LogInit()
|
||||||
|
{
|
||||||
|
// Create modules cvars.
|
||||||
|
g_hLog = CreateConVar("zr_log", "1", "");
|
||||||
|
g_hLogFlags = CreateConVar("zr_logflags", "331", "");
|
||||||
|
// Old Desc: Logging flags. Log messages to sourcemod logs, server console or client console. Use zr_log_flags to see a list of flags. (0: Disable)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs a formatted message with module and block info depending, on the type.
|
* Logs a formatted message with module and block info depending, on the type.
|
||||||
*
|
*
|
||||||
|
@ -75,39 +92,45 @@
|
||||||
LogMessageFormatted(client, const String:module[], const String:block[], const String:message[], type = LOG_FORMAT_TYPE_FULL, any:...)
|
LogMessageFormatted(client, const String:module[], const String:block[], const String:message[], type = LOG_FORMAT_TYPE_FULL, any:...)
|
||||||
{
|
{
|
||||||
// If logging is disabled, then stop.
|
// If logging is disabled, then stop.
|
||||||
new bool:log = GetConVarBool(g_hCvarsList[CVAR_LOG]);
|
new bool:log = GetConVarBool(g_hLog);
|
||||||
if (!log)
|
if (!log)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
decl String:buffer[LOG_MAX_LENGTH_FILE];
|
decl String:logtext[LOG_MAX_LENGTH_FILE];
|
||||||
decl String:text[LOG_MAX_LENGTH_FILE];
|
|
||||||
|
|
||||||
if (client == 0 && LogCheckFlag(LOG_IGNORE_CONSOLE))
|
// Set to true if log to console, false if client.
|
||||||
|
new bool:console = !ZRIsClientValid(client);
|
||||||
|
|
||||||
|
// If client is invalid (console), and console is ignored, then stop.
|
||||||
|
if (console && LogCheckFlag(LOG_IGNORE_CONSOLE))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Format log text.
|
||||||
|
VFormat(logtext, sizeof(logtext), message, 6);
|
||||||
|
|
||||||
|
// Format other parameters onto the log text.
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
|
// Log type is simple.
|
||||||
case LOG_FORMAT_TYPE_SIMPLE:
|
case LOG_FORMAT_TYPE_SIMPLE:
|
||||||
{
|
{
|
||||||
VFormat(buffer, sizeof(buffer), message, 6);
|
LogMessage(logtext);
|
||||||
Format(text, sizeof(text), "%s", message);
|
|
||||||
LogMessage(text);
|
|
||||||
}
|
}
|
||||||
|
// Log type is full.
|
||||||
case LOG_FORMAT_TYPE_FULL:
|
case LOG_FORMAT_TYPE_FULL:
|
||||||
{
|
{
|
||||||
VFormat(buffer, sizeof(buffer), message, 6);
|
Format(logtext, sizeof(logtext), "\"%s\" : \"%s\" -- %s", module, block, logtext);
|
||||||
Format(text, sizeof(text), "\"%s\" : \"%s\" -- %s", module, block, buffer);
|
LogMessage(logtext);
|
||||||
LogMessage(text);
|
|
||||||
}
|
}
|
||||||
|
// Log type is error.
|
||||||
case LOG_FORMAT_TYPE_ERROR:
|
case LOG_FORMAT_TYPE_ERROR:
|
||||||
{
|
{
|
||||||
VFormat(buffer, sizeof(buffer), message, 6);
|
Format(logtext, sizeof(logtext), "\"%s\" : \"%s\" -- %s", module, block, logtext);
|
||||||
Format(text, sizeof(text), "\"%s\" : \"%s\" -- %s", module, block, buffer);
|
LogError(logtext);
|
||||||
LogError(text);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,16 +138,17 @@ LogMessageFormatted(client, const String:module[], const String:block[], const S
|
||||||
if (LogCheckFlag(LOG_TO_ADMINS))
|
if (LogCheckFlag(LOG_TO_ADMINS))
|
||||||
{
|
{
|
||||||
// Print text to admins.
|
// Print text to admins.
|
||||||
LogToAdmins(text);
|
LogToAdmins(logtext);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ZRIsClientValid(client) && LogCheckFlag(LOG_TO_CLIENT))
|
// If client isn't console, and we log to client's then continue.
|
||||||
|
if (!console && LogCheckFlag(LOG_TO_CLIENT))
|
||||||
{
|
{
|
||||||
// Set client as translation target.
|
// Set client as translation target.
|
||||||
SetGlobalTransTarget(client);
|
SetGlobalTransTarget(client);
|
||||||
|
|
||||||
// Print to client.
|
// Print to client.
|
||||||
PrintToConsole(client, "%t %s", "ZR", text);
|
PrintToConsole(client, "%t %s", "ZR", logtext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +188,7 @@ LogToAdmins(String:message[])
|
||||||
bool:LogHasFlag(flag)
|
bool:LogHasFlag(flag)
|
||||||
{
|
{
|
||||||
// Get log flags.
|
// Get log flags.
|
||||||
new logflags = GetConVarInt(g_hCvarsList[CVAR_LOGFLAGS]);
|
new logflags = GetConVarInt(g_hLogFlags);
|
||||||
|
|
||||||
// Return true if flag is found, false if not.
|
// Return true if flag is found, false if not.
|
||||||
return bool:(logflags & flag);
|
return bool:(logflags & flag);
|
||||||
|
@ -174,9 +198,9 @@ bool:LogHasFlag(flag)
|
||||||
* Check if a log message should be written depending on log flags. If module
|
* Check if a log message should be written depending on log flags. If module
|
||||||
* overrides are enabled only logs with it's module flag set will be logged.
|
* overrides are enabled only logs with it's module flag set will be logged.
|
||||||
*
|
*
|
||||||
* @param logtype Log type flag.
|
* @param logtype Log type flag.
|
||||||
* @param module Specifies what module the log event belongs to.
|
* @param modulefilter Specifies what module the log event belongs to.
|
||||||
* @return True if the event should be logged, false otherwise.
|
* @return True if the event should be logged, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool:LogCheckFlag(logtype, modulefilter = 0)
|
bool:LogCheckFlag(logtype, modulefilter = 0)
|
||||||
{
|
{
|
||||||
|
@ -187,3 +211,28 @@ bool:LogCheckFlag(logtype, modulefilter = 0)
|
||||||
|
|
||||||
return LogHasFlag(logtype);
|
return LogHasFlag(logtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggles a log flag.
|
||||||
|
*
|
||||||
|
* @param flag The flag to toggle.
|
||||||
|
*/
|
||||||
|
LogToggleFlag(flag)
|
||||||
|
{
|
||||||
|
// Get current flags
|
||||||
|
new logflags = GetConVarInt(g_hLogFlags);
|
||||||
|
|
||||||
|
// If cvar contains flag, then remove it.
|
||||||
|
if (logflags & flag)
|
||||||
|
{
|
||||||
|
logflags = logflags - flag;
|
||||||
|
}
|
||||||
|
// If cvar doesn't have the flag, then add it.
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logflags = logflags + flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set new value to logflags cvar.
|
||||||
|
SetConVarInt(g_hLogFlags, logflags);
|
||||||
|
}
|
|
@ -17,7 +17,7 @@ new Handle:tRespawn[MAXPLAYERS + 1];
|
||||||
/**
|
/**
|
||||||
* Array for flagging zombies who were killed by world.
|
* Array for flagging zombies who were killed by world.
|
||||||
*/
|
*/
|
||||||
new bool:pKilledByWorld[MAXPLAYERS + 1];
|
new bool:bKilledByWorld[MAXPLAYERS + 1];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Client is joining the server.
|
* Client is joining the server.
|
||||||
|
@ -27,8 +27,8 @@ RespawnClientInit(client)
|
||||||
// Reset timer handle.
|
// Reset timer handle.
|
||||||
tRespawn[client] = INVALID_HANDLE;
|
tRespawn[client] = INVALID_HANDLE;
|
||||||
|
|
||||||
// Init pKilledByWorld for client.
|
// Init bKilledByWorld for client.
|
||||||
pKilledByWorld[client] = false;
|
bKilledByWorld[client] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,8 +58,8 @@ RespawnOnClientDeath(client, attacker, const String:weapon[])
|
||||||
// If client is a zombie, check if they were killed by world.
|
// If client is a zombie, check if they were killed by world.
|
||||||
if (InfectIsClientInfected(client))
|
if (InfectIsClientInfected(client))
|
||||||
{
|
{
|
||||||
// Set pKilledByWorld to true if attacker is not a valid client.
|
// Set bKilledByWorld to true if attacker is not a valid client.
|
||||||
pKilledByWorld[client] = !ZRIsClientValid(attacker);
|
bKilledByWorld[client] = !ZRIsClientValid(attacker);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If timer is running, kill it.
|
// If timer is running, kill it.
|
||||||
|
@ -86,6 +86,34 @@ RespawnOnClientDeath(client, attacker, const String:weapon[])
|
||||||
tRespawn[client] = CreateTimer(delay, RespawnTimer, client, TIMER_FLAG_NO_MAPCHANGE);
|
tRespawn[client] = CreateTimer(delay, RespawnTimer, client, TIMER_FLAG_NO_MAPCHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The round is ending.
|
||||||
|
*/
|
||||||
|
RespawnOnRoundEnd()
|
||||||
|
{
|
||||||
|
// x = client index.
|
||||||
|
for (new x = 1; x <= MaxClients; x++)
|
||||||
|
{
|
||||||
|
// If client isn't in-game, then stop.
|
||||||
|
if (!IsClientInGame(x))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If timer isn't currently running, then stop.
|
||||||
|
if (tRespawn[x] == INVALID_HANDLE)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop timer.
|
||||||
|
KillTimer(tRespawn[x]);
|
||||||
|
|
||||||
|
// Reset timer handle.
|
||||||
|
tRespawn[x] = INVALID_HANDLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if a player is to be respawned as a zombie, because they were killed by world.
|
* Returns if a player is to be respawned as a zombie, because they were killed by world.
|
||||||
*
|
*
|
||||||
|
@ -95,7 +123,7 @@ RespawnOnClientDeath(client, attacker, const String:weapon[])
|
||||||
RespawnKilledByWorld(client)
|
RespawnKilledByWorld(client)
|
||||||
{
|
{
|
||||||
// Return true if both the cvar is enabled and the player was killed by world.
|
// Return true if both the cvar is enabled and the player was killed by world.
|
||||||
return (GetConVarBool(g_hCvarsList[CVAR_RESPAWN_ZOMBIE_WORLD]) && pKilledByWorld[client]);
|
return (GetConVarBool(g_hCvarsList[CVAR_RESPAWN_ZOMBIE_WORLD]) && bKilledByWorld[client]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -130,10 +158,10 @@ RespawnSpawnClient(client)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetConVarBool(g_hCvarsList[CVAR_RESPAWN_ZOMBIE_WORLD]) && pKilledByWorld[client])
|
if (GetConVarBool(g_hCvarsList[CVAR_RESPAWN_ZOMBIE_WORLD]) && bKilledByWorld[client])
|
||||||
{
|
{
|
||||||
InfectClient(client);
|
InfectClient(client);
|
||||||
pKilledByWorld[client] = false;
|
bKilledByWorld[client] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,9 +47,9 @@
|
||||||
*/
|
*/
|
||||||
enum RoundEndOutcome
|
enum RoundEndOutcome
|
||||||
{
|
{
|
||||||
HumansWin, /** Humans have killed all zombies. */
|
HumansWin, /** Humans have killed all zombies. */
|
||||||
ZombiesWin, /** Zombies have infected all humans. */
|
ZombiesWin, /** Zombies have infected all humans. */
|
||||||
Draw, /** Round has ended in unexpected way. */
|
Draw, /** Round has ended in unexpected way. */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -84,10 +84,21 @@ RoundEndClientInit(client)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Client has been killed.
|
* Client has been killed.
|
||||||
*
|
|
||||||
* @param client The client index.
|
|
||||||
*/
|
*/
|
||||||
RoundEndOnClientDeath()
|
RoundEndOnClientDeath()
|
||||||
|
{
|
||||||
|
// Terminate the round if the last player was killed.
|
||||||
|
new RoundEndOutcome:outcome;
|
||||||
|
if (RoundEndGetRoundStatus(outcome))
|
||||||
|
{
|
||||||
|
RoundEndTerminateRound(outcome);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Client has been infected.
|
||||||
|
*/
|
||||||
|
RoundEndOnClientInfected()
|
||||||
{
|
{
|
||||||
// Terminate the round if the last player was infected.
|
// Terminate the round if the last player was infected.
|
||||||
new RoundEndOutcome:outcome;
|
new RoundEndOutcome:outcome;
|
||||||
|
@ -111,12 +122,6 @@ RoundEndOnRoundStart()
|
||||||
// Reset timer handle.
|
// Reset timer handle.
|
||||||
tRoundEnd = INVALID_HANDLE;
|
tRoundEnd = INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tell plugin no zombies have been spawned.
|
|
||||||
g_bZombieSpawned = false;
|
|
||||||
|
|
||||||
// Balance teams, and respawn all players.
|
|
||||||
RoundEndBalanceTeams(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -331,12 +336,23 @@ RoundEndTerminateRound(RoundEndOutcome:outcome)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restarts the game.
|
||||||
|
*
|
||||||
|
* @param delay How long to wait between round end and new round.
|
||||||
|
*/
|
||||||
|
RoundEndRestart(Float:delay)
|
||||||
|
{
|
||||||
|
// Terminate the round.
|
||||||
|
TerminateRound(delay, ROUNDEND_GAME_COMMENCING);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Balances teams
|
* Balances teams
|
||||||
*
|
*
|
||||||
* @param spawn If true, it will respawn player after switching their team.
|
* @param spawn If true, it will respawn player after switching their team.
|
||||||
*/
|
*/
|
||||||
RoundEndBalanceTeams(bool:spawn = false)
|
RoundEndBalanceTeams()
|
||||||
{
|
{
|
||||||
// Create eligible player list.
|
// Create eligible player list.
|
||||||
new Handle:arrayEligibleClients = INVALID_HANDLE;
|
new Handle:arrayEligibleClients = INVALID_HANDLE;
|
||||||
|
@ -376,29 +392,6 @@ RoundEndBalanceTeams(bool:spawn = false)
|
||||||
CS_SwitchTeam(client, CS_TEAM_CT);
|
CS_SwitchTeam(client, CS_TEAM_CT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If spawn is false, then stop.
|
|
||||||
if (!spawn)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// x = array index.
|
|
||||||
// client = client index.
|
|
||||||
for (new x = 0; x < eligibleclients; x++)
|
|
||||||
{
|
|
||||||
// Get client stored in array index.
|
|
||||||
client = GetArrayCell(arrayEligibleClients, x);
|
|
||||||
|
|
||||||
// If client is dead, then stop.
|
|
||||||
if (!IsPlayerAlive(client))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Respawn client.
|
|
||||||
CS_RespawnPlayer(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Destroy handle.
|
// Destroy handle.
|
||||||
CloseHandle(arrayEligibleClients);
|
CloseHandle(arrayEligibleClients);
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@ AmbientSoundsOnRoundStart()
|
||||||
*
|
*
|
||||||
* @param client The client index.
|
* @param client The client index.
|
||||||
*/
|
*/
|
||||||
AmbientSoundsOnClientSpawnPost(client)
|
AmbientSoundsOnClientSpawn(client)
|
||||||
{
|
{
|
||||||
// If ambience is disabled, then stop.
|
// If ambience is disabled, then stop.
|
||||||
if (!g_bAmbientSounds)
|
if (!g_bAmbientSounds)
|
||||||
|
|
|
@ -69,20 +69,10 @@ SEffectsOnRoundStart()
|
||||||
SEffectsOnClientSpawn(client)
|
SEffectsOnClientSpawn(client)
|
||||||
{
|
{
|
||||||
// Forward event to sub-modules.
|
// Forward event to sub-modules.
|
||||||
//AmbientSoundsOnClientSpawn(client);
|
AmbientSoundsOnClientSpawn(client);
|
||||||
ZombieSoundsOnClientSpawn(client);
|
ZombieSoundsOnClientSpawn(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Fired one frame after client spawns into the game.
|
|
||||||
*
|
|
||||||
* @param client The client index.
|
|
||||||
*/
|
|
||||||
SEffectsOnClientSpawnPost(client)
|
|
||||||
{
|
|
||||||
AmbientSoundsOnClientSpawnPost(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Client has been killed.
|
* Client has been killed.
|
||||||
*
|
*
|
||||||
|
|
|
@ -36,7 +36,19 @@ VEffectsLoad()
|
||||||
// Store map's default sky before applying new one.
|
// Store map's default sky before applying new one.
|
||||||
GetConVarString(g_hSkyname, g_VEffectsDefaultSky, sizeof(g_VEffectsDefaultSky));
|
GetConVarString(g_hSkyname, g_VEffectsDefaultSky, sizeof(g_VEffectsDefaultSky));
|
||||||
|
|
||||||
// TODO add sky to downloads table.
|
// If sky path is empty, then stop.
|
||||||
|
if (!g_VEffectsDefaultSky[0])
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
decl String:downloadpath[PLATFORM_MAX_PATH];
|
||||||
|
|
||||||
|
// Prepend materials/skybox to the path.
|
||||||
|
Format(downloadpath, sizeof(downloadpath), "materials/skybox/%s", g_VEffectsDefaultSky);
|
||||||
|
|
||||||
|
// Add skybox file to downloads table.
|
||||||
|
AddFileToDownloadsTable(downloadpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,6 +67,12 @@ VEffectsOnRoundStart()
|
||||||
|
|
||||||
// Apply new sky.
|
// Apply new sky.
|
||||||
VEffectsApplySky(!sky);
|
VEffectsApplySky(!sky);
|
||||||
|
|
||||||
|
// If fog is disabled, then disable.
|
||||||
|
new bool:fogoverride = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_FOG_OVERRIDE]);
|
||||||
|
|
||||||
|
// Apply fog.
|
||||||
|
VEffectsApplyFog(fogoverride);
|
||||||
}
|
}
|
||||||
|
|
||||||
VEffectsApplyLightStyle(bool:disable = false)
|
VEffectsApplyLightStyle(bool:disable = false)
|
||||||
|
@ -94,3 +112,218 @@ VEffectsApplySky(bool:disable = false)
|
||||||
// Set new sky on all clients.
|
// Set new sky on all clients.
|
||||||
SetConVarString(g_hSkyname, skypath, true);
|
SetConVarString(g_hSkyname, skypath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VEffectsApplyFog(bool:override = false)
|
||||||
|
{
|
||||||
|
// Find current fog index
|
||||||
|
new fogindex = FindEntityByClassname(-1, "env_fog_controller");
|
||||||
|
|
||||||
|
// If override is enabled, then continue.
|
||||||
|
if (override)
|
||||||
|
{
|
||||||
|
// If there is fog, then continue.
|
||||||
|
if (fogindex != -1)
|
||||||
|
{
|
||||||
|
// Delete fog.
|
||||||
|
RemoveEdict(fogindex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If fog is disabled, then stop.
|
||||||
|
new bool:fog = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_FOG]);
|
||||||
|
if (!fog)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If there is no fog on the map, create new fog.
|
||||||
|
if (fogindex == -1)
|
||||||
|
{
|
||||||
|
// Create and spawn fog.
|
||||||
|
fogindex = CreateEntityByName("env_fog_controller");
|
||||||
|
DispatchSpawn(fogindex);
|
||||||
|
}
|
||||||
|
|
||||||
|
decl String:fogcolor[16];
|
||||||
|
|
||||||
|
// Set primary fog color.
|
||||||
|
GetConVarString(g_hCvarsList[CVAR_VEFFECTS_FOG_PCOLOR], fogcolor, sizeof(fogcolor));
|
||||||
|
VEffectsSetFogColor(fogindex, fogcolor, true);
|
||||||
|
|
||||||
|
// Set secondary fog color.
|
||||||
|
GetConVarString(g_hCvarsList[CVAR_VEFFECTS_FOG_SCOLOR], fogcolor, sizeof(fogcolor));
|
||||||
|
VEffectsSetFogColor(fogindex, fogcolor, false);
|
||||||
|
|
||||||
|
// Set fog's density.
|
||||||
|
new Float:fogdensity = GetConVarFloat(g_hCvarsList[CVAR_VEFFECTS_FOG_DENSITY]);
|
||||||
|
VEffectsSetFogDensity(fogindex, fogdensity);
|
||||||
|
|
||||||
|
// Set fog's start distance.
|
||||||
|
new fogstart = GetConVarInt(g_hCvarsList[CVAR_VEFFECTS_FOG_STARTDIST]);
|
||||||
|
VEffectsSetFogStartDist(fogindex, fogstart);
|
||||||
|
|
||||||
|
// Set fog's end distance.
|
||||||
|
new fogend = GetConVarInt(g_hCvarsList[CVAR_VEFFECTS_FOG_ENDDIST]);
|
||||||
|
VEffectsSetFogEndDist(fogindex, fogend);
|
||||||
|
|
||||||
|
// Set fog's far z distance.
|
||||||
|
new fogfarz = GetConVarInt(g_hCvarsList[CVAR_VEFFECTS_FOG_FARZ]);
|
||||||
|
VEffectsSetFogFarZ(fogindex, fogfarz);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set fog's primary or secondary color.
|
||||||
|
*
|
||||||
|
* @param fogindex Edict index of the fog to modify.
|
||||||
|
* @param color The rgb color of the fog.
|
||||||
|
* @param primary (Optional) True to set primary, false otherwise.
|
||||||
|
*/
|
||||||
|
VEffectsSetFogColor(fogindex, const String:color[], bool:primary = true)
|
||||||
|
{
|
||||||
|
// Set primary color.
|
||||||
|
if (primary)
|
||||||
|
{
|
||||||
|
// Set new color.
|
||||||
|
SetVariantString(color);
|
||||||
|
AcceptEntityInput(fogindex, "SetColor");
|
||||||
|
}
|
||||||
|
// Set secondary color.
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Set new color.
|
||||||
|
SetVariantString(color);
|
||||||
|
AcceptEntityInput(fogindex, "SetColorSecondary");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set fog's density.
|
||||||
|
*
|
||||||
|
* @param fogindex Edict index of the fog to modify.
|
||||||
|
* @param density The density of the fog.
|
||||||
|
*/
|
||||||
|
VEffectsSetFogDensity(fogindex, Float:density)
|
||||||
|
{
|
||||||
|
// Set density.
|
||||||
|
DispatchKeyValueFloat(fogindex, "fogmaxdensity", density);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set fog's start distance.
|
||||||
|
*
|
||||||
|
* @param fogindex Edict index of the fog to modify.
|
||||||
|
* @param startdist The start distance of the fog.
|
||||||
|
*/
|
||||||
|
VEffectsSetFogStartDist(fogindex, startdist)
|
||||||
|
{
|
||||||
|
// Set start distance.
|
||||||
|
SetVariantInt(startdist);
|
||||||
|
AcceptEntityInput(fogindex, "SetStartDist");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set fog's end distance.
|
||||||
|
*
|
||||||
|
* @param fogindex Edict index of the fog to modify.
|
||||||
|
* @param enddist The end distance of the fog.
|
||||||
|
*/
|
||||||
|
VEffectsSetFogEndDist(fogindex, enddist)
|
||||||
|
{
|
||||||
|
// Set end distance.
|
||||||
|
SetVariantInt(enddist);
|
||||||
|
AcceptEntityInput(fogindex, "SetEndDist");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set fog's far z distance.
|
||||||
|
*
|
||||||
|
* @param fogindex Edict index of the fog to modify.
|
||||||
|
* @param farz The far z distance of the fog.
|
||||||
|
*/
|
||||||
|
VEffectsSetFogFarZ(fogindex, farz)
|
||||||
|
{
|
||||||
|
// Set far z distance.
|
||||||
|
SetVariantInt(farz);
|
||||||
|
AcceptEntityInput(fogindex, "SetFarZ");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an energy splash effect.
|
||||||
|
*
|
||||||
|
* @param client The client index.
|
||||||
|
* @param origin The origin of the effect.
|
||||||
|
* @param direction The direction of the effect.
|
||||||
|
*/
|
||||||
|
VEffectsCreateEnergySplash(const Float:origin[3], const Float:direction[3], bool:explosive)
|
||||||
|
{
|
||||||
|
TE_SetupEnergySplash(origin, direction, explosive);
|
||||||
|
TE_SendToAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an explosion effect with strict flags.
|
||||||
|
*
|
||||||
|
* @param origin The (x, y, z) coordinate of the explosion.
|
||||||
|
* @param flags The flags to set on the explosion.
|
||||||
|
*/
|
||||||
|
VEffectsCreateExplosion(const Float:origin[3], flags)
|
||||||
|
{
|
||||||
|
// Create an explosion entity.
|
||||||
|
new explosion = CreateEntityByName("env_explosion");
|
||||||
|
|
||||||
|
// If explosion entity isn't valid, then stop.
|
||||||
|
if (explosion == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get and modify flags on explosion.
|
||||||
|
new spawnflags = GetEntProp(explosion, Prop_Data, "m_spawnflags");
|
||||||
|
spawnflags = spawnflags | EXP_NODAMAGE | EXP_NODECAL | flags;
|
||||||
|
|
||||||
|
// Set modified flags on entity.
|
||||||
|
SetEntProp(explosion, Prop_Data, "m_spawnflags", spawnflags);
|
||||||
|
|
||||||
|
// Spawn the entity into the world.
|
||||||
|
DispatchSpawn(explosion);
|
||||||
|
|
||||||
|
// Set the origin of the explosion.
|
||||||
|
DispatchKeyValueVector(explosion, "origin", origin);
|
||||||
|
|
||||||
|
// Set fireball material.
|
||||||
|
PrecacheModel("materials/sprites/xfireball3.vmt");
|
||||||
|
DispatchKeyValue(explosion, "fireballsprite", "materials/sprites/xfireball3.vmt");
|
||||||
|
|
||||||
|
// Tell the entity to explode.
|
||||||
|
AcceptEntityInput(explosion, "Explode");
|
||||||
|
|
||||||
|
// Remove entity from world.
|
||||||
|
RemoveEdict(explosion);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shake a client's screen with specific parameters.
|
||||||
|
*
|
||||||
|
* @param client The client index.
|
||||||
|
* @param amplitude The amplitude (intensity) of the shaking.
|
||||||
|
* @param frequency The frequency (speed) of the shaking.
|
||||||
|
* @param duration The duration (time) of the shaking.
|
||||||
|
*/
|
||||||
|
VEffectsShakeClientScreen(client, Float:amplitude, Float:frequency, Float:duration)
|
||||||
|
{
|
||||||
|
// If shake usermsg isn't invalid, then stop.
|
||||||
|
new Handle:hShake = StartMessageOne("Shake", client);
|
||||||
|
if (hShake == INVALID_HANDLE)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write shake information to usermsg handle.
|
||||||
|
BfWriteByte(hShake, 0);
|
||||||
|
BfWriteFloat(hShake, amplitude);
|
||||||
|
BfWriteFloat(hShake, frequency);
|
||||||
|
BfWriteFloat(hShake, duration);
|
||||||
|
|
||||||
|
// End usermsg and send to client.
|
||||||
|
EndMessage();
|
||||||
|
}
|
|
@ -42,7 +42,9 @@ RestrictInit()
|
||||||
gRestrictedWeapons = CreateArray(32, 0);
|
gRestrictedWeapons = CreateArray(32, 0);
|
||||||
|
|
||||||
// Hook buy command.
|
// Hook buy command.
|
||||||
RegConsoleCmd("buy", RestrictBuyHook);
|
RegConsoleCmd("buy", RestrictBuyCommand);
|
||||||
|
RegConsoleCmd("autobuy", RestrictBuyCommand);
|
||||||
|
RegConsoleCmd("rebuy", RestrictBuyCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -136,7 +138,7 @@ RestrictDefaultRestrictions()
|
||||||
*/
|
*/
|
||||||
RestrictValidateWeaponGroups()
|
RestrictValidateWeaponGroups()
|
||||||
{
|
{
|
||||||
// If log flag check fails, don't log.
|
// If log flag check fails, then don't log.
|
||||||
if (!LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_WEAPONS))
|
if (!LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_WEAPONS))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -215,17 +217,18 @@ RestrictOnClientDisconnect(client)
|
||||||
* @param client The client index.
|
* @param client The client index.
|
||||||
* @param argc Argument count.
|
* @param argc Argument count.
|
||||||
*/
|
*/
|
||||||
public Action:RestrictBuyHook(client, argc)
|
public Action:RestrictBuyCommand(client, argc)
|
||||||
{
|
{
|
||||||
// If plugin is disabled then stop.
|
// If plugin is disabled then stop.
|
||||||
new bool:enabled = GetConVarBool(g_hCvarsList[CVAR_ENABLE]);
|
/*new bool:enabled = GetConVarBool(g_hCvarsList[CVAR_ENABLE]);
|
||||||
if (!enabled)
|
if (!enabled)
|
||||||
{
|
{
|
||||||
// Allow command.
|
// Allow command.
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}*/
|
||||||
|
// Disabled
|
||||||
|
|
||||||
// If player is a zombie then block command.
|
// If player is a zombie, then block command.
|
||||||
if (InfectIsClientInfected(client))
|
if (InfectIsClientInfected(client))
|
||||||
{
|
{
|
||||||
ZR_PrintToChat(client, "Zombie cant use weapon");
|
ZR_PrintToChat(client, "Zombie cant use weapon");
|
||||||
|
|
|
@ -108,7 +108,7 @@ WeaponsLoad()
|
||||||
*/
|
*/
|
||||||
WeaponsValidateConfig()
|
WeaponsValidateConfig()
|
||||||
{
|
{
|
||||||
// If log flag check fails, don't log.
|
// If log flag check fails, then don't log.
|
||||||
if (!LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_WEAPONS))
|
if (!LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_WEAPONS))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -583,112 +583,112 @@ public ZRLogFlagsMenuHandle(Handle:menu_log_flags, MenuAction:action, client, sl
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
ToggleLogFlag(LOG_CORE_EVENTS);
|
LogToggleFlag(LOG_CORE_EVENTS);
|
||||||
ZRLogFlagsMenu(client);
|
ZRLogFlagsMenu(client);
|
||||||
}
|
}
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
ToggleLogFlag(LOG_GAME_EVENTS);
|
LogToggleFlag(LOG_GAME_EVENTS);
|
||||||
ZRLogFlagsMenu(client);
|
ZRLogFlagsMenu(client);
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
ToggleLogFlag(LOG_PLAYER_COMMANDS);
|
LogToggleFlag(LOG_PLAYER_COMMANDS);
|
||||||
ZRLogFlagsMenu(client);
|
ZRLogFlagsMenu(client);
|
||||||
}
|
}
|
||||||
case 3:
|
case 3:
|
||||||
{
|
{
|
||||||
ToggleLogFlag(LOG_DEBUG);
|
LogToggleFlag(LOG_DEBUG);
|
||||||
ZRLogFlagsMenu(client);
|
ZRLogFlagsMenu(client);
|
||||||
}
|
}
|
||||||
case 4:
|
case 4:
|
||||||
{
|
{
|
||||||
ToggleLogFlag(LOG_DEBUG_DETAIL);
|
LogToggleFlag(LOG_DEBUG_DETAIL);
|
||||||
ZRLogFlagsMenu(client);
|
ZRLogFlagsMenu(client);
|
||||||
}
|
}
|
||||||
case 5:
|
case 5:
|
||||||
{
|
{
|
||||||
ToggleLogFlag(LOG_DEBUG_MAX_DETAIL);
|
LogToggleFlag(LOG_DEBUG_MAX_DETAIL);
|
||||||
ZRLogFlagsMenu(client);
|
ZRLogFlagsMenu(client);
|
||||||
}
|
}
|
||||||
case 6:
|
case 6:
|
||||||
{
|
{
|
||||||
ToggleLogFlag(LOG_TO_ADMINS);
|
LogToggleFlag(LOG_TO_ADMINS);
|
||||||
ZRLogFlagsMenu(client);
|
ZRLogFlagsMenu(client);
|
||||||
}
|
}
|
||||||
case 7:
|
case 7:
|
||||||
{
|
{
|
||||||
ToggleLogFlag(LOG_TO_CLIENT);
|
LogToggleFlag(LOG_TO_CLIENT);
|
||||||
ZRLogFlagsMenu(client);
|
ZRLogFlagsMenu(client);
|
||||||
}
|
}
|
||||||
case 8:
|
case 8:
|
||||||
{
|
{
|
||||||
ToggleLogFlag(LOG_IGNORE_CONSOLE);
|
LogToggleFlag(LOG_IGNORE_CONSOLE);
|
||||||
ZRLogFlagsMenu(client);
|
ZRLogFlagsMenu(client);
|
||||||
}
|
}
|
||||||
case 9:
|
case 9:
|
||||||
{
|
{
|
||||||
ToggleLogFlag(LOG_MODULES_ENABLED);
|
LogToggleFlag(LOG_MODULES_ENABLED);
|
||||||
ZRLogFlagsMenu(client);
|
ZRLogFlagsMenu(client);
|
||||||
}
|
}
|
||||||
case 10:
|
case 10:
|
||||||
{
|
{
|
||||||
ToggleLogFlag(LOG_MODULE_ZOMBIE);
|
LogToggleFlag(LOG_MODULE_ZOMBIE);
|
||||||
ZRLogFlagsMenu(client);
|
ZRLogFlagsMenu(client);
|
||||||
}
|
}
|
||||||
case 11:
|
case 11:
|
||||||
{
|
{
|
||||||
ToggleLogFlag(LOG_MODULE_AMBIENTSOUNDS);
|
LogToggleFlag(LOG_MODULE_AMBIENTSOUNDS);
|
||||||
ZRLogFlagsMenu(client);
|
ZRLogFlagsMenu(client);
|
||||||
}
|
}
|
||||||
case 12:
|
case 12:
|
||||||
{
|
{
|
||||||
ToggleLogFlag(LOG_MODULE_OVERLAYS);
|
LogToggleFlag(LOG_MODULE_OVERLAYS);
|
||||||
ZRLogFlagsMenu(client);
|
ZRLogFlagsMenu(client);
|
||||||
}
|
}
|
||||||
case 13:
|
case 13:
|
||||||
{
|
{
|
||||||
ToggleLogFlag(LOG_MODULE_SAYTRIGGERS);
|
LogToggleFlag(LOG_MODULE_SAYTRIGGERS);
|
||||||
ZRLogFlagsMenu(client);
|
ZRLogFlagsMenu(client);
|
||||||
}
|
}
|
||||||
case 14:
|
case 14:
|
||||||
{
|
{
|
||||||
ToggleLogFlag(LOG_MODULE_TELEPORT);
|
LogToggleFlag(LOG_MODULE_TELEPORT);
|
||||||
ZRLogFlagsMenu(client);
|
ZRLogFlagsMenu(client);
|
||||||
}
|
}
|
||||||
case 15:
|
case 15:
|
||||||
{
|
{
|
||||||
ToggleLogFlag(LOG_MODULE_CLASSES);
|
LogToggleFlag(LOG_MODULE_CLASSES);
|
||||||
ZRLogFlagsMenu(client);
|
ZRLogFlagsMenu(client);
|
||||||
}
|
}
|
||||||
case 16:
|
case 16:
|
||||||
{
|
{
|
||||||
ToggleLogFlag(LOG_MODULE_WEAPONS);
|
LogToggleFlag(LOG_MODULE_WEAPONS);
|
||||||
ZRLogFlagsMenu(client);
|
ZRLogFlagsMenu(client);
|
||||||
}
|
}
|
||||||
case 17:
|
case 17:
|
||||||
{
|
{
|
||||||
ToggleLogFlag(LOG_MODULE_HITGROUPS);
|
LogToggleFlag(LOG_MODULE_HITGROUPS);
|
||||||
ZRLogFlagsMenu(client);
|
ZRLogFlagsMenu(client);
|
||||||
}
|
}
|
||||||
case 18:
|
case 18:
|
||||||
{
|
{
|
||||||
ToggleLogFlag(LOG_MODULE_COMMANDS);
|
LogToggleFlag(LOG_MODULE_COMMANDS);
|
||||||
ZRLogFlagsMenu(client);
|
ZRLogFlagsMenu(client);
|
||||||
}
|
}
|
||||||
case 19:
|
case 19:
|
||||||
{
|
{
|
||||||
ToggleLogFlag(LOG_MODULE_ANTICAMP);
|
LogToggleFlag(LOG_MODULE_ANTICAMP);
|
||||||
ZRLogFlagsMenu(client);
|
ZRLogFlagsMenu(client);
|
||||||
}
|
}
|
||||||
case 20:
|
case 20:
|
||||||
{
|
{
|
||||||
ToggleLogFlag(LOG_MODULE_DAMAGE);
|
LogToggleFlag(LOG_MODULE_DAMAGE);
|
||||||
ZRLogFlagsMenu(client);
|
ZRLogFlagsMenu(client);
|
||||||
}
|
}
|
||||||
case 21:
|
case 21:
|
||||||
{
|
{
|
||||||
ToggleLogFlag(LOG_MODULE_OFFSETS);
|
LogToggleFlag(LOG_MODULE_OFFSETS);
|
||||||
ZRLogFlagsMenu(client);
|
ZRLogFlagsMenu(client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -716,20 +716,3 @@ AddToClassKnockback(classindex, Float:value)
|
||||||
{
|
{
|
||||||
arrayClasses[classindex][data_knockback] = arrayClasses[classindex][data_knockback] + value;
|
arrayClasses[classindex][data_knockback] = arrayClasses[classindex][data_knockback] + value;
|
||||||
}
|
}
|
||||||
|
|
||||||
ToggleLogFlag(flag)
|
|
||||||
{
|
|
||||||
new log_flags;
|
|
||||||
log_flags = GetConVarInt(g_hCvarsList[CVAR_LOG]);
|
|
||||||
|
|
||||||
if (log_flags & flag)
|
|
||||||
{
|
|
||||||
log_flags = log_flags - flag;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
log_flags = log_flags + flag;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetConVarInt(g_hCvarsList[CVAR_LOG], log_flags);
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user