This commit is contained in:
test 2009-04-29 01:58:41 +02:00
parent abd38ee033
commit fd129e561b
28 changed files with 1065 additions and 490 deletions

View File

@ -1,9 +1,12 @@
/**
* ====================
/*
* ============================================================================
*
* Zombie:Reloaded
* File: zombiereloaded.sp
* Author: Greyscale
* ====================
*
* File: (base) zombiereloaded.sp
* Description: Plugins base file.
*
* ============================================================================
*/
#pragma semicolon 1
@ -17,123 +20,96 @@
#define VERSION "3.0-dev"
// Core include
// Core includes.
#include "zr/zombiereloaded"
// External api (not done)
//#include "zr/global"
// Log (core)
#include "zr/log"
// Cvars (core)
#include "zr/cvars"
// Translations (core)
#include "zr/translation"
// Offsets (core)
#include "zr/offsets"
// Models (core)
#include "zr/tools"
#include "zr/models"
// Class System (core)
#include "zr/playerclasses/playerclasses"
// Weapons (core)
#include "zr/weapons/weapons"
// Hitgroups (core)
#include "zr/hitgroups"
// Round End (core)
#include "zr/roundend"
// Infect (core)
#include "zr/infect"
// Damage (core)
#include "zr/damage"
// Account (module)
#include "zr/account"
// Visual Effects (module)
#include "zr/visualeffects"
// Sound Effects (module)
#include "zr/soundeffects/soundeffects"
// Antistick (module)
#include "zr/antistick"
// Knockback (module)
#include "zr/knockback"
// Spawn Protect (module)
#include "zr/spawnprotect"
// Respawn (module)
#include "zr/respawn"
// Napalm (module)
#include "zr/napalm"
// ZHP (module)
#include "zr/zhp"
#include "zr/anticamp"
#include "zr/teleport"
#include "zr/zombie"
#include "zr/menu"
#include "zr/sayhooks"
#include "zr/event"
#include "zr/zadmin"
#include "zr/commands"
//#include "zr/global"
// Event
#include "zr/event"
// Modules
#include "zr/account"
#include "zr/visualeffects"
#include "zr/soundeffects/soundeffects"
#include "zr/antistick"
#include "zr/knockback"
#include "zr/spawnprotect"
#include "zr/respawn"
#include "zr/napalm"
#include "zr/zspawn"
#include "zr/zhp"
#include "zr/jumpboost"
#include "zr/anticamp"
#include "zr/teleport"
// Almost replaced! :)
#include "zr/zombie"
/**
* Tell SM ZR's info.
*/
public Plugin:myinfo =
{
name = "Zombie:Reloaded",
author = "Greyscale",
description = "Infection/survival style gameplay",
version = VERSION,
name = "Zombie:Reloaded",
author = "Greyscale, Rhelgeby (Richard)",
description = "Infection/survival style gameplay",
version = VERSION,
url = ""
};
/**
* Called before plugin is loaded.
*
* @param myself The plugin handle.
* @param late True if the plugin was loaded after map change, false on map start.
* @param error Error message if load failed.
* @param err_max Max length of the error message.
*/
public bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max)
{
// Todo: External API
//CreateGlobals();
// TODO: EXTERNAL API
// Let plugin load.
return true;
}
/**
* Plugin is loading.
*/
public OnPluginStart()
{
// Load translations phrases used by plugin.
LoadTranslations("common.phrases.txt");
LoadTranslations("zombiereloaded.phrases.txt");
// ======================================================================
// Start loading ZR init functions.
ZR_PrintToServer("Plugin loading");
// ======================================================================
// Log
LogInit();
// Cvars
CvarsInit();
// Tools
ToolsInit();
// TODO: Be modulized/recoded.
HookChatCmds();
CreateCommands();
HookCommands();
FindOffsets();
SetupGameData();
// Weapons
WeaponsInit();
@ -141,40 +117,53 @@ public OnPluginStart()
// Damage
DamageInit();
// Say Hooks
SayHooksInit();
// Event
EventInit();
// ======================================================================
// Set market variable to true if market is installed.
g_bMarket = LibraryExists("market");
// ======================================================================
// Create public cvar for tracking.
CreateConVar("gs_zombiereloaded_version", VERSION, "[ZR] Current version of this plugin", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_UNLOGGED|FCVAR_DONTRECORD|FCVAR_REPLICATED|FCVAR_NOTIFY);
CreateConVar("zombie_version", VERSION, "Zombie:Reloaded Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_UNLOGGED|FCVAR_DONTRECORD|FCVAR_REPLICATED|FCVAR_NOTIFY);
CreateConVar("zombie_enabled", "1", "Not synced with zr_enable", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_UNLOGGED|FCVAR_DONTRECORD|FCVAR_REPLICATED|FCVAR_NOTIFY);
// ======================================================================
// Finish loading ZR init functions.
ZR_PrintToServer("Plugin loaded");
}
/**
* Library is being removed.
*
* @param name The name of the library.
*/
public OnLibraryRemoved(const String:name[])
{
if (StrEqual(name, "market"))
{
g_bMarket = false;
}
}
public OnLibraryAdded(const String:name[])
{
if (StrEqual(name, "market"))
{
g_bMarket = true;
}
// If market is being removed, then set variable to false.
if (StrEqual(name, "market", false))
{
g_bMarket = false;
}
}
/**
* Library is being added.
*
* @param name The name of the library.
*/
public OnLibraryAdded(const String:name[])
{
// If market is being added, then set variable to true.
if (StrEqual(name, "market", false))
{
g_bMarket = true;
}
}
/**
* The map is starting.
*/
public OnMapStart()
{
LoadModelData();
@ -189,14 +178,21 @@ public OnMapStart()
Anticamp_Startup();
}
/**
* The map is ending.
*/
public OnMapEnd()
{
// Forward event to modules.
Anticamp_Disable();
}
/**
* Configs just finished getting executed.
*/
public OnConfigsExecuted()
{
// TODO: move to config module when made.
decl String:mapconfig[PLATFORM_MAX_PATH];
GetCurrentMap(mapconfig, sizeof(mapconfig));
@ -223,6 +219,11 @@ public OnConfigsExecuted()
SEffectsLoad();
}
/**
* Client is joining the server.
*
* @param client The client index.
*/
public OnClientPutInServer(client)
{
// Forward event to modules.
@ -237,6 +238,11 @@ public OnClientPutInServer(client)
ZHPClientInit(client);
}
/**
* Client is leaving the server.
*
* @param client The client index.
*/
public OnClientDisconnect(client)
{
// Forward event to modules.
@ -244,5 +250,6 @@ public OnClientDisconnect(client)
WeaponsOnClientDisconnect(client);
InfectOnClientDisconnect(client);
DamageOnClientDisconnect(client);
ZSpawnOnClientDisconnect(client);
ZTeleResetClient(client);
}

View File

@ -55,5 +55,5 @@ AccountSetClientCash(client, value)
}
// Set client's cash.
SetEntData(client, offsAccount, value, 4);
SetEntData(client, g_iToolsAccount, value, 4);
}

View File

