sm-zombiereloaded-3/src/zombiereloaded.sp

255 lines
5.4 KiB
SourcePawn
Raw Normal View History

2009-04-29 01:58:41 +02:00
/*
* ============================================================================
*
2008-10-04 22:59:11 +02:00
* Zombie:Reloaded
2009-04-29 01:58:41 +02:00
*
* File: (base) zombiereloaded.sp
* Description: Plugins base file.
*
* ============================================================================
2008-10-04 22:59:11 +02:00
*/
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#include <hacks>
#undef REQUIRE_PLUGIN
#include <market>
#define VERSION "3.0-dev"
2008-10-04 22:59:11 +02:00
2009-04-29 01:58:41 +02:00
// Core includes.
2008-10-04 22:59:11 +02:00
#include "zr/zombiereloaded"
#include "zr/log"
#include "zr/cvars"
2008-10-04 22:59:11 +02:00
#include "zr/translation"
2009-04-29 01:58:41 +02:00
#include "zr/tools"
2008-10-04 22:59:11 +02:00
#include "zr/models"
#include "zr/playerclasses/playerclasses"
#include "zr/weapons/weapons"
#include "zr/hitgroups"
#include "zr/roundend"
#include "zr/infect"
#include "zr/damage"
2009-04-29 01:58:41 +02:00
#include "zr/menu"
#include "zr/sayhooks"
#include "zr/event"
#include "zr/zadmin"
#include "zr/commands"
//#include "zr/global"
2009-04-29 01:58:41 +02:00
// Modules
#include "zr/account"
#include "zr/visualeffects"
#include "zr/soundeffects/soundeffects"
#include "zr/antistick"
#include "zr/knockback"
2009-04-15 11:27:03 +02:00
#include "zr/spawnprotect"
#include "zr/respawn"
#include "zr/napalm"
2009-04-29 01:58:41 +02:00
#include "zr/zspawn"
#include "zr/zhp"
2009-04-29 01:58:41 +02:00
#include "zr/jumpboost"
#include "zr/anticamp"
#include "zr/teleport"
2009-04-29 01:58:41 +02:00
// Almost replaced! :)
#include "zr/zombie"
2008-10-04 22:59:11 +02:00
2009-04-29 01:58:41 +02:00
/**
* Tell SM ZR's info.
*/
2008-10-04 22:59:11 +02:00
public Plugin:myinfo =
{
2009-04-29 01:58:41 +02:00
name = "Zombie:Reloaded",
author = "Greyscale, Rhelgeby (Richard)",
description = "Infection/survival style gameplay",
version = VERSION,
2008-10-04 22:59:11 +02:00
url = ""
};
2009-04-29 01:58:41 +02:00
/**
* 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.
*/
2008-10-04 22:59:11 +02:00
public bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max)
{
2009-04-29 01:58:41 +02:00
// TODO: EXTERNAL API
2008-10-04 22:59:11 +02:00
2009-04-29 01:58:41 +02:00
// Let plugin load.
2008-10-04 22:59:11 +02:00
return true;
}
2009-04-29 01:58:41 +02:00
/**
* Plugin is loading.
*/
2008-10-04 22:59:11 +02:00
public OnPluginStart()
{
2009-04-29 01:58:41 +02:00
// Load translations phrases used by plugin.
2008-10-04 22:59:11 +02:00
LoadTranslations("common.phrases.txt");
LoadTranslations("zombiereloaded.phrases.txt");
2009-04-29 01:58:41 +02:00
// Start loading ZR init functions.
2008-10-04 22:59:11 +02:00
ZR_PrintToServer("Plugin loading");
// Log
LogInit();
// Cvars
CvarsInit();
2009-04-29 01:58:41 +02:00
// Tools
ToolsInit();
// TODO: Be modulized/recoded.
2008-10-04 22:59:11 +02:00
CreateCommands();
HookCommands();
// Weapons
WeaponsInit();
// Damage
DamageInit();
2008-10-04 22:59:11 +02:00
2009-04-29 01:58:41 +02:00
// Say Hooks
SayHooksInit();
// Event
EventInit();
2009-04-29 01:58:41 +02:00
// Set market variable to true if market is installed.
g_bMarket = LibraryExists("market");
2008-10-04 22:59:11 +02:00
2009-04-29 01:58:41 +02:00
// Create public cvar for tracking.
2008-10-04 22:59:11 +02:00
CreateConVar("gs_zombiereloaded_version", VERSION, "[ZR] Current version of this plugin", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_UNLOGGED|FCVAR_DONTRECORD|FCVAR_REPLICATED|FCVAR_NOTIFY);
2009-04-29 01:58:41 +02:00
// Finish loading ZR init functions.
2008-10-04 22:59:11 +02:00
ZR_PrintToServer("Plugin loaded");
}
2009-04-29 01:58:41 +02:00
/**
* Library is being removed.
*
* @param name The name of the library.
*/
2008-10-04 22:59:11 +02:00
public OnLibraryRemoved(const String:name[])
{
2009-04-29 01:58:41 +02:00
// If market is being removed, then set variable to false.
if (StrEqual(name, "market", false))
{
g_bMarket = false;
}
2008-10-04 22:59:11 +02:00
}
2009-04-29 01:58:41 +02:00
/**
* Library is being added.
*
* @param name The name of the library.
*/
2008-10-04 22:59:11 +02:00
public OnLibraryAdded(const String:name[])
{
2009-04-29 01:58:41 +02:00
// If market is being added, then set variable to true.
if (StrEqual(name, "market", false))
{
g_bMarket = true;
}
2008-10-04 22:59:11 +02:00
}
2009-04-29 01:58:41 +02:00
/**
* The map is starting.
*/
2008-10-04 22:59:11 +02:00
public OnMapStart()
{
LoadModelData();
LoadDownloadData();
// Forward event to modules.
RoundEndOnMapStart();
InfectOnMapStart();
SEffectsOnMapStart();
AntiStickOnMapStart();
Anticamp_Startup();
}
2009-04-29 01:58:41 +02:00
/**
* The map is ending.
*/
public OnMapEnd()
{
// Forward event to modules.
Anticamp_Disable();
2008-10-04 22:59:11 +02:00
}
2009-04-29 01:58:41 +02:00
/**
* Configs just finished getting executed.
*/
2008-10-04 22:59:11 +02:00
public OnConfigsExecuted()
{
2009-04-29 01:58:41 +02:00
// TODO: move to config module when made.
2008-10-04 22:59:11 +02:00
decl String:mapconfig[PLATFORM_MAX_PATH];
GetCurrentMap(mapconfig, sizeof(mapconfig));
Format(mapconfig, sizeof(mapconfig), "sourcemod/zombiereloaded/%s.cfg", mapconfig);
decl String:path[PLATFORM_MAX_PATH];
Format(path, sizeof(path), "cfg/%s", mapconfig);
if (FileExists(path))
{
ServerCommand("exec %s", mapconfig);
if (LogCheckFlag(LOG_CORE_EVENTS))
2009-04-13 04:37:17 +02:00
{
LogMessageFormatted(-1, "", "", "Executed map config file: %s.", LOG_FORMAT_TYPE_SIMPLE, mapconfig);
}
2008-10-04 22:59:11 +02:00
}
// Forward event to modules.
WeaponsLoad();
HitgroupsLoad();
InfectLoad();
VEffectsLoad();
SEffectsLoad();
ClassLoad();
2008-10-04 22:59:11 +02:00
}
2009-04-29 01:58:41 +02:00
/**
* Client is joining the server.
*
* @param client The client index.
*/
2008-10-04 22:59:11 +02:00
public OnClientPutInServer(client)
{
// Forward event to modules.
ClassClientInit(client);
WeaponsClientInit(client);
RoundEndClientInit(client);
InfectClientInit(client);
DamageClientInit(client);
SEffectsClientInit(client);
SpawnProtectClientInit(client);
RespawnClientInit(client);
ZHPClientInit(client);
2008-10-04 22:59:11 +02:00
}
2009-04-29 01:58:41 +02:00
/**
* Client is leaving the server.
*
* @param client The client index.
*/
2008-10-04 22:59:11 +02:00
public OnClientDisconnect(client)
{
// Forward event to modules.
ClassOnClientDisconnect(client);
WeaponsOnClientDisconnect(client);
InfectOnClientDisconnect(client);
DamageOnClientDisconnect(client);
2009-04-29 01:58:41 +02:00
ZSpawnOnClientDisconnect(client);
ZTeleResetClient(client);
}