@ -6,12 +6,21 @@
* ====================
*/
/**
* @section Collision values.
*/
#define ANTISTICK_COLLISIONS_OFF 2
#define ANTISTICK_COLLISIONS_ON 5
/**
* @endsection
*/
/**
* @section Offsets relating to player hull dimensions.
*/
#define PLAYER_HULL_XY_OFFSET 32
#define PLAYER_HULL_Z_OFFSET 12
#define PLAYER_HULL_STACK_OFFSET 14
#define ANTISTICK_PLAYER_HULL_XY_OFFSET 32
#define ANTISTICK_PLAYER_HULL_Z_OFFSET 12
#define ANTISTICK_PLAYER_HULL_STACK_OFFSET 14
/**
* @endsection
*/
@ -79,7 +88,7 @@ AntiStickIsStuck(client)
// x-y plane distance formula: sqrt((x2-x1)^2 + (y2-y1)^2)
new Float:xydistance = SquareRoot(Pow(stuckloc[0] - clientloc[0], 2.0) + Pow(stuckloc[1] - clientloc[1], 2.0));
if (xydistance < PLAYER_HULL_XY_OFFSET)
if (xydistance < ANTISTICK_PLAYER_HULL_XY_OFFSET)
{
if (clientloc[2] <= stuckloc[2])
{
@ -87,10 +96,10 @@ AntiStickIsStuck(client)
GetClientEyePosition(client, eyeloc);
// Get the distance between the eyes and feet and subtract the stack "view crush."
new Float:eyedistance = FloatAbs(eyeloc[2] - clientloc[2]) - PLAYER_HULL_STACK_OFFSET;
new Float:eyedistance = FloatAbs(eyeloc[2] - clientloc[2]) - ANTISTICK_PLAYER_HULL_STACK_OFFSET;
new Float:zdistance = FloatAbs(stuckloc[2] - clientloc[2]);
if (zdistance <= eyedistance + PLAYER_HULL_Z_OFFSET)
if (zdistance <= eyedistance + ANTISTICK_PLAYER_HULL_Z_OFFSET)
{
return x;
}
@ -122,15 +131,15 @@ public Action:AntiStickTimer(Handle:timer)
continue;
}
if (CanCollide(x))
if (AntiStickClientCollisionGroup(x, false))
{
NoCollide(x, true);
AntiStickClientCollisionGroup(x, true, ANTISTICK_COLLISIONS_OFF);
CreateTimer(0.5, AntiStickSolidify, x, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
}
if (CanCollide(stuckindex))
if (AntiStickClientCollisionGroup(stuckindex, false))
{
NoCollide(stuckindex, true);
AntiStickClientCollisionGroup(stuckindex, true, ANTISTICK_COLLISIONS_OFF);
CreateTimer(0.5, AntiStickSolidify, stuckindex, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
}
}
@ -146,7 +155,7 @@ public Action:AntiStickTimer(Handle:timer)
public Action:AntiStickSolidify(Handle:timer, any:client)
{
// Validate player is in-game, alive, and is being unstuck.
if (!IsClientInGame(client) || !IsPlayerAlive(client) || CanCollide(client))
if (!IsClientInGame(client) || !IsPlayerAlive(client) || AntiStickClientCollisionGroup(client, false))
{
return Plugin_Stop;
}
@ -157,9 +166,27 @@ public Action:AntiStickSolidify(Handle:timer, any:client)
return Plugin_Continue;
}
NoCollide(client, false);
AntiStickClientCollisionGroup(client, true, ANTISTICK_COLLISIONS_ON);
return Plugin_Stop;
}
/**
* Set collision group flags on a client.
* @param client The client index.
* @param collisiongroup Collision group flag.
* @return The collision group on the client, -1 if applying collision group.
*/
AntiStickClientCollisionGroup(client, bool:apply = true, collisiongroup = 0)
{
if (apply)
{
SetEntData(client, g_iToolsCollisionGroup, collisiongroup, 1, true);
return -1;
}
return GetEntData(client, g_iToolsCollisionGroup, 1);
}

View File

@ -46,6 +46,7 @@ enum CvarsList
Handle:CVAR_INFECT_SPAWNTIME_MIN,
Handle:CVAR_INFECT_SPAWNTIME_MAX,
Handle:CVAR_INFECT_CONSECUTIVE_BLOCK,
Handle:CVAR_INFECT_WEAPONS_DROP,
Handle:CVAR_INFECT_MZOMBIE_RATIO,
Handle:CVAR_INFECT_MZOMBIE_RESPAWN,
Handle:CVAR_INFECT_SOUND,
@ -86,6 +87,7 @@ enum CvarsList
Handle:CVAR_RESPAWN_DELAY,
Handle:CVAR_RESPAWN_ZOMBIE,
Handle:CVAR_RESPAWN_ZOMBIE_WORLD,
Handle:CVAR_ZSPAWN,
Handle:CVAR_ZHP,
Handle:CVAR_ZHP_DEFAULT,
@ -93,7 +95,6 @@ enum CvarsList
Handle:CVAR_OVERLAY_REDISPLAY,
Handle:CVAR_ZVISION_ALLOW_DISABLE,
Handle:CVAR_MENU_AUTOCLOSE,
Handle:CVAR_ZSPAWN,
Handle:CVAR_ZTELE,
Handle:CVAR_ZTELE_STARTUP_DELAY,
Handle:CVAR_ZTELE_COOLDOWN,
@ -159,50 +160,50 @@ CvarsCreate()
// Any thing else?
// ===========================
// General (Core)
// ===========================
// General (Core)
// ===========================
g_hCvarsList[CVAR_ENABLE] = CreateConVar("zr_enable", "1", "");
// ===========================
// Log (core)
// ===========================
// Log (core)
// ===========================
// Cvars created in log.inc, because of compilation problems when creating them here.
// ===========================
// Translations (core)
// ===========================
// Translations (core)
// ===========================
// (None)
// ===========================
// Offsets (core)
// ===========================
// (None)
// ===========================
// Models (core)
// ===========================
// TODO: config file path.
// Tools (core)
// ===========================
// (None)
// ===========================
// Models (core)
// ===========================
// TODO: config file path.
// ===========================
// Classes (core)
// ===========================
g_hCvarsList[CVAR_CLASSES_SPAWN] = CreateConVar("zr_classes_spawn", "0", "");
g_hCvarsList[CVAR_CLASSES_SPAWN] = CreateConVar("zr_classes_spawn", "0", "");
// Old Desc: Classmenu is re-displayed every spawn (0: Disable)
g_hCvarsList[CVAR_CLASSES_RANDOM] = CreateConVar("zr_classes_random", "0", "");
g_hCvarsList[CVAR_CLASSES_RANDOM] = CreateConVar("zr_classes_random", "0", "");
// Old Desc: A random class is assigned to each player every round. Overrides zr_classes_spawn and default classes. (0: Disable)
g_hCvarsList[CVAR_CLASSES_DEFAULT_ZOMBIE] = CreateConVar("zr_classes_default_zombie", "random", "");
g_hCvarsList[CVAR_CLASSES_DEFAULT_ZOMBIE] = CreateConVar("zr_classes_default_zombie", "random", "");
// Old Desc: Default zombie class selected for all players when they connect. Use \"random\" to select a random class, or blank to use class config defaults.
g_hCvarsList[CVAR_CLASSES_DEFAULT_HUMAN] = CreateConVar("zr_classes_default_human", "random", "");
g_hCvarsList[CVAR_CLASSES_DEFAULT_HUMAN] = CreateConVar("zr_classes_default_human", "random", "");
// Old Desc:
g_hCvarsList[CVAR_CLASSES_DEFAULT_ADMIN] = CreateConVar("zr_classes_default_admin", "random", "");
g_hCvarsList[CVAR_CLASSES_DEFAULT_ADMIN] = CreateConVar("zr_classes_default_admin", "random", "");
// Old Desc: Default admin-only class selected for admins when they connect. Use \"random\" to select a random class, or blank to use class config defaults.
g_hCvarsList[CVAR_CLASSES_FILE] = CreateConVar("zr_classes_file", "configs/zr/playerclasses.txt", "");
g_hCvarsList[CVAR_CLASSES_FILE] = CreateConVar("zr_classes_file", "configs/zr/playerclasses.txt", "");
// Old Desc: Class data file to read from, in Valves key/values format. The path is relative to the \"sourcemod\" folder.
// ===========================
@ -222,7 +223,7 @@ CvarsCreate()
// Market Handler
g_hCvarsList[CVAR_WEAPONS_ZMARKET_BUYZONE] = CreateConVar("zr_weapons_zmarket_buyzone", "1", "");
g_hCvarsList[CVAR_WEAPONS_ZMARKET_BUYZONE] = CreateConVar("zr_weapons_zmarket_buyzone", "1", "");
// Old Desc: Must be in buyzone to access !zmarket, if Market is installed (0: Can be used anywhere)
// ===========================
@ -233,37 +234,38 @@ CvarsCreate()
// Note make config file cvar.
// ===========================
// Round End (core)
// ===========================
g_hCvarsList[CVAR_ROUNDEND_OVERLAY] = CreateConVar("zr_roundend_overlay", "1", "");
// Round End (core)
// ===========================
g_hCvarsList[CVAR_ROUNDEND_OVERLAY] = CreateConVar("zr_roundend_overlay", "1", "");
// 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", "overlays/zr/humans_win");
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
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
// ===========================
// Infect (core)
// ===========================
g_hCvarsList[CVAR_INFECT_MZOMBIE_RATIO] = CreateConVar("zr_infect_mzombie_ratio", "5", "");
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_MAX] = CreateConVar("zr_infect_spawntime_max", "50.0", "");
g_hCvarsList[CVAR_INFECT_MZOMBIE_RATIO] = CreateConVar("zr_infect_mzombie_ratio", "5", "");
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_MAX] = CreateConVar("zr_infect_spawntime_max", "50.0", "");
g_hCvarsList[CVAR_INFECT_CONSECUTIVE_BLOCK] = CreateConVar("zr_infect_consecutive_block", "1", "");
g_hCvarsList[CVAR_INFECT_WEAPONS_DROP] = CreateConVar("zr_infect_weapons_drop", "1", "");
// Effects
g_hCvarsList[CVAR_INFECT_FIREBALL] = CreateConVar("zr_infect_fireball", "1", "");
g_hCvarsList[CVAR_INFECT_SMOKE] = CreateConVar("zr_infect_smoke", "1", "");
g_hCvarsList[CVAR_INFECT_SPARKS] = CreateConVar("zr_infect_sparks", "1", "");
g_hCvarsList[CVAR_INFECT_SOUND] = CreateConVar("zr_infect_sound", "npc/fast_zombie/fz_scream1.wav", "");
g_hCvarsList[CVAR_INFECT_ESPLASH] = CreateConVar("zr_infect_esplash", "1", "");
g_hCvarsList[CVAR_INFECT_SHAKE] = CreateConVar("zr_infect_shake", "1", "");
g_hCvarsList[CVAR_INFECT_SHAKE_AMP] = CreateConVar("zr_infect_shake_amp", "15.0", "");
g_hCvarsList[CVAR_INFECT_SHAKE_FREQUENCY] = CreateConVar("zr_infect_shake_frequency", "1.0", "");
g_hCvarsList[CVAR_INFECT_SHAKE_DURATION] = CreateConVar("zr_infect_shake_duration", "5.0", "");
g_hCvarsList[CVAR_INFECT_FIREBALL] = CreateConVar("zr_infect_fireball", "1", "");
g_hCvarsList[CVAR_INFECT_SMOKE] = CreateConVar("zr_infect_smoke", "1", "");
g_hCvarsList[CVAR_INFECT_SPARKS] = CreateConVar("zr_infect_sparks", "1", "");
g_hCvarsList[CVAR_INFECT_SOUND] = CreateConVar("zr_infect_sound", "npc/fast_zombie/fz_scream1.wav", "");
g_hCvarsList[CVAR_INFECT_ESPLASH] = CreateConVar("zr_infect_esplash", "1", "");
g_hCvarsList[CVAR_INFECT_SHAKE] = CreateConVar("zr_infect_shake", "1", "");
g_hCvarsList[CVAR_INFECT_SHAKE_AMP] = CreateConVar("zr_infect_shake_amp", "15.0", "");
g_hCvarsList[CVAR_INFECT_SHAKE_FREQUENCY] = CreateConVar("zr_infect_shake_frequency", "1.0", "");
g_hCvarsList[CVAR_INFECT_SHAKE_DURATION] = CreateConVar("zr_infect_shake_duration", "5.0", "");
// ===========================
// Damage (core)
@ -271,13 +273,13 @@ CvarsCreate()
// Hitgroup Damage
g_hCvarsList[CVAR_DAMAGE_HITGROUPS] = CreateConVar("zr_damage_hitgroups", "1", "");
g_hCvarsList[CVAR_DAMAGE_HITGROUPS] = CreateConVar("zr_damage_hitgroups", "1", "");
// Block Damage Types
g_hCvarsList[CVAR_DAMAGE_BLOCK_FF] = CreateConVar("zr_damage_block_ff", "1", "");
g_hCvarsList[CVAR_DAMAGE_BLOCK_FF] = CreateConVar("zr_damage_block_ff", "1", "");
// note overrides mp_friendlyfire
g_hCvarsList[CVAR_DAMAGE_BLOCK_BLAST] = CreateConVar("zr_damage_block_blast", "1", "");
g_hCvarsList[CVAR_DAMAGE_BLOCK_BLAST] = CreateConVar("zr_damage_block_blast", "1", "");
// Suicide Intercept
@ -325,108 +327,113 @@ CvarsCreate()
g_hCvarsList[CVAR_VEFFECTS_FOG_FARZ] = CreateConVar("zr_veffects_fog_farz", "2000", "");
// ===========================
// Sound Effects (module)
// ===========================
// Zombie Sounds
g_hCvarsList[CVAR_SEFFECTS_MOAN] = CreateConVar("zr_seffects_moan", "30", "");
// Sound Effects (module)
// ===========================
// Zombie Sounds
g_hCvarsList[CVAR_SEFFECTS_MOAN] = CreateConVar("zr_seffects_moan", "30", "");
// Old Desc: How often, in seconds, a zombie moans (0: Disable)
g_hCvarsList[CVAR_SEFFECTS_GROAN] = CreateConVar("zr_seffects_groan", "5", "");
g_hCvarsList[CVAR_SEFFECTS_GROAN] = CreateConVar("zr_seffects_groan", "5", "");
// Old Desc: Chance factor a zombie will groan when shot (Lower: More often, 0: Disable)
g_hCvarsList[CVAR_SEFFECTS_DEATH] = CreateConVar("zr_seffects_death", "1", "");
g_hCvarsList[CVAR_SEFFECTS_DEATH] = CreateConVar("zr_seffects_death", "1", "");
// Old Desc: Zombie will emit a death sound when killed (0: Disable)
// Ambient Sounds
g_hCvarsList[CVAR_AMBIENTSOUNDS] = CreateConVar("zr_ambientsounds", "1", "");
g_hCvarsList[CVAR_AMBIENTSOUNDS] = CreateConVar("zr_ambientsounds", "1", "");
// Old Desc: Enable creepy ambience to be played throughout the game (0: Disable)
g_hCvarsList[CVAR_AMBIENTSOUNDS_FILE] = CreateConVar("zr_ambientsounds_file", "ambient/zr/zr_ambience.mp3", "");
g_hCvarsList[CVAR_AMBIENTSOUNDS_FILE] = CreateConVar("zr_ambientsounds_file", "ambient/zr/zr_ambience.mp3", "");
// Old Desc: Path to ambient sound file that will be played throughout the game, when zr_ambience is 1
g_hCvarsList[CVAR_AMBIENTSOUNDS_LENGTH] = CreateConVar("zr_ambientsounds_length", "60.0", "");
g_hCvarsList[CVAR_AMBIENTSOUNDS_LENGTH] = CreateConVar("zr_ambientsounds_length", "60.0", "");
// Old Desc: The length, in seconds, of the ambient sound file
g_hCvarsList[CVAR_AMBIENTSOUNDS_VOLUME] = CreateConVar("zr_ambientsounds_volume", "1.0", "");
g_hCvarsList[CVAR_AMBIENTSOUNDS_VOLUME] = CreateConVar("zr_ambientsounds_volume", "1.0", "");
// Old Desc: Volume of ambient sounds when zr_ambience is 1 (0.0: Unhearable, 1.0: Max volume)
// ===========================
// Antistick (module)
// ===========================
g_hCvarsList[CVAR_ANTISTICK] = CreateConVar("zr_antistick", "1", "");
// Antistick (module)
// ===========================
g_hCvarsList[CVAR_ANTISTICK] = CreateConVar("zr_antistick", "1", "");
// Old Desc: Enable the anti-stick module, which will automatically unstick players stuck within each other. (0:Disable)
g_hCvarsList[CVAR_ANTISTICK_INTERVAL] = CreateConVar("zr_antistick_interval", "0.5", "");
g_hCvarsList[CVAR_ANTISTICK_INTERVAL] = CreateConVar("zr_antistick_interval", "0.5", "");
// Old Desc: How often, in seconds, the anti-stick module checks each player for being stuck. (1.0: Default)
// ===========================
// Knockback (module)
// ===========================
// (None)
// ===========================
// Spawn Protect (module)
// ===========================
g_hCvarsList[CVAR_SPAWNPROTECT] = CreateConVar("zr_spawnprotect", "1", "");
g_hCvarsList[CVAR_SPAWNPROTECT_TIME] = CreateConVar("zr_spawnprotect_time", "10", "");
// Knockback (module)
// ===========================
// (None)
// ===========================
// Respawn (module)
// ===========================
g_hCvarsList[CVAR_RESPAWN] = CreateConVar("zr_respawn", "0", "");
// Spawn Protect (module)
// ===========================
g_hCvarsList[CVAR_SPAWNPROTECT] = CreateConVar("zr_spawnprotect", "1", "");
g_hCvarsList[CVAR_SPAWNPROTECT_TIME] = CreateConVar("zr_spawnprotect_time", "10", "");
// ===========================
// Respawn (module)
// ===========================
g_hCvarsList[CVAR_RESPAWN] = CreateConVar("zr_respawn", "0", "");
// Old Desc: When player is killed, player will respawn
g_hCvarsList[CVAR_RESPAWN_DELAY] = CreateConVar("zr_respawn_delay", "1", "");
g_hCvarsList[CVAR_RESPAWN_DELAY] = CreateConVar("zr_respawn_delay", "1", "");
// Old Desc: How long to wait after death to respawn, in seconds
g_hCvarsList[CVAR_RESPAWN_ZOMBIE] = CreateConVar("zr_respawn_zombie", "1", "");
g_hCvarsList[CVAR_RESPAWN_ZOMBIE] = CreateConVar("zr_respawn_zombie", "1", "");
// Old Desc: Respawn player as zombie (0: Respawn as human)
g_hCvarsList[CVAR_RESPAWN_ZOMBIE_WORLD] = CreateConVar("zr_respawn_zombie_world", "1", "");
g_hCvarsList[CVAR_RESPAWN_ZOMBIE_WORLD] = CreateConVar("zr_respawn_zombie_world", "1", "");
// Old Desc: Respawn zombies as zombies if they were killed by the world, like elevators, doors and lasers. (0: Disable)
// ===========================
// Napalm (module)
// ===========================
// (None)
// ===========================
// ZHP (module)
// ===========================
g_hCvarsList[CVAR_ZHP] = CreateConVar("zr_zhp", "1", "");
// Napalm (module)
// ===========================
// (None)
// ===========================
// ZSpawn (module)
// ===========================
g_hCvarsList[CVAR_ZSPAWN] = CreateConVar("zr_zspawn", "1", "");
// Old Desc: Allow players to spawn if they just joined the game (0: Disable)
// ===========================
// ZHP (module)
// ===========================
g_hCvarsList[CVAR_ZHP] = CreateConVar("zr_zhp", "1", "");
// Old Desc: Allows clients to enable/disable zombie health display (1: On, 0: Off)
g_hCvarsList[CVAR_ZHP_DEFAULT] = CreateConVar("zr_zhp_default", "1", "");
g_hCvarsList[CVAR_ZHP_DEFAULT] = CreateConVar("zr_zhp_default", "1", "");
// Old Desc: The default value of zombie health display to new clients (1: On, 0: Off)
// TO BE MODULIZED/RECODED.
g_hCvarsList[CVAR_OVERLAY_REDISPLAY] = CreateConVar("zr_overlay_redisplay", "3", "");
g_hCvarsList[CVAR_OVERLAY_REDISPLAY] = CreateConVar("zr_overlay_redisplay", "3", "");
// Old Desc: Frequency, in seconds, to display overlay on the client's screen (Never go below 0.1, 0.2 seems safe)
g_hCvarsList[CVAR_ZVISION_ALLOW_DISABLE] = CreateConVar("zr_zvision_allow_disable", "1", "");
g_hCvarsList[CVAR_ZVISION_ALLOW_DISABLE] = CreateConVar("zr_zvision_allow_disable", "1", "");
// Old Desc: Allow users to disable ZVision with their nightvision key (0: Disable)
g_hCvarsList[CVAR_MENU_AUTOCLOSE] = CreateConVar("zr_menu_autoclose", "0", "");
g_hCvarsList[CVAR_MENU_AUTOCLOSE] = CreateConVar("zr_menu_autoclose", "0", "");
// Old Desc: Automatically close menus on selection. If disabled the menu will remain open.
g_hCvarsList[CVAR_ZSPAWN] = CreateConVar("zr_zspawn", "1", "");
// Old Desc: Allow players to spawn if they just joined the game (0: Disable)
g_hCvarsList[CVAR_ZTELE] = CreateConVar("zr_tele", "1", "");
g_hCvarsList[CVAR_ZTELE] = CreateConVar("zr_tele", "1", "");
// Old Desc: Allow players to use the teleporter to get to spawn. (0: Disable)
g_hCvarsList[CVAR_ZTELE_STARTUP_DELAY] = CreateConVar("zr_tele_startup_delay", "30", "");
g_hCvarsList[CVAR_ZTELE_STARTUP_DELAY] = CreateConVar("zr_tele_startup_delay", "30", "");
// Old Desc: Number of seconds to wait before the teleporter is enabled (0: Always enabled)
g_hCvarsList[CVAR_ZTELE_COOLDOWN] = CreateConVar("zr_tele_cooldown", "20", "");
g_hCvarsList[CVAR_ZTELE_COOLDOWN] = CreateConVar("zr_tele_cooldown", "20", "");
// Old Desc: Number of seconds to wait before the teleporter can be used again, after a teleport. (0: Disable)
g_hCvarsList[CVAR_ZTELE_HUMAN_DELAY] = CreateConVar("zr_tele_human_delay", "10", "");
g_hCvarsList[CVAR_ZTELE_HUMAN_DELAY] = CreateConVar("zr_tele_human_delay", "10", "");
// Old Desc: Teleport delay for humans. (0: No delay)
g_hCvarsList[CVAR_ZTELE_HUMAN_LIMIT] = CreateConVar("zr_tele_human_limit", "3", "");
g_hCvarsList[CVAR_ZTELE_HUMAN_LIMIT] = CreateConVar("zr_tele_human_limit", "3", "");
// Old Desc: Maximum number of teleports humans can do. (0: Humans can't use the teleporter. -1: Unlimited)
g_hCvarsList[CVAR_ZTELE_ZOMBIE_DELAY] = CreateConVar("zr_tele_zombie_delay", "0", "");
g_hCvarsList[CVAR_ZTELE_ZOMBIE_DELAY] = CreateConVar("zr_tele_zombie_delay", "0", "");
// Old Desc: Teleport delay for zombies. (0: No delay)
g_hCvarsList[CVAR_ZTELE_ZOMBIE_LIMIT] = CreateConVar("zr_tele_zombie_limit", "8", "");
g_hCvarsList[CVAR_ZTELE_ZOMBIE_LIMIT] = CreateConVar("zr_tele_zombie_limit", "8", "");
// Old Desc: Maximum number of teleports zombies can do. (0: Zombies can't use the teleporter. -1: Unlimited)
g_hCvarsList[CVAR_ZTELE_RESET_BUFFERS] = CreateConVar("zr_tele_reset_buffers", "1", "");
g_hCvarsList[CVAR_ZTELE_RESET_BUFFERS] = CreateConVar("zr_tele_reset_buffers", "1", "");
// Old Desc: Reset custom saved teleport locations on each round start. (0: Disable)
g_hCvarsList[CVAR_ANTICAMP] = CreateConVar("zr_anticamp", "1", "");
g_hCvarsList[CVAR_ANTICAMP] = CreateConVar("zr_anticamp", "1", "");
// Old Desc: Enables or disables hurt volumes for preventing unfair camping. (0: Disable)
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).
// Auto-generate config file if it doesn't exist, then execute.
@ -523,7 +530,7 @@ public CvarsHookRestartGame(Handle:cvar, const String:oldvalue[], const String:n
}
// Terminate the round with restart time as delay.
RoundEndRestart(delay);
RoundEndTerminateRound(delay);
// If log flag check fails, then don't log.
if (LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_CORE))

View File

@ -39,7 +39,7 @@ enum DamageHooks
Hook_OnTakeDamage, /** OnTakeDamage HookID */
}
new g_iDamageHooks[MAXPLAYERS + 1][DamageHooks];
new g_iDamageHookID[MAXPLAYERS + 1][DamageHooks];
/**
* Damage module init function.
@ -73,8 +73,8 @@ DamageInit()
DamageClientInit(client)
{
// Hook damage callbacks.
g_iDamageHooks[client][Hook_TraceAttack] = Hacks_Hook(client, HACKS_HTYPE_TRACEATTACK, DamageTraceAttack);
g_iDamageHooks[client][Hook_OnTakeDamage] = Hacks_Hook(client, HACKS_HTYPE_ONTAKEDAMAGE, DamageOnTakeDamage);
g_iDamageHookID[client][Hook_TraceAttack] = Hacks_Hook(client, HACKS_HTYPE_TRACEATTACK, DamageTraceAttack);
g_iDamageHookID[client][Hook_OnTakeDamage] = Hacks_Hook(client, HACKS_HTYPE_ONTAKEDAMAGE, DamageOnTakeDamage);
}
/**
@ -85,8 +85,8 @@ DamageClientInit(client)
DamageOnClientDisconnect(client)
{
// Unhook damage callbacks.
Hacks_Unhook(g_iDamageHooks[client][Hook_TraceAttack]);
Hacks_Unhook(g_iDamageHooks[client][Hook_OnTakeDamage]);
Hacks_Unhook(g_iDamageHookID[client][Hook_TraceAttack]);
Hacks_Unhook(g_iDamageHookID[client][Hook_OnTakeDamage]);
}
/**

View File

@ -73,6 +73,7 @@ public Action:EventRoundStart(Handle:event, const String:name[], bool:dontBroadc
VEffectsOnRoundStart();
SEffectsOnRoundStart();
AntiStickOnRoundStart();
ZSpawnOnRoundStart();
}
/**
@ -148,15 +149,17 @@ public Action:EventPlayerSpawn(Handle:event, const String:name[], bool:dontBroad
new index = GetClientOfUserId(GetEventInt(event, "userid"));
// Reset FOV and overlay.
SetPlayerFOV(index, 90);
ToolsSetClientDefaultFOV(index, 90);
ClientCommand(index, "r_screenoverlay \"\"");
// Check if client is on a team.
if (ZRIsClientOnTeam(index))
{
// Remove night vision.
NightVisionOn(index, false);
NightVision(index, false);
// Turn off nightvision.
ToolsClientNightVision(index, false, false);
// Take nightvision away.
ToolsClientNightVision(index, false);
if (g_bZombieSpawned)
{
@ -166,10 +169,6 @@ public Action:EventPlayerSpawn(Handle:event, const String:name[], bool:dontBroad
CS_RespawnPlayer(index);
}
}
else
{
SetPlayerAlpha(index, 255);
}
}
// Forward event to modules.
@ -248,7 +247,8 @@ public Action:EventPlayerDeath(Handle:event, const String:name[], bool:dontBroad
{
// Add kill bonus to attacker's score.
new bonus = ClassGetKillBonus(attacker);
AddPlayerScore(attacker, bonus);
new score = ToolsClientScore(index, true, false);
ToolsClientScore(index, true, true, score + bonus);
}
}
@ -272,12 +272,10 @@ public Action:EventPlayerDeath(Handle:event, const String:name[], bool:dontBroad
public Action:EventPlayerJump(Handle:event, const String:name[], bool:dontBroadcast)
{
// Get all required event info.
new client = GetClientOfUserId(GetEventInt(event, "userid"));
new index = GetClientOfUserId(GetEventInt(event, "userid"));
new Float:distance = ClassGetJumpDistance(client);
new Float:height = ClassGetJumpHeight(client);
JumpBoost(client, distance, height);
// Forward event to modules.
JumpBoostOnClientJump(index);
}
/**

View File

@ -1,9 +1,12 @@
/**
* ====================
/*
* ============================================================================
*
* Zombie:Reloaded
* File: global.inc
* Author: Greyscale
* ====================
*
* File: (Core) global.inc
* Description: External API.
*
* ============================================================================
*/
/**

View File

@ -17,10 +17,10 @@ new Handle:kvHitgroups = INVALID_HANDLE;
/**
* @section Player hitgroup values.
*/
#define HITGROUP_GENERIC 0
#define HITGROUP_HEAD 1
#define HITGROUP_CHEST 2
#define HITGROUP_STOMACH 3
#define HITGROUP_GENERIC 0
#define HITGROUP_HEAD 1
#define HITGROUP_CHEST 2
#define HITGROUP_STOMACH 3
#define HITGROUP_LEFTARM 4
#define HITGROUP_RIGHTARM 5
#define HITGROUP_LEFTLEG 6

View File

@ -138,7 +138,7 @@ InfectOnClientDisconnect(client)
}
// Manually terminate round.
RoundEndTerminateRound(ZombiesWin);
RoundEndTerminateRound(ROUNDEND_DELAY, ZombiesWin);
return;
}
@ -351,6 +351,12 @@ public Action:InfectMotherZombie(Handle:timer)
// client = client index.
for (new x = 0; x < eligibleclients; x++)
{
// Stop pruning if there is only 1 player left.
if (eligibleclients <= 1)
{
break;
}
// Get client stored in array index.
client = GetArrayCell(arrayEligibleClients, x);
@ -366,12 +372,6 @@ public Action:InfectMotherZombie(Handle:timer)
// Subtract one from count.
eligibleclients--;
// If there are no eligible client's then stop.
if (!eligibleclients)
{
return;
}
// Backtrack one index, because we deleted it out from under the loop.
x--;
}
@ -426,6 +426,12 @@ public Action:InfectMotherZombie(Handle:timer)
// Calculate mother zombie count.
new mothercount = RoundToNearest(float(humancount) / ratio);
// If mothercount is 0, then set to 1.
if (!mothercount)
{
mothercount = 1;
}
// x = current mother zombie count.
for (new x = 0; x < mothercount; x++)
{
@ -437,6 +443,7 @@ public Action:InfectMotherZombie(Handle:timer)
{
break;
}
// Get a random valid array index.
randindex = GetRandomInt(0, eligibleclients - 1);
@ -475,28 +482,39 @@ InfectClient(client, attacker = -1, bool:motherinfect = false)
new weapons[WeaponsType];
WeaponsGetClientWeapons(client, weapons);
// Check if weapons drop is enabled.
new bool:weaponsdrop = GetConVarBool(g_hCvarsList[CVAR_INFECT_WEAPONS_DROP]);
// Loop through array slots and force drop.
// x = weapon slot.
for (new x = 0; x < WEAPONS_SLOTS_MAX; x++)
{
// If this is the knife slot, then stop.
if (WeaponsType:x == Type_Melee)
{
continue;
}
// If weapon is invalid, then stop.
if (weapons[x] == -1)
{
continue;
}
// Force client to drop weapon.
WeaponForceClientDrop(client, weapons[x]);
if (weaponsdrop)
{
// If this is the knife slot, then stop.
if (WeaponsType:x == Type_Melee)
{
continue;
}
// Force client to drop weapon.
WeaponForceClientDrop(client, weapons[x]);
}
else
{
// Strip weapon.
RemovePlayerItem(client, weapons[x]);
}
}
// If client has no knife, give them one.
if (weapons[Type_Melee] == -1)
if (GetPlayerWeaponSlot(client, _:Type_Melee) == -1)
{
GivePlayerItem(client, "weapon_knife");
}
@ -524,10 +542,12 @@ InfectClient(client, attacker = -1, bool:motherinfect = false)
}
// Give client's infector a point.
AddPlayerScore(attacker, 1);
new score = ToolsClientScore(attacker, true, false);
ToolsClientScore(attacker, true, true, ++score);
// Add a death to the zombie's score.
AddPlayerDeath(client, 1);
new deaths = ToolsClientScore(client, false, false);
ToolsClientScore(client, false, true, ++deaths);
// Apply infect HP gain.
new healthgain = ClassGetHealthInfectGain(attacker);

44
src/zr/jumpboost.inc Normal file
View File

@ -0,0 +1,44 @@
/*
* ============================================================================
*
* Zombie:Reloaded
*
* File: jumpboost.inc
* Description: Modified jump vector magnitudes.
*
* ============================================================================
*/
/**
* Client is jumping.
*
* @param client The client index.
*/
JumpBoostOnClientJump(client)
{
// Get class jump multipliers.
new Float:distance = ClassGetJumpDistance(client);
new Float:height = ClassGetJumpHeight(client);
// Get client's current velocity.
new Float:vecVelocity[3];
ToolsClientVelocity(client, vecVelocity, false);
// Apply jump values.
vecVelocity[0] *= distance;
vecVelocity[1] *= distance;
vecVelocity[2] = height;
JumpBoostSetClientVelocity(client, vecVelocity);
}
/**
* Apply jump boost force on client. (Special method separate from ToolsClientVelocity)
*
* @param client The client index.
* @param vecVelocity Velocity to set on client.
*/
JumpBoostSetClientVelocity(client, const Float:vecVelocity[3])
{
SetEntDataVector(client, g_iToolsBaseVelocity, vecVelocity, true);
}

View File

@ -59,7 +59,7 @@ KnockbackOnClientHurt(client, attacker, const String:weapon[], hitgroup, dmg_hea
// Get attackers eye angles.
new Float:attackerang[3];
GetPlayerEyeAngles(attacker, attackerang);
KnockbackGetClientEyeAngles(attacker, attackerang);
// Calculate knockback end-vector.
TR_TraceRayFilter(attackerloc, attackerang, MASK_ALL, RayType_Infinite, KnockbackTRFilter);
@ -99,8 +99,8 @@ KnockbackSetVelocity(client, const Float:startpoint[3], const Float:endpoint[3],
// Apply the magnitude by scaling the vector (multiplying each of its components).
ScaleVector(vector, magnitude);
// ADD the given vector to the clients current velocity.
SetPlayerVelocity(client, vector, false);
// ADD the given vector to the client's current velocity.
ToolsClientVelocity(client, vector);
}
/**
@ -163,4 +163,15 @@ KnockbackFindExplodingGrenade(Float:heLoc[3])
// Didn't find the grenade.
return -1;
}
/**
* Get client's eye angles.
*
* @param client The client index.
* @param vecAngles The angle vector of the client's eyes.
*/
KnockbackGetClientEyeAngles(client, Float:vecAngles[3])
{
SDKCall(g_hToolsEyeAngles, client, vecAngles);
}

View File

@ -24,6 +24,7 @@
#define LOG_FORMAT_TYPE_SIMPLE 0 /** Simple log message. */
#define LOG_FORMAT_TYPE_FULL 1 /** Full log message, printed in normal log. */
#define LOG_FORMAT_TYPE_ERROR 2 /** Full log message, printed in error log. */
#define LOG_FORMAT_TYPE_FATALERROR 3 /** Full log message, stops the plugin and printed in error logs. */
/**
* @endsection
*/
@ -67,6 +68,9 @@ new Handle:g_hLogFlags = INVALID_HANDLE;
* @endsection
*/
/**
* Log module init function.
*/
LogInit()
{
// Create modules cvars.
@ -100,11 +104,8 @@ LogMessageFormatted(client, const String:module[], const String:block[], const S
decl String:logtext[LOG_MAX_LENGTH_FILE];
// 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))
// If client is invalid (console), and console log events are ignored, then stop.
if (client == 0 && LogCheckFlag(LOG_IGNORE_CONSOLE))
{
return;
}
@ -132,6 +133,11 @@ LogMessageFormatted(client, const String:module[], const String:block[], const S
Format(logtext, sizeof(logtext), "\"%s\" : \"%s\" -- %s", module, block, logtext);
LogError(logtext);
}
case LOG_FORMAT_TYPE_FATALERROR:
{
Format(logtext, sizeof(logtext), "\"%s\" : \"%s\" -- %s", module, block, logtext);
SetFailState(logtext);
}
}
// If log to admin flag is enabled, then print to admins.
@ -141,8 +147,8 @@ LogMessageFormatted(client, const String:module[], const String:block[], const S
LogToAdmins(logtext);
}
// If client isn't console, and we log to client's then continue.
if (!console && LogCheckFlag(LOG_TO_CLIENT))
// If client is a valid client (but not console), and we log to client's then continue.
if (ZRIsClientValid(client) && LogCheckFlag(LOG_TO_CLIENT))
{
// Set client as translation target.
SetGlobalTransTarget(client);

View File

@ -1,100 +1,136 @@
/**
* ====================
/*
* ============================================================================
*
* Zombie:Reloaded
* File: menu.sp
* Author: Greyscale
* ====================
*
* File: menu.inc
* Description: Base menu functions for the plugin.
*
* ============================================================================
*/
MainMenu(client)
/**
* Show main menu to client.
*
* @param client The client index.
*/
MenuMain(client)
{
new Handle:menu_main = CreateMenu(MainMenuHandle);
new itemdraw = (ZRIsClientAdmin(client)) ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED;
// Create menu handle.
new Handle:menu_main = CreateMenu(MenuMainHandle);
// Make client global translations target.
SetGlobalTransTarget(client);
// Set menu title.
SetMenuTitle(menu_main, "%t\n ", "!zmenu title");
decl String:zadmin[128];
decl String:zclass[128];
decl String:zmarket[128];
decl String:zspawn[128];
decl String:ztele[128];
decl String:zhp[128];
// Initialize menu lines.
decl String:zadmin[64];
decl String:zclass[64];
decl String:zspawn[64];
decl String:ztele[64];
decl String:zhp[64];
decl String:zmarket[64];
Format(zadmin, sizeof(zadmin), "%t", "!zmenu admin");
Format(zclass, sizeof(zclass), "%t", "!zmenu class", ITEMDRAW_DISABLED);
Format(zmarket, sizeof(zmarket), "%t", "!zmenu market");
Format(zspawn, sizeof(zspawn), "%t", "!zmenu spawn");
Format(ztele, sizeof(ztele), "%t", "!zmenu tele");
Format(zhp, sizeof(zhp), "%t (%d HP)", "!zmenu hp", GetClientHealth(client));
// Translate each line into client's language.
Format(zadmin, sizeof(zadmin), "%t", "Menu main zadmin");
Format(zclass, sizeof(zclass), "%t", "Menu main zclass");
Format(zspawn, sizeof(zspawn), "%t", "Menu main zspawn");
Format(ztele, sizeof(ztele), "%t", "Menu main ztele");
Format(zhp, sizeof(zhp), "%t", "Menu main zhp");
Format(zmarket, sizeof(zmarket), "%t", "Menu main zmarket");
// Add items to menu.
// Disable option if client isn't an admin.
new bool:admin = ZRIsClientAdmin(client);
AddMenuItem(menu_main, "zadmin", zadmin, MenuGetItemDraw(admin));
AddMenuItem(menu_main, "zadmin", zadmin, itemdraw);
AddMenuItem(menu_main, "zclass", zclass);
if (g_bMarket)
{
AddMenuItem(menu_main, "zmarket", zmarket);
}
else
{
AddMenuItem(menu_main, "zmarket", zmarket, ITEMDRAW_DISABLED);
}
AddMenuItem(menu_main, "zspawn", zspawn);
AddMenuItem(menu_main, "ztele", ztele);
AddMenuItem(menu_main, "zhp", zhp);
AddMenuItem(menu_main, "zmarket", zmarket, MenuGetItemDraw(g_bMarket));
// Display menu to client.
DisplayMenu(menu_main, client, MENU_TIME_FOREVER);
}
public MainMenuHandle(Handle:menu_main, MenuAction:action, client, slot)
/**
* Menu callback (main)
* Redirects client to selected option's handle code.
*
* @param menu The menu handle.
* @param action Action client is doing in menu.
* @param client The client index.
* @param slot The menu slot selected. (starting from 0)
*/
public MenuMainHandle(Handle:menu, MenuAction:action, client, slot)
{
// Client selected an option.
if (action == MenuAction_Select)
{
// Create variable to possible resend menu later.
new bool:resend = true;
switch(slot)
{
// Selected zadmin.
case 0:
{
if (!ZRAdminMenu(client))
{
MainMenu(client);
}
// Copy return to resend variable.
resend = !ZRAdminMenu(client);
}
case 1:
{
// Send class menu
ClassMenuMain(client);
// Don't resend this menu.
resend = false;
}
case 2:
{
if (!ZMarketSend(client))
{
MainMenu(client);
}
// Copy return to resend variable.
resend = !ZMarketSend(client);
}
case 3:
{
ZSpawn(client);
// Send zspawn command from client.
ZSpawnClient(client);
}
case 4:
{
if (!ZTele(client))
{
MainMenu(client);
}
// Copy return to resend variable.
resend = !ZTele(client);
}
case 5:
{
// Toggle ZHP.
ZHPToggle(client);
// Resend menu.
MainMenu(client);
}
}
// Resend is still true, then resend menu.
if (resend)
{
MenuMain(client);
}
}
// Client exited menu.
if (action == MenuAction_End)
{
CloseHandle(menu_main);
CloseHandle(menu);
}
}
/**
* Return itemdraw flag for SM menus.
*
* @param condition If this is true, item will be drawn normally.
*/
MenuGetItemDraw(bool:condition)
{
return condition ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED;
}

View File

@ -112,7 +112,7 @@ bool:ClassApplyAlpha(client, classindex, cachetype = ZR_CLASS_CACHE_PLAYER)
return false;
}
SetPlayerAlpha(client, alpha);
ToolsSetClientAlpha(client, alpha);
return true;
}
@ -187,13 +187,9 @@ bool:ClassApplyNightVision(client, classindex, cachetype = ZR_CLASS_CACHE_PLAYER
nvgs = ClassGetNvgs(classindex, cachetype);
}
NightVision(client, nvgs);
ToolsClientNightVision(client, nvgs);
ToolsClientNightVision(client, nvgs, false);
// Turn on night vision if applied.
if (nvgs)
{
NightVisionOn(client, nvgs);
}
return true;
}
@ -223,7 +219,7 @@ bool:ClassApplyFOV(client, classindex, cachetype = ZR_CLASS_CACHE_PLAYER)
fov = ClassGetFOV(classindex, cachetype);
}
SetPlayerFOV(client, fov);
ToolsSetClientDefaultFOV(client, fov);
return true;
}
@ -333,6 +329,6 @@ bool:ClassApplySpeed(client, classindex, cachetype = ZR_CLASS_CACHE_PLAYER)
speed = ClassGetSpeed(classindex, cachetype);
}
SetPlayerSpeed(client, speed);
ToolsSetClientLMV(client, speed);
return true;
}

View File

@ -38,7 +38,7 @@ ClassOnClientDisconnect(client)
ClassOnClientSpawn(client)
{
// Reset client's FOV.
SetPlayerFOV(client, ATTRIBUTES_FOV_DEFAULT);
ToolsSetClientDefaultFOV(client, ATTRIBUTES_FOV_DEFAULT);
new bool:randomclass = GetConVarBool(g_hCvarsList[CVAR_CLASSES_RANDOM]);
new bool:showmenu = GetConVarBool(g_hCvarsList[CVAR_CLASSES_SPAWN]);

View File

@ -136,7 +136,7 @@ public ClassMenuMainHandle(Handle:menu, MenuAction:action, client, slot)
{
if (slot == MenuCancel_ExitBack)
{
MainMenu(client);
MenuMain(client);
}
}
}
@ -256,6 +256,9 @@ public ClassMenuSelectHandle(Handle:menu, MenuAction:action, client, slot)
case MenuAction_End:
{
CloseHandle(menu);
// Stop so menu doesn't reopen.
return;
}
}

View File

@ -22,6 +22,6 @@ ClassAlphaUpdate(client)
if ((max_health - current_health) > max_damage)
{
new alpha_damaged = ClassGetAlphaDamaged(client);
SetPlayerAlpha(client, alpha_damaged);
ToolsSetClientAlpha(client, alpha_damaged);
}
}

View File

@ -12,22 +12,22 @@
/**
* @section All round end reasons.
*/
#define ROUNDEND_TARGET_BOMBED 1 // Target Successfully Bombed!
#define ROUNDEND_VIP_ESCAPED 2 // The VIP has escaped!
#define ROUNDEND_VIP_ASSASSINATED 3 // VIP has been assassinated!
#define ROUNDEND_TERRORISTS_ESCAPED 4 // The terrorists have escaped!
#define ROUNDEND_CTS_PREVENTESCAPE 5 // The CT's have prevented most of the terrorists from escaping!
#define ROUNDEND_ESCAPING_TERRORISTS_NEUTRALIZED 6 // Escaping terrorists have all been neutralized!
#define ROUNDEND_BOMB_DEFUSED 7 // The bomb has been defused!
#define ROUNDEND_CTS_WIN 8 // Counter-Terrorists Win!
#define ROUNDEND_TERRORISTS_WIN 9 // Terrorists Win!
#define ROUNDEND_ROUND_DRAW 10 // Round Draw!
#define ROUNDEND_ALL_HOSTAGES_RESCUED 11 // All Hostages have been rescued!
#define ROUNDEND_TARGET_SAVED 12 // Target has been saved!
#define ROUNDEND_HOSTAGES_NOT_RESCUED 13 // Hostages have not been rescued!
#define ROUNDEND_TERRORISTS_NOT_ESCAPED 14 // Terrorists have not escaped!
#define ROUNDEND_VIP_NOT_ESCAPED 15 // VIP has not escaped!
#define ROUNDEND_GAME_COMMENCING 16 // Game Commencing!
#define ROUNDEND_TARGET_BOMBED 1 // Target Successfully Bombed!
#define ROUNDEND_VIP_ESCAPED 2 // The VIP has escaped!
#define ROUNDEND_VIP_ASSASSINATED 3 // VIP has been assassinated!
#define ROUNDEND_TERRORISTS_ESCAPED 4 // The terrorists have escaped!
#define ROUNDEND_CTS_PREVENTESCAPE 5 // The CT's have prevented most of the terrorists from escaping!
#define ROUNDEND_ESCAPING_TERRORISTS_NEUTRALIZED 6 // Escaping terrorists have all been neutralized!
#define ROUNDEND_BOMB_DEFUSED 7 // The bomb has been defused!
#define ROUNDEND_CTS_WIN 8 // Counter-Terrorists Win!
#define ROUNDEND_TERRORISTS_WIN 9 // Terrorists Win!
#define ROUNDEND_ROUND_DRAW 10 // Round Draw!
#define ROUNDEND_ALL_HOSTAGES_RESCUED 11 // All Hostages have been rescued!
#define ROUNDEND_TARGET_SAVED 12 // Target has been saved!
#define ROUNDEND_HOSTAGES_NOT_RESCUED 13 // Hostages have not been rescued!
#define ROUNDEND_TERRORISTS_NOT_ESCAPED 14 // Terrorists have not escaped!
#define ROUNDEND_VIP_NOT_ESCAPED 15 // VIP has not escaped!
#define ROUNDEND_GAME_COMMENCING 16 // Game Commencing!
/**
* @endsection
*/
@ -35,21 +35,17 @@
/**
* Delay between round ending and new round starting. (Normal)
*/
#define ROUNDEND_DELAY_NORMAL 5.0
/**
* Delay between round ending and new round starting. (Short, for ROUNDEND_GAME_COMMENCING)
*/
#define ROUNDEND_DELAY_SHORT 3.0
#define ROUNDEND_DELAY 5.0
/**
* Possible round end outcomes.
*/
enum RoundEndOutcome
{
Restart, /** Round is restarting. */
Draw, /** Round has ended in unexpected way. */
HumansWin, /** Humans have killed all zombies. */
ZombiesWin, /** Zombies have infected all humans. */
Draw, /** Round has ended in unexpected way. */
}
/**
@ -91,7 +87,7 @@ RoundEndOnClientDeath()
new RoundEndOutcome:outcome;
if (RoundEndGetRoundStatus(outcome))
{
RoundEndTerminateRound(outcome);
RoundEndTerminateRound(ROUNDEND_DELAY, outcome);
}
}
@ -104,7 +100,7 @@ RoundEndOnClientInfected()
new RoundEndOutcome:outcome;
if (RoundEndGetRoundStatus(outcome))
{
RoundEndTerminateRound(outcome);
RoundEndTerminateRound(ROUNDEND_DELAY, outcome);
}
}
@ -164,7 +160,7 @@ RoundEndOnRoundEnd(reason)
new RoundEndOutcome:outcome = RoundEndReasonToOutcome(reason);
// Display the overlay to all clients.
RoundEndOverlayStart(ROUNDEND_DELAY_NORMAL, outcome);
RoundEndOverlayStart(ROUNDEND_DELAY, outcome);
// Balance teams.
RoundEndBalanceTeams();
@ -255,8 +251,8 @@ RoundEndOutcome:RoundEndReasonToOutcome(reason)
*/
public Action:RoundEndTimer(Handle:timer)
{
// Terminate the round with a normal delay, and CTs as the winner.
TerminateRound(ROUNDEND_DELAY_NORMAL, ROUNDEND_CTS_WIN);
// Terminate the round with humans as the winner.
RoundEndTerminateRound(ROUNDEND_DELAY, HumansWin);
}
/**
@ -313,40 +309,38 @@ bool:RoundEndGetRoundStatus(&RoundEndOutcome:outcome)
}
/**
* Ends the round with the given outcome.
* Ends the round with the given outcome and delay.
*
* @param delay Delay before new round starts.
* @param outcome The outcome of the round.
*/
RoundEndTerminateRound(RoundEndOutcome:outcome)
RoundEndTerminateRound(Float:delay, RoundEndOutcome:outcome = Restart)
{
switch(outcome)
{
// Round is restarting.
case Restart:
{
SDKCall(g_hToolsTerminateRound, delay, ROUNDEND_GAME_COMMENCING);
}
// Round was a draw.
case Draw:
{
SDKCall(g_hToolsTerminateRound, delay, ROUNDEND_ROUND_DRAW);
}
// Zombies won.
case ZombiesWin:
{
// Terminate the round with a normal delay, and Ts as the winner.
TerminateRound(ROUNDEND_DELAY_NORMAL, ROUNDEND_TERRORISTS_WIN);
SDKCall(g_hToolsTerminateRound, delay, ROUNDEND_TERRORISTS_WIN);
}
// Humans won.
case HumansWin:
{
// Terminate the round with a normal delay, and CTs as the winner.
TerminateRound(ROUNDEND_DELAY_NORMAL, ROUNDEND_CTS_WIN);
SDKCall(g_hToolsTerminateRound, delay, ROUNDEND_CTS_WIN);
}
}
}
/**
* 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
*

View File

@ -1,103 +1,104 @@
/**
* ====================
/*
* ============================================================================
*
* Zombie:Reloaded
* File: sayhooks.inc
* Author: Greyscale
* ====================
*
* File: sayhooks.inc
* Description: Hook plugin say commands and redirect to their handling module.
*
* ============================================================================
*/
HookChatCmds()
/**
* Max number of characters in a chat text string.
*/
#define SAYHOOKS_MAX_CHAT_LENGTH 192
/**
* @section Say command key words.
*/
#define SAYHOOKS_KEYWORD_ZMENU "!zmenu"
#define SAYHOOKS_KEYWORD_ZADMIN "!zadmin"
#define SAYHOOKS_KEYWORD_ZCLASS "!zclass"
#define SAYHOOKS_KEYWORD_ZSPAWN "!zspawn"
#define SAYHOOKS_KEYWORD_ZTELE "!ztele"
#define SAYHOOKS_KEYWORD_ZHP "!zhp"
#define SAYHOOKS_KEYWORD_ZMARKET "!zmarket"
/**
* @endsection
*/
/**
* Say hooks module init function.
*/
SayHooksInit()
{
RegConsoleCmd("say", SayCommand);
RegConsoleCmd("say_team", SayCommand);
// Hook client's say commands.
RegConsoleCmd("say", SayHooksCmdSay);
RegConsoleCmd("say_team", SayHooksCmdSay);
}
public Action:SayCommand(client, argc)
/**
* Command callback. (say, say_team)
* Catches all client's say text and takes action on key words.
*
* @param client The client index.
* @param argc The number of arguments in command string.
*/
public Action:SayHooksCmdSay(client, argc)
{
new bool:enabled = GetConVarBool(g_hCvarsList[CVAR_ENABLE]);
if (!client || !enabled)
{
return Plugin_Continue;
}
decl String:args[192];
decl String:args[SAYHOOKS_MAX_CHAT_LENGTH];
// Get client's command string (typically 'say "text"')
GetCmdArgString(args, sizeof(args));
// Strip away the quotes.
ReplaceString(args, sizeof(args), "\"", "");
if (StrEqual(args, "!zmenu", false))
// If client triggered the zmenu keyword, then send menu.
if (StrEqual(args, SAYHOOKS_KEYWORD_ZMENU, false))
{
MainMenu(client);
MenuMain(client);
}
if (StrEqual(args, "!zadmin", false))
// If client triggered the zmenu keyword, then send menu.
else if (StrEqual(args, SAYHOOKS_KEYWORD_ZADMIN, false))
{
ZRAdminMenu(client);
}
else if (StrEqual(args, "!zclass", false))
// If client triggered the zmenu keyword, then send menu.
else if (StrEqual(args, SAYHOOKS_KEYWORD_ZCLASS, false))
{
ClassMenuMain(client);
}
else if (StrEqual(args, "!zmarket", false))
// If client triggered the zmenu keyword, then send menu.
else if (StrEqual(args, SAYHOOKS_KEYWORD_ZSPAWN, false))
{
// Spawns a late-joining client into the game.
ZSpawnClient(client);
}
// If client triggered the zmenu keyword, then send menu.
else if (StrEqual(args, SAYHOOKS_KEYWORD_ZTELE, false))
{
ZTele(client);
}
// If client triggered the zmenu keyword, then send menu.
else if (StrEqual(args, SAYHOOKS_KEYWORD_ZHP, false))
{
// Toggle ZHP.
ZHPToggle(client);
}
// If client triggered the zmenu keyword, then send menu.
else if (StrEqual(args, SAYHOOKS_KEYWORD_ZMARKET, false))
{
// Send market menu.
ZMarketSend(client);
}
else if (StrEqual(args, "!zspawn", false))
{
ZSpawn(client);
}
else if (StrEqual(args, "!tp", false) ||
StrEqual(args, "!ztele", false) ||
StrEqual(args, "!tele", false) ||
StrEqual(args, "!teleport", false))
{
ZTele(client);
}
else if (StrEqual(args, "!teleabort", false))
{
AbortTeleport(client, false);
}
else if (StrEqual(args, "!zhp", false))
{
// Toggle ZHP.
ZHPToggle(client);
}
else if (StrContains(args, "teleport", false) != -1
|| StrContains(args, "stuck", false) != -1
|| StrContains(args, "help", false) != -1)
{
ZR_PrintToChat(client, "!ztele stuck");
}
return Plugin_Continue;
}
ZSpawn(client)
{
new bool:spawn = GetConVarBool(g_hCvarsList[CVAR_ZSPAWN]);
if (!spawn)
{
ZR_PrintToChat(client, "Feature is disabled");
return;
}
new team = GetClientTeam(client);
if (team != CS_TEAM_T && team != CS_TEAM_CT)
{
return;
}
if (IsPlayerAlive(client))
{
return;
}
RespawnSpawnClient(client);
}

View File

@ -79,8 +79,8 @@ SpawnProtectOnClientSpawn(client)
// Set improved attributes
// (Move to cvar?)
SetPlayerAlpha(client, 0);
SetPlayerSpeed(client, 600.0);
ToolsSetClientAlpha(client, 0);
ToolsSetClientLMV(client, 600.0);
// Set time left to zr_protect_time's value.
new protect_time = GetConVarInt(g_hCvarsList[CVAR_SPAWNPROTECT_TIME]);
@ -151,8 +151,8 @@ public Action:SpawnProtectTimer(Handle:timer, any:client)
// Fix attributes.
// TODO: Set class attributes.
SetPlayerAlpha(client, 255);
SetPlayerSpeed(client, 300.0);
ToolsSetClientAlpha(client, 255);
ToolsSetClientLMV(client, 300.0);
// Clear timer handle.
tSpawnProtect[client] = INVALID_HANDLE;

199
src/zr/tools.inc Normal file
View File

@ -0,0 +1,199 @@
/*
* ============================================================================
*
* Zombie:Reloaded
*
* File: tools.inc
* Description: Find offsets and signatures.
*
* ============================================================================
*/
/**
* Initialize global offset variables.
*/
new g_iToolsVelocity;
new g_iToolsBaseVelocity;
new g_iToolsLMV;
new g_iToolsHasNightVision;
new g_iToolsNightVisionOn;
new g_iToolsCollisionGroup;
new g_iToolsAccount;
new g_iToolsDefaultFOV;
new g_iToolsInBuyZone;
new g_iToolsRender;
new g_iToolsRenderMode;
new g_iToolsActiveWeapon;
/**
* @endsection
*/
/**
* Initialize global SDKTools handles.
*/
new Handle:g_hToolsGameConfig = INVALID_HANDLE;
new Handle:g_hToolsEyeAngles = INVALID_HANDLE;
new Handle:g_hToolsTerminateRound = INVALID_HANDLE;
new Handle:g_hToolsCSWeaponDrop = INVALID_HANDLE;
/**
* @endsection
*/
// Tools Functions (core)
#include "zr/tools_functions"
/**
* Tools module init function.
*/
ToolsInit()
{
// Find offsets.
ToolsFindOffsets();
// Setup SDKTools
ToolsSetupGameData();
}
/**
* Finds all offset values for the plugin.
*/
ToolsFindOffsets()
{
// If offset "m_vecVelocity[0]" can't be found, then stop the plugin.
g_iToolsVelocity = FindSendPropInfo("CBasePlayer", "m_vecVelocity[0]");
if (g_iToolsVelocity == -1)
{
LogMessageFormatted(-1, "Tools", "Offsets", "Offset \"CBasePlayer::m_vecVelocity[0]\" was not found.", LOG_FORMAT_TYPE_FATALERROR);
}
// If offset "m_vecBaseVelocity" can't be found, then stop the plugin.
g_iToolsBaseVelocity = FindSendPropInfo("CBasePlayer", "m_vecBaseVelocity");
if (g_iToolsBaseVelocity == -1)
{
LogMessageFormatted(-1, "Tools", "Offsets", "Offset \"CBasePlayer::m_vecBaseVelocity\" was not found.", LOG_FORMAT_TYPE_FATALERROR);
}
// If offset "m_flLaggedMovementValue" can't be found, then stop the plugin.
g_iToolsLMV = FindSendPropInfo("CCSPlayer", "m_flLaggedMovementValue");
if (g_iToolsLMV == -1)
{
LogMessageFormatted(-1, "Tools", "Offsets", "Offset \"CCSPlayer::m_flLaggedMovementValue\" was not found.", LOG_FORMAT_TYPE_FATALERROR);
}
// If offset "m_bHasNightVision" can't be found, then stop the plugin.
g_iToolsHasNightVision = FindSendPropInfo("CCSPlayer", "m_bHasNightVision");
if (g_iToolsHasNightVision == -1)
{
LogMessageFormatted(-1, "Tools", "Offsets", "Offset \"CCSPlayer::m_bHasNightVision\" was not found.", LOG_FORMAT_TYPE_FATALERROR);
}
// If offset "m_bNightVisionOn" can't be found, then stop the plugin.
g_iToolsNightVisionOn = FindSendPropInfo("CCSPlayer", "m_bNightVisionOn");
if (g_iToolsNightVisionOn == -1)
{
LogMessageFormatted(-1, "Tools", "Offsets", "Offset \"CCSPlayer::m_bNightVisionOn\" was not found.", LOG_FORMAT_TYPE_FATALERROR);
}
// If offset "m_CollisionGroup" can't be found, then stop the plugin.
g_iToolsCollisionGroup = FindSendPropInfo("CBaseEntity", "m_CollisionGroup");
if (g_iToolsCollisionGroup == -1)
{
LogMessageFormatted(-1, "Tools", "Offsets", "Offset \"CBaseEntity::m_CollisionGroup\" was not found.", LOG_FORMAT_TYPE_FATALERROR);
}
// If offset "m_iAccount" can't be found, then stop the plugin.
g_iToolsAccount = FindSendPropInfo("CCSPlayer", "m_iAccount");
if (g_iToolsAccount == -1)
{
LogMessageFormatted(-1, "Tools", "Offsets", "Offset \"CCSPlayer::m_iAccount\" was not found.", LOG_FORMAT_TYPE_FATALERROR);
}
// If offset "m_iDefaultFOV" can't be found, then stop the plugin.
g_iToolsDefaultFOV = FindSendPropInfo("CBasePlayer", "m_iDefaultFOV");
if (g_iToolsDefaultFOV == -1)
{
LogMessageFormatted(-1, "Tools", "Offsets", "Offset \"CBasePlayer::m_iDefaultFOV\" was not found.", LOG_FORMAT_TYPE_FATALERROR);
}
// If offset "m_bInBuyZone" can't be found, then stop the plugin.
g_iToolsInBuyZone = FindSendPropInfo("CCSPlayer", "m_bInBuyZone");
if (g_iToolsInBuyZone == -1)
{
LogMessageFormatted(-1, "Tools", "Offsets", "Offset \"CCSPlayer::m_bInBuyZone\" was not found.", LOG_FORMAT_TYPE_FATALERROR);
}
// If offset "m_clrRender" can't be found, then stop the plugin.
g_iToolsRender = FindSendPropInfo("CAI_BaseNPC", "m_clrRender");
if (g_iToolsRender == -1)
{
LogMessageFormatted(-1, "Tools", "Offsets", "Offset \"CAI_BaseNPC::m_clrRender\" was not found.", LOG_FORMAT_TYPE_FATALERROR);
}
// If offset "m_nRenderMode" can't be found, then stop the plugin.
g_iToolsRenderMode = FindSendPropInfo("CBaseAnimating", "m_nRenderMode");
if (g_iToolsRenderMode == -1)
{
LogMessageFormatted(-1, "Tools", "Offsets", "Offset \"CBaseAnimating::m_nRenderMode\" was not found.", LOG_FORMAT_TYPE_FATALERROR);
}
// If offset "m_hActiveWeapon" can't be found, then stop the plugin.
g_iToolsActiveWeapon = FindSendPropInfo("CBasePlayer", "m_hActiveWeapon");
if (g_iToolsActiveWeapon == -1)
{
LogMessageFormatted(-1, "Tools", "Offsets", "Offset \"CBasePlayer::m_hActiveWeapon\" was not found.", LOG_FORMAT_TYPE_FATALERROR);
}
}
/**
* Sets up gamedata for the plugin.
*/
ToolsSetupGameData()
{
// Load game config file.
g_hToolsGameConfig = LoadGameConfigFile("plugin.zombiereloaded");
// If gamedata file can't be loaded, then stop the plugin.
if (g_hToolsGameConfig == INVALID_HANDLE)
{
LogMessageFormatted(-1, "Tools", "GameData", "Can't load game config file (plugin.zombiereloaded.txt) from the gamedata directory.", LOG_FORMAT_TYPE_FATALERROR);
}
// Prep the SDKCall for "EyeAngles."
StartPrepSDKCall(SDKCall_Player);
PrepSDKCall_SetFromConf(g_hToolsGameConfig, SDKConf_Virtual, "EyeAngles");
PrepSDKCall_SetReturnInfo(SDKType_QAngle, SDKPass_ByValue);
g_hToolsEyeAngles = EndPrepSDKCall();
// If offset "EyeAngles" can't be found, then stop the plugin.
if(g_hToolsEyeAngles == INVALID_HANDLE)
{
LogMessageFormatted(-1, "Tools", "GameData", "Offset \"EyeAngles\" was not found.", LOG_FORMAT_TYPE_FATALERROR);
}
// Prep the SDKCall for "TerminateRound."
StartPrepSDKCall(SDKCall_GameRules);
PrepSDKCall_SetFromConf(g_hToolsGameConfig, SDKConf_Signature, "TerminateRound");
PrepSDKCall_AddParameter(SDKType_Float, SDKPass_Plain);
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
g_hToolsTerminateRound = EndPrepSDKCall();
// If offset "TerminateRound" can't be found, then stop the plugin.
if(g_hToolsTerminateRound == INVALID_HANDLE)
{
LogMessageFormatted(-1, "Tools", "GameData", "Signature \"CGameRules::TerminateRound\" was not found.", LOG_FORMAT_TYPE_FATALERROR);
}
// Prep the SDKCall for "CSWeaponDrop."
StartPrepSDKCall(SDKCall_Player);
PrepSDKCall_SetFromConf(g_hToolsGameConfig, SDKConf_Signature, "CSWeaponDrop");
PrepSDKCall_AddParameter(SDKType_CBaseEntity, SDKPass_Pointer);
PrepSDKCall_AddParameter(SDKType_Bool, SDKPass_Plain);
PrepSDKCall_AddParameter(SDKType_Bool, SDKPass_Plain);
g_hToolsCSWeaponDrop = EndPrepSDKCall();
// If offset "CSWeaponDrop" can't be found, then stop the plugin.
if(g_hToolsCSWeaponDrop == INVALID_HANDLE)
{
LogMessageFormatted(-1, "Tools", "GameData", "Signature \"CBasePlaye::CSWeaponDrop\" was not found.", LOG_FORMAT_TYPE_FATALERROR);
}
}

149
src/zr/tools_functions.inc Normal file
View File

@ -0,0 +1,149 @@
/*
* ============================================================================
*
* Zombie:Reloaded
*
* File: tools_functions.inc
* Description: API for offsets/signatures exposed in tools.inc
*
* ============================================================================
*/
/**
* Get or set a client's velocity.
* @param client The client index.
* @param vecVelocity Array to store vector in, or velocity to set on client.
* @param retrieve True to get client's velocity, false to set it.
* @param stack If modifying velocity, then true will stack new velocity onto the client's
* current velocity, false will reset it.
*/
ToolsClientVelocity(client, Float:vecVelocity[3], bool:apply = true, bool:stack = true)
{
// If retrieve if true, then get client's velocity.
if (!apply)
{
// x = vector component.
for (new x = 0; x < 3; x++)
{
vecVelocity[x] = GetEntDataFloat(client, g_iToolsVelocity + (x*4));
}
// Stop here.
return;
}
// If stack is true, then add client's velocity.
if (stack)
{
// Get client's velocity.
new Float:vecClientVelocity[3];
// x = vector component.
for (new x = 0; x < 3; x++)
{
vecClientVelocity[x] = GetEntDataFloat(client, g_iToolsVelocity + (x*4));
}
AddVectors(vecClientVelocity, vecVelocity, vecVelocity);
}
// Apply velocity on client.
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, vecVelocity);
}
/**
* Set a client's lagged movement value.
* @param client The client index.
* @param value LMV value. (1.0 = default, 2.0 = double)
*/
ToolsSetClientLMV(client, Float:fLMV)
{
// Set lagged movement value of client.
SetEntDataFloat(client, g_iToolsLMV, fLMV / 300.0, true);
}
/**
* Control nightvision values on a client.
* @param client The client index.
* @param enable Enable or disable an aspect of nightvision. (see ownership parameter)
* @param ownership If true, enable will toggle the client's ownership of nightvision.
* If false, enable will toggle the client's on/off state of the nightvision.
*/
ToolsClientNightVision(client, bool:enable, bool:ownership = true)
{
// If ownership is true, then toggle the ownership of nightvision on client.
if (ownership)
{
SetEntData(client, g_iToolsHasNightVision, enable, 1, true);
// Stop here.
return;
}
SetEntData(client, g_iToolsNightVisionOn, enable, 1, true);
}
/**
* Set a client's default field of vision.
* @param client The client index.
* @param FOV The field of vision of the client.
*/
ToolsSetClientDefaultFOV(client, FOV)
{
SetEntData(client, g_iToolsDefaultFOV, FOV, 1, true);
}
/**
* Get or set a client's score or deaths.
*
* @param client The client index.
* @param score True to look at score, false to look at deaths.
* @param apply True to set scores or death, false to get.
* @param value The value of the client's score or deaths.
* @return The score or death count of the client, -1 if setting.
*/
ToolsClientScore(client, bool:score = true, bool:apply = true, value = 0)
{
if (!apply)
{
if (score)
{
// If score is true, then return client's score.
return GetEntProp(client, Prop_Data, "m_iFrags");
}
// Return client's deaths.
else
{
return GetEntProp(client, Prop_Data, "m_iDeaths");
}
}
// If score is true, then set client's score.
if (score)
{
SetEntProp(client, Prop_Data, "m_iFrags", value);
}
// Set client's deaths.
else
{
SetEntProp(client, Prop_Data, "m_iDeaths", value);
}
// We set the client's score or deaths.
return -1;
}
/**
* Set a client's alpha value.
*
* @param client The client index.
* @param alpha The alpha value to set client's alpha to. (0-255)
*/
ToolsSetClientAlpha(client, alpha)
{
// Turn rendermode on, on the client.
SetEntData(client, g_iToolsRenderMode, 3, 1, true);
// Set alpha value on the client.
SetEntData(client, g_iToolsRender + 3, alpha, 1, true);
}

View File

@ -39,7 +39,7 @@ bool:ZMarketSend(client)
// Check buyzone cvar to see if client has to be in a buyzone to use.
new bool:buyzone = GetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET_BUYZONE]);
if (!IsClientInBuyZone(client) && buyzone)
if (!ZMarketIsClientInBuyZone(client) && buyzone)
{
// Tell client they must be in a buyzone.
ZR_PrintCenterText(client, "Market out of buyzone");
@ -63,6 +63,17 @@ bool:ZMarketSend(client)
return true;
}
/**
* Checks if a client is in a buyzone.
*
* @param client The client index.
*/
bool:ZMarketIsClientInBuyZone(client)
{
// Return if client is in buyzone.
return bool:GetEntData(client, g_iToolsInBuyZone);
}
/**
* (Market) Forward called when a client selects a weapon from the market.
*
@ -115,7 +126,7 @@ public bool:Market_OnWeaponSelected(client, String:weaponid[])
// Check if buyzone cvar is enabled, and if the client is in a buyzone.
new bool:buyzone = GetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET_BUYZONE]);
if (!IsClientInBuyZone(client) && buyzone)
if (!ZMarketIsClientInBuyZone(client) && buyzone)
{
ZR_PrintCenterText(client, "Market out of buyzone");

View File

@ -847,30 +847,30 @@ RestrictGetGroupWeapons(const String:groupname[], String:weaponlist[], maxlen, c
*/
public RestrictCanUse(client, weapon, dummy1, dummy2, dummy3, dummy4)
{
// If plugin is disabled then stop.
new bool:enabled = GetConVarBool(g_hCvarsList[CVAR_ENABLE]);
if (!enabled)
{
return Hacks_Continue;
}
new String:weaponname[WEAPONS_MAX_LENGTH];
GetEdictClassname(weapon, weaponname, sizeof(weaponname));
// Strip "weapon_" from entity name.
ReplaceString(weaponname, sizeof(weaponname), "weapon_", "");
// If the weapon is restricted then prevent pickup.
// If weapon is a knife, then allow pickup.
if (StrEqual(weaponname, "knife"))
{
return Hacks_Continue;
}
// If the weapon is restricted, then prevent pickup.
if (RestrictIsWeaponRestricted(weaponname))
{
return 0;
}
// If the player is a zombie and the weapon isn't a knife then prevent pickup.
if (InfectIsClientInfected(client) && !StrEqual(weaponname, "knife"))
// If the player is a zombie, then prevent pickup.
if (InfectIsClientInfected(client))
{
return 0;
}
// Allow pickup.
return Hacks_Continue;
}

View File

@ -369,5 +369,5 @@ WeaponsType:WeaponsGetDeployedWeaponSlot(client)
WeaponForceClientDrop(client, weapon)
{
// Force client to drop weapon.
SDKCall(g_hCSWeaponDrop, client, weapon, true, false);
SDKCall(g_hToolsCSWeaponDrop, client, weapon, true, false);
}

View File

@ -102,7 +102,7 @@ public ZRAdminMenuHandle(Handle:menu_admin, MenuAction:action, client, slot)
{
if (slot == MenuCancel_ExitBack)
{
MainMenu(client);
MenuMain(client);
}
}
else if (action == MenuAction_End)
@ -422,7 +422,7 @@ ZRSpawnAll(client)
{
if (IsClientInGame(x))
{
ZSpawn(x);
ZSpawnClient(x);
}
}
ZRAdminMenu(client);

View File

@ -48,19 +48,6 @@ public Action:Command_NightVision(client, argc)
}
}
JumpBoost(client, Float:distance, Float:height)
{
new Float:vel[3];
GetPlayerVelocity(client, vel);
vel[0] *= distance;
vel[1] *= distance;
vel[2] *= height;
SetPlayerVelocity(client, vel, false);
}
RemoveObjectives()
{
decl String:classname[64];

76
src/zr/zspawn.inc Normal file
View File

@ -0,0 +1,76 @@
/*
* ============================================================================
*
* Zombie:Reloaded
*
* File: (Module) zspawn.inc
* Description: Handles zspawn command, spawns late-joining clients into the game.
*
* ============================================================================
*/
/**
* Array to block zspawn for a unique client serial number.
*/
new bool:g_bZSpawnBlock[MAXPLAYERS + 1];
/**
* Client is leaving the server.
*
* @param client The client index.
*/
ZSpawnOnClientDisconnect(client)
{
// Get client's unique serial number.
new serial = GetClientSerial(client);
// Block zspawn.
g_bZSpawnBlock[serial] = true;
}
/**
* The round is starting.
*/
ZSpawnOnRoundStart()
{
// Disable flag that blocks zspawn for all clients.
// x = client index.
for (new x = 1; x <= MaxClients; x++)
{
// Unblock zspawn.
g_bZSpawnBlock[x] = false;
}
}
ZSpawnClient(client)
{
// If zspawn is disabled, then stop.
new bool:zspawn = GetConVarBool(g_hCvarsList[CVAR_ZSPAWN]);
if (!zspawn)
{
ZR_PrintToChat(client, "Feature is disabled");
return;
}
// If client isn't on a team, then stop.
if (!ZRIsClientOnTeam(client))
{
return;
}
// If client is alive, then stop.
if (IsPlayerAlive(client))
{
return;
}
// Block if client has already played during this round.
new serial = GetClientSerial(client);
if (g_bZSpawnBlock[serial])
{
return;
}
// Tell respawn module to respawn client.
RespawnSpawnClient(client);
}