Initial check in.
This commit is contained in:
97
src/zr/ambience.inc
Normal file
97
src/zr/ambience.inc
Normal file
@ -0,0 +1,97 @@
|
||||
/**
|
||||
* ====================
|
||||
* Zombie:Reloaded
|
||||
* File: ambience.inc
|
||||
* Author: Greyscale
|
||||
* ====================
|
||||
*/
|
||||
|
||||
new bool:soundValid = false;
|
||||
|
||||
new Handle:tAmbience = INVALID_HANDLE;
|
||||
|
||||
LoadAmbienceData()
|
||||
{
|
||||
new bool:ambience = GetConVarBool(gCvars[CVAR_AMBIENCE]);
|
||||
if (!ambience)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
decl String:sound[64];
|
||||
GetConVarString(gCvars[CVAR_AMBIENCE_FILE], sound, sizeof(sound));
|
||||
Format(sound, sizeof(sound), "sound/%s", sound);
|
||||
|
||||
soundValid = FileExists(sound, true);
|
||||
|
||||
if (soundValid)
|
||||
{
|
||||
AddFileToDownloadsTable(sound);
|
||||
}
|
||||
else
|
||||
{
|
||||
ZR_LogMessage("Ambient sound load failed", sound);
|
||||
}
|
||||
}
|
||||
|
||||
RestartAmbience()
|
||||
{
|
||||
if (tAmbience != INVALID_HANDLE)
|
||||
{
|
||||
CloseHandle(tAmbience);
|
||||
}
|
||||
|
||||
CreateTimer(0.0, AmbienceLoop, _, TIMER_FLAG_NO_MAPCHANGE);
|
||||
}
|
||||
|
||||
public Action:AmbienceLoop(Handle:timer)
|
||||
{
|
||||
new bool:ambience = GetConVarBool(gCvars[CVAR_AMBIENCE]);
|
||||
|
||||
if (!ambience || !soundValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
decl String:sound[64];
|
||||
GetConVarString(gCvars[CVAR_AMBIENCE_FILE], sound, sizeof(sound));
|
||||
|
||||
EmitAmbience(sound);
|
||||
|
||||
new Float:delay = GetConVarFloat(gCvars[CVAR_AMBIENCE_LENGTH]);
|
||||
tAmbience = CreateTimer(delay, AmbienceLoop, _, TIMER_FLAG_NO_MAPCHANGE);
|
||||
}
|
||||
|
||||
StopAmbience()
|
||||
{
|
||||
new bool:ambience = GetConVarBool(gCvars[CVAR_AMBIENCE]);
|
||||
|
||||
if (!ambience)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
decl String:sound[64];
|
||||
GetConVarString(gCvars[CVAR_AMBIENCE_FILE], sound, sizeof(sound));
|
||||
|
||||
new maxplayers = GetMaxClients();
|
||||
for (new x = 1; x <= maxplayers; x++)
|
||||
{
|
||||
if (!IsClientInGame(x))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
StopSound(x, SNDCHAN_AUTO, sound);
|
||||
}
|
||||
}
|
||||
|
||||
EmitAmbience(const String:sound[])
|
||||
{
|
||||
PrecacheSound(sound);
|
||||
|
||||
StopAmbience();
|
||||
|
||||
new Float:volume = GetConVarFloat(gCvars[CVAR_AMBIENCE_VOLUME]);
|
||||
EmitSoundToAll(sound, SOUND_FROM_PLAYER, SNDCHAN_AUTO, SNDLEVEL_NORMAL, SND_NOFLAGS, volume, SNDPITCH_NORMAL, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
|
||||
}
|
295
src/zr/classes.inc
Normal file
295
src/zr/classes.inc
Normal file
@ -0,0 +1,295 @@
|
||||
/**
|
||||
* ====================
|
||||
* Zombie:Reloaded
|
||||
* File: classes.inc
|
||||
* Author: Greyscale
|
||||
* ====================
|
||||
*/
|
||||
|
||||
enum ZR_ClassOptions
|
||||
{
|
||||
String:data_name[64],
|
||||
String:data_model[256],
|
||||
String:data_menu_description[256],
|
||||
String:data_zvision[256],
|
||||
data_health,
|
||||
Float:data_speed,
|
||||
Float:data_jump_distance,
|
||||
Float:data_jump_height,
|
||||
Float:data_knockback,
|
||||
bool:data_nvgs[8],
|
||||
data_fov,
|
||||
bool:data_regen,
|
||||
data_regen_health,
|
||||
Float:data_regen_interval,
|
||||
bool:data_napalm,
|
||||
Float:data_napalm_time,
|
||||
bool:data_nofalldamage,
|
||||
data_kill_bonus,
|
||||
data_infect_health
|
||||
}
|
||||
|
||||
#define MAXCLASSES 20
|
||||
|
||||
new Handle:kvClasses = INVALID_HANDLE;
|
||||
|
||||
new arrayClasses[MAXCLASSES][ZR_ClassOptions];
|
||||
new classCount;
|
||||
|
||||
LoadClassData()
|
||||
{
|
||||
if (kvClasses != INVALID_HANDLE)
|
||||
{
|
||||
CloseHandle(kvClasses);
|
||||
}
|
||||
|
||||
kvClasses = CreateKeyValues("classes");
|
||||
|
||||
decl String:path[PLATFORM_MAX_PATH];
|
||||
BuildPath(Path_SM, path, sizeof(path), "configs/zr/classes.txt");
|
||||
|
||||
if (!FileToKeyValues(kvClasses, path))
|
||||
{
|
||||
SetFailState("\"%s\" missing from server", path);
|
||||
}
|
||||
|
||||
KvRewind(kvClasses);
|
||||
if (!KvGotoFirstSubKey(kvClasses))
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
{
|
||||
SetConVarBool(gCvars[CVAR_CLASSES], false);
|
||||
|
||||
ZR_LogMessage("Class auto-disable", path);
|
||||
}
|
||||
}
|
||||
|
||||
decl String:name[64];
|
||||
decl String:model[256];
|
||||
decl String:menu_description[256];
|
||||
decl String:zvision[256];
|
||||
|
||||
classCount = 0;
|
||||
|
||||
do
|
||||
{
|
||||
KvGetString(kvClasses, "name", name, sizeof(name));
|
||||
strcopy(arrayClasses[classCount][data_name], 64, name);
|
||||
|
||||
KvGetString(kvClasses, "model", model, sizeof(model));
|
||||
strcopy(arrayClasses[classCount][data_model], 256, model);
|
||||
|
||||
KvGetString(kvClasses, "menu_description", menu_description, sizeof(menu_description));
|
||||
strcopy(arrayClasses[classCount][data_menu_description], 256, menu_description);
|
||||
|
||||
decl String:cvar_zvision[256];
|
||||
GetConVarString(gCvars[CVAR_ZOMBIE_ZVISION], cvar_zvision, sizeof(cvar_zvision));
|
||||
|
||||
KvGetString(kvClasses, "zvision", zvision, sizeof(zvision), cvar_zvision);
|
||||
strcopy(arrayClasses[classCount][data_zvision], 256, zvision);
|
||||
|
||||
arrayClasses[classCount][data_health] = KvGetNum(kvClasses, "health"), GetConVarInt(gCvars[CVAR_ZOMBIE_HEALTH]);
|
||||
arrayClasses[classCount][data_speed] = KvGetFloat(kvClasses, "speed"), GetConVarFloat(gCvars[CVAR_ZOMBIE_SPEED]);
|
||||
arrayClasses[classCount][data_jump_distance] = KvGetFloat(kvClasses, "jump_distance"), GetConVarFloat(gCvars[CVAR_ZOMBIE_JUMP_DISTANCE]);
|
||||
arrayClasses[classCount][data_jump_height] = KvGetFloat(kvClasses, "jump_height"), GetConVarFloat(gCvars[CVAR_ZOMBIE_JUMP_HEIGHT]);
|
||||
arrayClasses[classCount][data_knockback] = KvGetFloat(kvClasses, "knockback"), GetConVarFloat(gCvars[CVAR_ZOMBIE_KNOCKBACK]);
|
||||
arrayClasses[classCount][data_nvgs] = bool:KvGetNum(kvClasses, "nvgs"), GetConVarBool(gCvars[CVAR_ZOMBIE_NVGS]);
|
||||
arrayClasses[classCount][data_fov] = KvGetNum(kvClasses, "fov"), GetConVarInt(gCvars[CVAR_ZOMBIE_FOV]);
|
||||
arrayClasses[classCount][data_regen] = bool:KvGetNum(kvClasses, "regen"), GetConVarBool(gCvars[CVAR_ZOMBIE_REGEN]);
|
||||
arrayClasses[classCount][data_regen_health] = KvGetNum(kvClasses, "regen_health"), GetConVarInt(gCvars[CVAR_ZOMBIE_REGEN_HEALTH]);
|
||||
arrayClasses[classCount][data_regen_interval] = KvGetFloat(kvClasses, "regen_interval"), GetConVarFloat(gCvars[CVAR_ZOMBIE_REGEN_INTERVAL]);
|
||||
arrayClasses[classCount][data_napalm] = bool:KvGetNum(kvClasses, "napalm"), GetConVarBool(gCvars[CVAR_ZOMBIE_NAPALM]);
|
||||
arrayClasses[classCount][data_napalm_time] = KvGetFloat(kvClasses, "napalm_time"), GetConVarFloat(gCvars[CVAR_ZOMBIE_NAPALM_TIME]);
|
||||
arrayClasses[classCount][data_nofalldamage] = bool:KvGetNum(kvClasses, "nofalldamage"), GetConVarBool(gCvars[CVAR_ZOMBIE_NOFALLDAMAGE]);
|
||||
arrayClasses[classCount][data_kill_bonus] = KvGetNum(kvClasses, "kill_bonus"), GetConVarInt(gCvars[CVAR_ZOMBIE_KILL_BONUS]);
|
||||
arrayClasses[classCount][data_infect_health] = KvGetNum(kvClasses, "infect_health"), GetConVarInt(gCvars[CVAR_ZOMBIE_INFECT_HEALTH]);
|
||||
|
||||
classCount++;
|
||||
} while (KvGotoNextKey(kvClasses));
|
||||
}
|
||||
|
||||
GetClassName(classindex, String:name[], maxlen)
|
||||
{
|
||||
strcopy(name, maxlen, arrayClasses[classindex][data_name]);
|
||||
}
|
||||
|
||||
GetClassModel(classindex, String:model[], maxlen)
|
||||
{
|
||||
strcopy(model, maxlen, arrayClasses[classindex][data_model]);
|
||||
}
|
||||
|
||||
GetClassMenuDescription(classindex, String:menudescription[], maxlen)
|
||||
{
|
||||
strcopy(menudescription, maxlen, arrayClasses[classindex][data_menu_description]);
|
||||
}
|
||||
|
||||
GetClassZVision(classindex, String:zvision[], maxlen)
|
||||
{
|
||||
strcopy(zvision, maxlen, arrayClasses[classindex][data_zvision]);
|
||||
}
|
||||
|
||||
GetClassHealth(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
{
|
||||
return arrayClasses[classindex][data_health];
|
||||
}
|
||||
|
||||
return GetConVarInt(gCvars[CVAR_ZOMBIE_HEALTH]);
|
||||
}
|
||||
|
||||
Float:GetClassSpeed(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
{
|
||||
return arrayClasses[classindex][data_speed];
|
||||
}
|
||||
|
||||
return GetConVarFloat(gCvars[CVAR_ZOMBIE_SPEED]);
|
||||
}
|
||||
|
||||
Float:GetClassJumpDistance(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
{
|
||||
return arrayClasses[classindex][data_jump_distance];
|
||||
}
|
||||
|
||||
return GetConVarFloat(gCvars[CVAR_ZOMBIE_JUMP_DISTANCE]);
|
||||
}
|
||||
|
||||
Float:GetClassJumpHeight(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
{
|
||||
return arrayClasses[classindex][data_jump_height];
|
||||
}
|
||||
|
||||
return GetConVarFloat(gCvars[CVAR_ZOMBIE_JUMP_HEIGHT]);
|
||||
}
|
||||
|
||||
Float:GetClassKnockback(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
{
|
||||
return arrayClasses[classindex][data_knockback];
|
||||
}
|
||||
|
||||
return GetConVarFloat(gCvars[CVAR_ZOMBIE_KNOCKBACK]);
|
||||
}
|
||||
|
||||
bool:GetClassNVGs(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
{
|
||||
return arrayClasses[classindex][data_nvgs];
|
||||
}
|
||||
|
||||
return GetConVarBool(gCvars[CVAR_ZOMBIE_NVGS]);
|
||||
}
|
||||
|
||||
GetClassFOV(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
{
|
||||
return arrayClasses[classindex][data_fov];
|
||||
}
|
||||
|
||||
return GetConVarInt(gCvars[CVAR_ZOMBIE_FOV]);
|
||||
}
|
||||
|
||||
bool:GetClassRegen(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
{
|
||||
return arrayClasses[classindex][data_regen];
|
||||
}
|
||||
|
||||
return GetConVarBool(gCvars[CVAR_ZOMBIE_REGEN]);
|
||||
}
|
||||
|
||||
GetClassRegenHealth(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
{
|
||||
return arrayClasses[classindex][data_regen_health];
|
||||
}
|
||||
|
||||
return GetConVarInt(gCvars[CVAR_ZOMBIE_REGEN_HEALTH]);
|
||||
}
|
||||
|
||||
Float:GetClassRegenInterval(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
{
|
||||
return arrayClasses[classindex][data_regen_interval];
|
||||
}
|
||||
|
||||
return GetConVarFloat(gCvars[CVAR_ZOMBIE_REGEN_INTERVAL]);
|
||||
}
|
||||
|
||||
bool:GetClassNapalm(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
{
|
||||
return arrayClasses[classindex][data_napalm];
|
||||
}
|
||||
|
||||
return GetConVarBool(gCvars[CVAR_ZOMBIE_NAPALM]);
|
||||
}
|
||||
|
||||
Float:GetClassNapalmTime(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
{
|
||||
return arrayClasses[classindex][data_napalm_time];
|
||||
}
|
||||
|
||||
return GetConVarFloat(gCvars[CVAR_ZOMBIE_NAPALM_TIME]);
|
||||
}
|
||||
|
||||
bool:GetClassNoFallDamage(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
{
|
||||
return arrayClasses[classindex][data_nofalldamage];
|
||||
}
|
||||
|
||||
return GetConVarBool(gCvars[CVAR_ZOMBIE_NOFALLDAMAGE]);
|
||||
}
|
||||
|
||||
GetClassKillBonus(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
{
|
||||
return arrayClasses[classindex][data_kill_bonus];
|
||||
}
|
||||
|
||||
return GetConVarInt(gCvars[CVAR_ZOMBIE_KILL_BONUS]);
|
||||
}
|
||||
|
||||
GetClassInfectHealth(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
{
|
||||
return arrayClasses[classindex][data_infect_health];
|
||||
}
|
||||
|
||||
return GetConVarInt(gCvars[CVAR_ZOMBIE_INFECT_HEALTH]);
|
||||
}
|
118
src/zr/commands.inc
Normal file
118
src/zr/commands.inc
Normal file
@ -0,0 +1,118 @@
|
||||
/**
|
||||
* ====================
|
||||
* Zombie:Reloaded
|
||||
* File: commands.inc
|
||||
* Author: Greyscale
|
||||
* ====================
|
||||
*/
|
||||
|
||||
CreateCommands()
|
||||
{
|
||||
RegAdminCmd("zr_infect", Command_Infect, ADMFLAG_GENERIC, "Infects the specified player");
|
||||
RegAdminCmd("zr_spawn", Command_Respawn, ADMFLAG_GENERIC, "Respawns the specified player following auto-respawning rules");
|
||||
|
||||
RegAdminCmd("zr_restrict", Command_Restrict, ADMFLAG_GENERIC, "Restrict a specified weapon");
|
||||
RegAdminCmd("zr_unrestrict", Command_UnRestrict, ADMFLAG_GENERIC, "Unrestrict a specified weapon");
|
||||
}
|
||||
|
||||
public Action:Command_Infect(client, argc)
|
||||
{
|
||||
new bool:enabled = GetConVarBool(gCvars[CVAR_ENABLE]);
|
||||
if (argc < 1 || !enabled)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:arg1[32];
|
||||
GetCmdArg(1, arg1, sizeof(arg1));
|
||||
|
||||
decl String:target_name[MAX_TARGET_LENGTH];
|
||||
new targets[MAXPLAYERS];
|
||||
new bool:tn_is_ml;
|
||||
|
||||
new tcount = ProcessTargetString(arg1, client, targets, MAXPLAYERS, COMMAND_FILTER_ALIVE, target_name, sizeof(target_name), tn_is_ml);
|
||||
if (tcount <= 0)
|
||||
{
|
||||
ReplyToTargetError(client, tcount);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
for (new x = 0; x < tcount; x++)
|
||||
{
|
||||
Zombify(targets[x], 0);
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_Respawn(client, argc)
|
||||
{
|
||||
new bool:enabled = GetConVarBool(gCvars[CVAR_ENABLE]);
|
||||
if (argc < 1 || !enabled)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:arg1[32];
|
||||
GetCmdArg(1, arg1, sizeof(arg1));
|
||||
|
||||
decl String:target_name[MAX_TARGET_LENGTH];
|
||||
new targets[MAXPLAYERS];
|
||||
new bool:tn_is_ml;
|
||||
|
||||
new tcount = ProcessTargetString(arg1, client, targets, MAXPLAYERS, COMMAND_FILTER_DEAD, target_name, sizeof(target_name), tn_is_ml);
|
||||
if (tcount <= 0)
|
||||
{
|
||||
ReplyToTargetError(client, tcount);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
for (new x = 0; x < tcount; x++)
|
||||
{
|
||||
RespawnPlayer(targets[x]);
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_Restrict(client, argc)
|
||||
{
|
||||
new bool:enabled = GetConVarBool(gCvars[CVAR_ENABLE]);
|
||||
if (argc < 1 || !enabled)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:arg1[32];
|
||||
GetCmdArg(1, arg1, sizeof(arg1));
|
||||
|
||||
new WepRestrictQuery:output = RestrictWeapon(arg1);
|
||||
|
||||
if (output == Existing)
|
||||
{
|
||||
ZR_ReplyToCommand(client, "Weapon already restricted", arg1);
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_UnRestrict(client, argc)
|
||||
{
|
||||
new bool:enabled = GetConVarBool(gCvars[CVAR_ENABLE]);
|
||||
if (argc < 1 || !enabled)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:arg1[32];
|
||||
GetCmdArg(1, arg1, sizeof(arg1));
|
||||
|
||||
new WepRestrictQuery:output = UnRestrictWeapon(arg1);
|
||||
|
||||
if (output == Invalid)
|
||||
{
|
||||
ZR_ReplyToCommand(client, "Weapon invalid", arg1);
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
191
src/zr/cvars.inc
Normal file
191
src/zr/cvars.inc
Normal file
@ -0,0 +1,191 @@
|
||||
/**
|
||||
* ====================
|
||||
* Zombie:Reloaded
|
||||
* File: cvars.inc
|
||||
* Author: Greyscale
|
||||
* ====================
|
||||
*/
|
||||
|
||||
enum ZRSettings
|
||||
{
|
||||
Handle:CVAR_ENABLE,
|
||||
Handle:CVAR_ALLOW_PLAYER_TEAM,
|
||||
Handle:CVAR_AMBIENCE,
|
||||
Handle:CVAR_AMBIENCE_FILE,
|
||||
Handle:CVAR_AMBIENCE_LENGTH,
|
||||
Handle:CVAR_AMBIENCE_VOLUME,
|
||||
Handle:CVAR_EMITSOUNDS,
|
||||
Handle:CVAR_CLASSES,
|
||||
Handle:CVAR_CLASSES_SPAWN,
|
||||
Handle:CVAR_CLASSES_RANDOM,
|
||||
Handle:CVAR_ZOMBIE_HEALTH,
|
||||
Handle:CVAR_ZOMBIE_SPEED,
|
||||
Handle:CVAR_ZOMBIE_JUMP_DISTANCE,
|
||||
Handle:CVAR_ZOMBIE_JUMP_HEIGHT,
|
||||
Handle:CVAR_ZOMBIE_KNOCKBACK,
|
||||
Handle:CVAR_ZOMBIE_NVGS,
|
||||
Handle:CVAR_ZOMBIE_FOV,
|
||||
Handle:CVAR_ZOMBIE_REGEN,
|
||||
Handle:CVAR_ZOMBIE_REGEN_HEALTH,
|
||||
Handle:CVAR_ZOMBIE_REGEN_INTERVAL,
|
||||
Handle:CVAR_ZOMBIE_NAPALM,
|
||||
Handle:CVAR_ZOMBIE_NAPALM_TIME,
|
||||
Handle:CVAR_ZOMBIE_NOFALLDAMAGE,
|
||||
Handle:CVAR_ZOMBIE_KILL_BONUS,
|
||||
Handle:CVAR_ZOMBIE_INFECT_HEALTH,
|
||||
Handle:CVAR_ZOMBIE_ZVISION,
|
||||
Handle:CVAR_ZVISION_REDISPLAY,
|
||||
Handle:CVAR_ZVISION_ALLOW_DISABLE,
|
||||
Handle:CVAR_DARK,
|
||||
Handle:CVAR_DARK_LEVEL,
|
||||
Handle:CVAR_DARK_SKY,
|
||||
Handle:CVAR_MOTHER_ZOMBIE_RATIO,
|
||||
Handle:CVAR_MOTHER_ZOMBIE_RESPAWN,
|
||||
Handle:CVAR_RESPAWN,
|
||||
Handle:CVAR_RESPAWN_TEAM,
|
||||
Handle:CVAR_RESPAWN_DELAY,
|
||||
Handle:CVAR_SUICIDE,
|
||||
Handle:CVAR_SPAWN_MIN,
|
||||
Handle:CVAR_SPAWN_MAX,
|
||||
Handle:CVAR_PROTECT,
|
||||
Handle:CVAR_CONSECUTIVE_INFECT,
|
||||
Handle:CVAR_OVERLAYS,
|
||||
Handle:CVAR_OVERLAYS_HUMAN,
|
||||
Handle:CVAR_OVERLAYS_ZOMBIE,
|
||||
Handle:CVAR_ZMARKET_BUYZONE,
|
||||
Handle:CVAR_ZSPAWN,
|
||||
Handle:CVAR_ZTELE,
|
||||
Handle:CVAR_ZTELE_LIMIT,
|
||||
Handle:CVAR_ZSTUCK,
|
||||
Handle:CVAR_ZHP,
|
||||
Handle:CVAR_ZHP_DEFAULT,
|
||||
Handle:CVAR_CASHFILL,
|
||||
Handle:CVAR_CASHAMOUNT,
|
||||
Handle:CVAR_INFECT_FIREBALL,
|
||||
Handle:CVAR_INFECT_SMOKE,
|
||||
Handle:CVAR_INFECT_SPARKS,
|
||||
Handle:CVAR_INFECT_SOUND,
|
||||
Handle:CVAR_INFECT_ESPLASH,
|
||||
Handle:CVAR_INFECT_SHAKE,
|
||||
Handle:CVAR_INFECT_SHAKE_AMP,
|
||||
Handle:CVAR_INFECT_SHAKE_FREQUENCY,
|
||||
Handle:CVAR_INFECT_SHAKE_DURATION
|
||||
}
|
||||
|
||||
new gCvars[ZRSettings];
|
||||
|
||||
CreateCvars()
|
||||
{
|
||||
gCvars[CVAR_ENABLE] = CreateConVar("zr_enable", "1", "Enable zombie gameplay (0: Disable)");
|
||||
gCvars[CVAR_ALLOW_PLAYER_TEAM] = CreateConVar("zr_allow_player_team", "0", "This will allow the player_team event to be fired on first team join, enable when using mani model menu (0: Disable)");
|
||||
gCvars[CVAR_AMBIENCE] = CreateConVar("zr_ambience", "1", "Enable creepy ambience to be played throughout the game (0: Disable)");
|
||||
gCvars[CVAR_AMBIENCE_FILE] = CreateConVar("zr_ambience_file", "ambient/zr/zr_ambience.mp3", "Path to ambient sound file that will be played throughout the game, when zr_ambience is 1");
|
||||
gCvars[CVAR_AMBIENCE_LENGTH] = CreateConVar("zr_ambience_length", "60.0", "The length, in seconds, of the ambient sound file");
|
||||
gCvars[CVAR_AMBIENCE_VOLUME] = CreateConVar("zr_ambience_volume", "0.6", "Volume of ambient sounds when zr_ambience is 1 (0.0: Unhearable, 1.0: Max volume)");
|
||||
gCvars[CVAR_EMITSOUNDS] = CreateConVar("zr_emitsounds", "50", "How often a zombie emits a sound, in seconds (0: Disable)");
|
||||
gCvars[CVAR_CLASSES] = CreateConVar("zr_classes", "1", "Enable zombie classes");
|
||||
gCvars[CVAR_CLASSES_SPAWN] = CreateConVar("zr_classes_spawn", "0", "Classmenu is re-displayed every spawn (0: Disable)");
|
||||
gCvars[CVAR_CLASSES_RANDOM] = CreateConVar("zr_classes_random", "0", "A random class is assigned to each player every round (0: Disable)");
|
||||
gCvars[CVAR_ZOMBIE_HEALTH] = CreateConVar("zr_zombie_health", "5000", "The default health of a zombie");
|
||||
gCvars[CVAR_ZOMBIE_SPEED] = CreateConVar("zr_zombie_speed", "350", "How fast zombies travel (300: Default speed, 600: Double speed)");
|
||||
gCvars[CVAR_ZOMBIE_JUMP_DISTANCE] = CreateConVar("zr_zombie_jump_distance", "0.1", "How far the zombie jumps, (0: Regular jump distance)");
|
||||
gCvars[CVAR_ZOMBIE_JUMP_HEIGHT] = CreateConVar("zr_zombie_jump_height", "10.0", "How high a zombie jumps (0: Regular jump height)");
|
||||
gCvars[CVAR_ZOMBIE_KNOCKBACK] = CreateConVar("zr_zombie_knockback", "4", "How far zombies are pushed back when shot (1: Default)");
|
||||
gCvars[CVAR_ZOMBIE_NVGS] = CreateConVar("zr_zombie_nvgs", "0", "Zombies will receive nightvision and it will automatically be enabled (0: No night vision, recommended if using zvision)");
|
||||
gCvars[CVAR_ZOMBIE_FOV] = CreateConVar("zr_zombie_fov", "110", "The field of vision of zombies (90: Default vision)");
|
||||
gCvars[CVAR_ZOMBIE_REGEN] = CreateConVar("zr_zombie_regen", "0", "Zombies will regenerate health");
|
||||
gCvars[CVAR_ZOMBIE_REGEN_HEALTH] = CreateConVar("zr_zombie_regen_health", "1", "How much health is regenerated when zr_zombie_regen is 1");
|
||||
gCvars[CVAR_ZOMBIE_REGEN_INTERVAL] = CreateConVar("zr_zombie_regen_interval", "5", "How often, in seconds, a zombie regenerates health when zr_zombie_regen is 1");
|
||||
gCvars[CVAR_ZOMBIE_NAPALM] = CreateConVar("zr_zombie_napalm", "1", "Turns grenades into napalm grenades that light zombies on fire (0: Disable)");
|
||||
gCvars[CVAR_ZOMBIE_NAPALM_TIME] = CreateConVar("zr_zombie_napalm_time", "20", "How long the zombie burns when zr_napalm is 1");
|
||||
gCvars[CVAR_ZOMBIE_NOFALLDAMAGE] = CreateConVar("zr_zombie_nofalldamage", "0", "Zombies wont be hurt from falling (0: Disable)");
|
||||
gCvars[CVAR_ZOMBIE_KILL_BONUS] = CreateConVar("zr_zombie_kill_bonus", "2", "How many additional kills are rewarded to the killer of the zombie");
|
||||
gCvars[CVAR_ZOMBIE_INFECT_HEALTH] = CreateConVar("zr_zombie_infect_health", "100", "How much health a zombie gains when infecting a human (0: Disable)");
|
||||
gCvars[CVAR_ZOMBIE_ZVISION] = CreateConVar("zr_zombie_zvision", "overlays/zr/zvision", "Overlay to be shown on all zombies' screen on infection (Leave empty to disable)");
|
||||
gCvars[CVAR_ZVISION_REDISPLAY] = CreateConVar("zr_zvision_redisplay", "0.2", "Frequency, in seconds, to display zvision on the client's screen (Never go below 0.1, 0.2 seems safe)");
|
||||
gCvars[CVAR_ZVISION_ALLOW_DISABLE] = CreateConVar("zr_zvision_allow_disable", "1", "Allow users to disable ZVision with their nightvision key (0: Disable)");
|
||||
gCvars[CVAR_DARK] = CreateConVar("zr_dark", "0", "Default value for darkening maps, most dislike this feature (0: Disable)");
|
||||
gCvars[CVAR_DARK_LEVEL] = CreateConVar("zr_dark_level", "a", "The darkness of the map, a being the darkest, z being extremely bright when zr_dark is 1 (n: Default)");
|
||||
gCvars[CVAR_DARK_SKY] = CreateConVar("zr_dark_sky", "sky_borealis01", "The sky the map will have when zr_dark is 1");
|
||||
gCvars[CVAR_MOTHER_ZOMBIE_RATIO] = CreateConVar("zr_mother_zombie_ratio", "5", "For every 'x' number of humans, there will be 1 zombie (0: Always only 1 mother zombie)");
|
||||
gCvars[CVAR_MOTHER_ZOMBIE_RESPAWN] = CreateConVar("zr_mother_zombie_respawn", "0", "First zombie(s) will be teleported back to spawn when infected (0: Disable)");
|
||||
gCvars[CVAR_RESPAWN] = CreateConVar("zr_respawn", "0", "When player is killed, player will respawn");
|
||||
gCvars[CVAR_RESPAWN_TEAM] = CreateConVar("zr_respawn_team", "zombie", "Which team to respawn player as (Choices: zombie, human)");
|
||||
gCvars[CVAR_RESPAWN_DELAY] = CreateConVar("zr_respawn_delay", "1", "How long to wait after death to respawn, in seconds");
|
||||
gCvars[CVAR_SUICIDE] = CreateConVar("zr_suicide", "1", "Stops players from suiciding");
|
||||
gCvars[CVAR_SPAWN_MIN] = CreateConVar("zr_spawn_min", "30", "Minimum time a player is picked to be zombie after the round starts, in seconds");
|
||||
gCvars[CVAR_SPAWN_MAX] = CreateConVar("zr_spawn_max", "50", "Maximum time a player is picked to be zombie after the round starts, in seconds");
|
||||
gCvars[CVAR_PROTECT] = CreateConVar("zr_protect", "10", "Players that join late will be protected for this long, in seconds (0: Disable)");
|
||||
gCvars[CVAR_CONSECUTIVE_INFECT] = CreateConVar("zr_consecutive_infect", "0", "Allow player to be randomly chosen twice in a row to be a mother zombie (0: Disable)");
|
||||
gCvars[CVAR_OVERLAYS] = CreateConVar("zr_overlays", "1", "Will show overlays that tell who the winner of the round was (0: Disable)");
|
||||
gCvars[CVAR_OVERLAYS_HUMAN] = CreateConVar("zr_overlays_human", "overlays/zr/humans_win", "The overlay shown to tell everyone that humans won when zr_overlays is 1");
|
||||
gCvars[CVAR_OVERLAYS_ZOMBIE] = CreateConVar("zr_overlays_zombie", "overlays/zr/zombies_win", "The overlay shown to tell everyone that zombies won when zr_overlays is 1");
|
||||
gCvars[CVAR_ZMARKET_BUYZONE] = CreateConVar("zr_zmarket_buyzone", "1", "Must be in buyzone to access !zmarket, if Market is installed (0: Can be used anywhere)");
|
||||
gCvars[CVAR_ZSPAWN] = CreateConVar("zr_zspawn", "1", "Allow players to spawn if they just joined the game (0: Disable)");
|
||||
gCvars[CVAR_ZTELE] = CreateConVar("zr_ztele", "1", "Allows zombies who get stuck to teleport back to spawn (0: Disable)");
|
||||
gCvars[CVAR_ZTELE_LIMIT] = CreateConVar("zr_ztele_limit", "1", "Max amount of teleports per round when zr_ztele is 1 (0: Unlimited)");
|
||||
gCvars[CVAR_ZSTUCK] = CreateConVar("zr_zstuck", "1", "Allow players that are stuck together to get unstuck (0: Disable)");
|
||||
gCvars[CVAR_ZHP] = CreateConVar("zr_zhp", "1", "Allows clients to enable/disable zombie health display (1: On, 0: Off)");
|
||||
gCvars[CVAR_ZHP_DEFAULT] = CreateConVar("zr_zhp_default", "1", "The default value of zombie health display to new clients (1: On, 0: Off)");
|
||||
gCvars[CVAR_CASHFILL] = CreateConVar("zr_cashfill", "1", "Enable the mod to set the players cash to zr_cashamount (0: Disabled)");
|
||||
gCvars[CVAR_CASHAMOUNT] = CreateConVar("zr_cashamount", "12000", "How much money players will have when they spawn when zr_cashfill is 1");
|
||||
gCvars[CVAR_INFECT_FIREBALL] = CreateConVar("zr_infect_fireball", "1", "A fireball is created when a player is infected ( 0: Disable)");
|
||||
gCvars[CVAR_INFECT_SMOKE] = CreateConVar("zr_infect_smoke", "1", "A puff of smoke is created when a player is infected (0: Disable)");
|
||||
gCvars[CVAR_INFECT_SPARKS] = CreateConVar("zr_infect_sparks", "1", "Sparks are emitted when a player is infected (0: Disable)");
|
||||
gCvars[CVAR_INFECT_SOUND] = CreateConVar("zr_infect_sound", "npc/fast_zombie/fz_scream1.wav", "Sound played from from player on infection (Leave blank to disable)");
|
||||
gCvars[CVAR_INFECT_ESPLASH] = CreateConVar("zr_infect_esplash", "1", "An energy splash is emitted when player is infected ( 0: Disable)");
|
||||
gCvars[CVAR_INFECT_SHAKE] = CreateConVar("zr_infect_shake", "1", "Player's screen is shaken on infection (0: Disable)");
|
||||
gCvars[CVAR_INFECT_SHAKE_AMP] = CreateConVar("zr_infect_shake_amp", "15.0", "Amplitude of the shake, when zr_infect_shake is 1");
|
||||
gCvars[CVAR_INFECT_SHAKE_FREQUENCY] = CreateConVar("zr_infect_shake_frequency", "1.0", "Frequency of the shake, when zr_infect_shake is 1");
|
||||
gCvars[CVAR_INFECT_SHAKE_DURATION] = CreateConVar("zr_infect_shake_duration", "5.0", "Duration of the shake, when zr_infect_shake is 1");
|
||||
|
||||
HookConVarChange(gCvars[CVAR_ENABLE], EnableHook);
|
||||
|
||||
AutoExecConfig(true, "zombiereloaded", "sourcemod/zombiereloaded");
|
||||
}
|
||||
|
||||
HookCvars()
|
||||
{
|
||||
SetConVarBool(FindConVar("mp_autoteambalance"), false);
|
||||
SetConVarInt(FindConVar("mp_limitteams"), 0);
|
||||
|
||||
HookConVarChange(FindConVar("mp_autoteambalance"), AutoTeamBalanceHook);
|
||||
HookConVarChange(FindConVar("mp_limitteams"), LimitTeamsHook);
|
||||
|
||||
HookConVarChange(FindConVar("mp_restartgame"), RestartGameHook);
|
||||
}
|
||||
|
||||
UnhookCvars()
|
||||
{
|
||||
UnhookConVarChange(FindConVar("mp_autoteambalance"), AutoTeamBalanceHook);
|
||||
UnhookConVarChange(FindConVar("mp_limitteams"), LimitTeamsHook);
|
||||
|
||||
UnhookConVarChange(FindConVar("mp_restartgame"), RestartGameHook);
|
||||
}
|
||||
|
||||
public EnableHook(Handle:convar, const String:oldValue[], const String:newValue[])
|
||||
{
|
||||
new bool:enable = bool:StringToInt(newValue);
|
||||
|
||||
if (enable)
|
||||
{
|
||||
HookEvents();
|
||||
HookCvars();
|
||||
|
||||
TerminateRound(3.0, Game_Commencing);
|
||||
}
|
||||
else
|
||||
{
|
||||
ZREnd();
|
||||
}
|
||||
}
|
||||
|
||||
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[])
|
||||
{
|
||||
SetConVarInt(FindConVar("mp_limitteams"), 0);
|
||||
}
|
178
src/zr/damagecontrol.inc
Normal file
178
src/zr/damagecontrol.inc
Normal file
@ -0,0 +1,178 @@
|
||||
/**
|
||||
* ====================
|
||||
* Zombie:Reloaded
|
||||
* File: damagecontrol.inc
|
||||
* Author: Greyscale
|
||||
* ====================
|
||||
*/
|
||||
|
||||
#define DMG_GENERIC 0 // generic damage was done
|
||||
#define DMG_BULLET (1 << 1) // shot
|
||||
#define DMG_SLASH (1 << 2) // cut, clawed, stabbed
|
||||
#define DMG_BURN (1 << 3) // heat burned
|
||||
#define DMG_FALL (1 << 5) // fell too far
|
||||
#define DMG_BLAST (1 << 6) // explosive blast damage
|
||||
#define DMG_DROWN (1 << 14) // Drowning
|
||||
|
||||
enum ZRHooks
|
||||
{
|
||||
Hook_TraceAttack,
|
||||
Hook_OnTakeDamage
|
||||
}
|
||||
|
||||
new gHooks[MAXPLAYERS+1][ZRHooks];
|
||||
|
||||
InitDmgControl()
|
||||
{
|
||||
RegConsoleCmd("kill", Attempt_Suicide);
|
||||
RegConsoleCmd("jointeam", Attempt_Suicide);
|
||||
RegConsoleCmd("spectate", Attempt_Suicide);
|
||||
}
|
||||
|
||||
ClientHookAttack(client)
|
||||
{
|
||||
gHooks[client][Hook_TraceAttack] = Hacks_Hook(client, HACKS_HTYPE_TRACEATTACK, TraceAttack, false);
|
||||
gHooks[client][Hook_OnTakeDamage] = Hacks_Hook(client, HACKS_HTYPE_ONTAKEDAMAGE, OnTakeDamage, false);
|
||||
}
|
||||
|
||||
ClientUnHookAttack(client)
|
||||
{
|
||||
Hacks_Unhook(gHooks[client][Hook_TraceAttack]);
|
||||
Hacks_Unhook(gHooks[client][Hook_OnTakeDamage]);
|
||||
}
|
||||
|
||||
public TraceAttack(client, inflictor, attacker, damage, hitbox, hitgroup)
|
||||
{
|
||||
new bool:enabled = GetConVarBool(gCvars[CVAR_ENABLE]);
|
||||
|
||||
if (!attacker || !IsClientInGame(attacker) || !enabled)
|
||||
{
|
||||
return Hacks_Continue;
|
||||
}
|
||||
|
||||
if (IsPlayerZombie(client) && IsPlayerZombie(attacker))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (IsPlayerHuman(client) && IsPlayerHuman(attacker))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Hacks_Continue;
|
||||
}
|
||||
|
||||
public OnTakeDamage(client, inflictor, attacker, damage, damagetype, ammotype)
|
||||
{
|
||||
new bool:enabled = GetConVarBool(gCvars[CVAR_ENABLE]);
|
||||
if (!enabled)
|
||||
{
|
||||
return Hacks_Continue;
|
||||
}
|
||||
|
||||
decl String:classname[64];
|
||||
GetEdictClassname(inflictor, classname, sizeof(classname));
|
||||
if (StrContains(classname, "trigger") > -1)
|
||||
{
|
||||
return Hacks_Continue;
|
||||
}
|
||||
|
||||
if (damagetype & DMG_FALL)
|
||||
{
|
||||
if (!IsPlayerZombie(client))
|
||||
{
|
||||
return Hacks_Continue;
|
||||
}
|
||||
|
||||
new bool:blockfalldamage = GetClassNoFallDamage(pClass[client]);
|
||||
if (!blockfalldamage)
|
||||
{
|
||||
return Hacks_Continue;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (damagetype & DMG_BLAST)
|
||||
{
|
||||
if (!IsPlayerHuman(client) || !IsClientInGame(attacker))
|
||||
{
|
||||
return Hacks_Continue;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (damagetype & DMG_BULLET)
|
||||
{
|
||||
if (!client || !IsClientInGame(client))
|
||||
{
|
||||
return Hacks_Continue;
|
||||
}
|
||||
|
||||
if (!attacker || !IsClientInGame(attacker))
|
||||
{
|
||||
return Hacks_Continue;
|
||||
}
|
||||
|
||||
if (IsPlayerZombie(client) && IsPlayerHuman(attacker))
|
||||
{
|
||||
return Hacks_Continue;
|
||||
}
|
||||
|
||||
if (IsPlayerHuman(client) && IsPlayerZombie(attacker))
|
||||
{
|
||||
new health = GetClientHealth(client);
|
||||
SetEntityHealth(client, health + damage);
|
||||
|
||||
return Hacks_Continue;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Hacks_Continue;
|
||||
}
|
||||
|
||||
public Action:Attempt_Suicide(client, argc)
|
||||
{
|
||||
if (!client)
|
||||
{
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
new bool:enabled = GetConVarBool(gCvars[CVAR_ENABLE]);
|
||||
if (!enabled)
|
||||
{
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
new bool:suicide = GetConVarBool(gCvars[CVAR_SUICIDE]);
|
||||
if (!suicide)
|
||||
{
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
decl String:cmd[16];
|
||||
GetCmdArg(0, cmd, sizeof(cmd));
|
||||
|
||||
if (!IsPlayerZombie(client) && StrEqual(cmd, "spectate", false))
|
||||
{
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
if (!IsPlayerZombie(client) && !GetConVarBool(gCvars[CVAR_RESPAWN]))
|
||||
{
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
if (!IsPlayerAlive(client))
|
||||
{
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
ZR_ReplyToCommand(client, "Suicide text");
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
465
src/zr/event.inc
Normal file
465
src/zr/event.inc
Normal file
@ -0,0 +1,465 @@
|
||||
/**
|
||||
* ====================
|
||||
* Zombie:Reloaded
|
||||
* File: events.inc
|
||||
* Author: Greyscale
|
||||
* ====================
|
||||
*/
|
||||
|
||||
HookEvents()
|
||||
{
|
||||
HookEvent("round_start", RoundStart);
|
||||
HookEvent("round_freeze_end", RoundFreezeEnd);
|
||||
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);
|
||||
}
|
||||
|
||||
UnhookEvents()
|
||||
{
|
||||
UnhookEvent("round_start", RoundStart);
|
||||
UnhookEvent("round_freeze_end", RoundFreezeEnd);
|
||||
UnhookEvent("round_end", RoundEnd);
|
||||
UnhookEvent("player_team", PlayerTeam, EventHookMode_Pre);
|
||||
UnhookEvent("player_spawn", PlayerSpawn);
|
||||
UnhookEvent("player_hurt", PlayerHurt);
|
||||
UnhookEvent("player_death", PlayerDeath);
|
||||
UnhookEvent("player_jump", PlayerJump);
|
||||
}
|
||||
|
||||
public Action:RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
{
|
||||
ChangeLightStyle();
|
||||
|
||||
RestartAmbience();
|
||||
|
||||
RefreshList();
|
||||
|
||||
if (tRound != INVALID_HANDLE)
|
||||
{
|
||||
CloseHandle(tRound);
|
||||
tRound = INVALID_HANDLE;
|
||||
}
|
||||
|
||||
if (tInfect != INVALID_HANDLE)
|
||||
{
|
||||
CloseHandle(tInfect);
|
||||
tInfect = INVALID_HANDLE;
|
||||
}
|
||||
|
||||
|
||||
ZR_PrintToChat(0, "Round objective");
|
||||
}
|
||||
|
||||
public Action:RoundFreezeEnd(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
{
|
||||
RemoveObjectives();
|
||||
|
||||
if (tRound != INVALID_HANDLE)
|
||||
{
|
||||
CloseHandle(tRound);
|
||||
}
|
||||
|
||||
new Float:roundlen = GetConVarFloat(FindConVar("mp_roundtime")) * 60.0;
|
||||
tRound = CreateTimer(roundlen, RoundOver, _, TIMER_FLAG_NO_MAPCHANGE);
|
||||
|
||||
if (tInfect != INVALID_HANDLE)
|
||||
{
|
||||
CloseHandle(tInfect);
|
||||
}
|
||||
|
||||
new Float:min = GetConVarFloat(gCvars[CVAR_SPAWN_MIN]);
|
||||
new Float:max = GetConVarFloat(gCvars[CVAR_SPAWN_MAX]);
|
||||
new Float:randlen = GetRandomFloat(min, max);
|
||||
tInfect = CreateTimer(randlen, MotherZombie, _, TIMER_FLAG_NO_MAPCHANGE);
|
||||
}
|
||||
|
||||
public Action:RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
{
|
||||
if (tRound != INVALID_HANDLE)
|
||||
{
|
||||
CloseHandle(tRound);
|
||||
tRound = INVALID_HANDLE;
|
||||
}
|
||||
|
||||
if (tInfect != INVALID_HANDLE)
|
||||
{
|
||||
CloseHandle(tInfect);
|
||||
tInfect = INVALID_HANDLE;
|
||||
}
|
||||
|
||||
zombieSpawned = false;
|
||||
|
||||
new maxplayers = GetMaxClients();
|
||||
for (new x = 1; x<= maxplayers; x++)
|
||||
{
|
||||
if (!IsClientInGame(x))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
gZombie[x] = false;
|
||||
|
||||
new bool:consecutive_infect = GetConVarBool(gCvars[CVAR_CONSECUTIVE_INFECT]);
|
||||
gBlockMotherInfect[x] = consecutive_infect ? false : motherZombie[x];
|
||||
}
|
||||
|
||||
BalanceTeams();
|
||||
|
||||
new reason = GetEventInt(event, "reason");
|
||||
|
||||
if (reason == CTs_PreventEscape)
|
||||
{
|
||||
ShowOverlays(5.0, Human);
|
||||
}
|
||||
else if (reason == Terrorists_Escaped)
|
||||
{
|
||||
ShowOverlays(5.0, Zombie);
|
||||
}
|
||||
}
|
||||
|
||||
public Action:PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
{
|
||||
new index = GetClientOfUserId(GetEventInt(event, "userid"));
|
||||
new team = GetEventInt(event, "team");
|
||||
|
||||
if (team == 1)
|
||||
{
|
||||
gZombie[index] = false;
|
||||
motherZombie[index] = false;
|
||||
}
|
||||
|
||||
new bool:allow_player_team = GetConVarBool(gCvars[CVAR_ALLOW_PLAYER_TEAM]);
|
||||
if (allow_player_team && !IsPlayerInList(index))
|
||||
{
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
{
|
||||
new index = GetClientOfUserId(GetEventInt(event, "userid"));
|
||||
|
||||
for (new x = 0; x < MAXTIMERS; x++)
|
||||
{
|
||||
if (x == TRESPAWN)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tHandles[index][x] != INVALID_HANDLE)
|
||||
{
|
||||
CloseHandle(tHandles[index][x]);
|
||||
tHandles[index][x] = INVALID_HANDLE;
|
||||
}
|
||||
}
|
||||
|
||||
gZombie[index] = false;
|
||||
motherZombie[index] = false;
|
||||
|
||||
SetPlayerFOV(index, 90);
|
||||
|
||||
ClientCommand(index, "r_screenoverlay \"\"");
|
||||
|
||||
new team = GetClientTeam(index);
|
||||
if (team != CS_TEAM_T && team != CS_TEAM_CT)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
new bool:cashfill = GetConVarBool(gCvars[CVAR_CASHFILL]);
|
||||
if (cashfill)
|
||||
{
|
||||
new cash = GetConVarInt(gCvars[CVAR_CASHAMOUNT]);
|
||||
SetPlayerMoney(index, cash);
|
||||
}
|
||||
|
||||
teleCount[index] = 0;
|
||||
GetClientAbsOrigin(index, spawnLoc[index]);
|
||||
|
||||
NightVisionOn(index, false);
|
||||
NightVision(index, false);
|
||||
|
||||
if (pNextClass[index] != -1)
|
||||
{
|
||||
Call_StartForward(hOnZClassChanged);
|
||||
Call_PushCell(index);
|
||||
Call_PushCell(pClass[index]);
|
||||
Call_PushCell(pNextClass[index]);
|
||||
Call_Finish();
|
||||
|
||||
pClass[index] = pNextClass[index];
|
||||
pNextClass[index] = -1;
|
||||
}
|
||||
|
||||
pProtect[index] = false;
|
||||
if (zombieSpawned)
|
||||
{
|
||||
if (team == CS_TEAM_T)
|
||||
{
|
||||
CS_SwitchTeam(index, CS_TEAM_CT);
|
||||
CS_RespawnPlayer(index);
|
||||
}
|
||||
|
||||
new protect = GetConVarInt(gCvars[CVAR_PROTECT]);
|
||||
if (protect > 0)
|
||||
{
|
||||
decl String:respawnteam[32];
|
||||
GetConVarString(gCvars[CVAR_RESPAWN_TEAM], respawnteam, sizeof(respawnteam));
|
||||
|
||||
if (!StrEqual(respawnteam, "zombie", false))
|
||||
{
|
||||
pProtect[index] = true;
|
||||
|
||||
ZR_PrintToChat(index, "Spawn protection begin", protect);
|
||||
ZR_PrintCenterText(index, "Spawn protection begin", protect);
|
||||
|
||||
if (tHandles[index][TPROTECT] != INVALID_HANDLE)
|
||||
{
|
||||
CloseHandle(tHandles[index][TPROTECT]);
|
||||
}
|
||||
|
||||
tHandles[index][TPROTECT] = CreateTimer(float(protect), EndProtect, index, TIMER_FLAG_NO_MAPCHANGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
new bool:randomclass = GetConVarBool(gCvars[CVAR_CLASSES_RANDOM]);
|
||||
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
{
|
||||
new bool:showmenu = GetConVarBool(gCvars[CVAR_CLASSES_SPAWN]);
|
||||
if (showmenu && !randomclass)
|
||||
{
|
||||
ClassMenu(index);
|
||||
}
|
||||
}
|
||||
|
||||
ZR_PrintToChat(index, "!zmenu reminder");
|
||||
|
||||
decl String:steamid[16];
|
||||
GetClientAuthString(index, steamid, sizeof(steamid));
|
||||
if (StrEqual(steamid, "BOT") || randomclass)
|
||||
{
|
||||
new class = GetRandomInt(0, classCount - 1);
|
||||
|
||||
Call_StartForward(hOnZClassChanged);
|
||||
Call_PushCell(index);
|
||||
Call_PushCell(pClass[index]);
|
||||
Call_PushCell(class);
|
||||
Call_Finish();
|
||||
|
||||
pClass[index] = class;
|
||||
|
||||
decl String:classname[32];
|
||||
GetClassName(class, classname, sizeof(classname));
|
||||
|
||||
ZR_PrintToChat(index, "Auto-assign", classname);
|
||||
}
|
||||
}
|
||||
|
||||
public Action:PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
{
|
||||
new index = GetClientOfUserId(GetEventInt(event, "userid"));
|
||||
new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
|
||||
|
||||
new dmg = GetEventInt(event, "dmg_health");
|
||||
|
||||
decl String:weapon[32];
|
||||
GetEventString(event, "weapon", weapon, sizeof(weapon));
|
||||
|
||||
if (attacker != 0)
|
||||
{
|
||||
if (IsPlayerHuman(index) && IsPlayerZombie(attacker))
|
||||
{
|
||||
if (StrEqual(weapon, "knife"))
|
||||
{
|
||||
Zombify(index, attacker);
|
||||
}
|
||||
}
|
||||
else if (IsPlayerHuman(attacker))
|
||||
{
|
||||
new Float:knockback = GetClassKnockback(pClass[index]);
|
||||
|
||||
new Float:clientloc[3];
|
||||
new Float:attackerloc[3];
|
||||
|
||||
GetClientAbsOrigin(index, clientloc);
|
||||
|
||||
if (!StrEqual(weapon, "hegrenade"))
|
||||
{
|
||||
GetClientAbsOrigin(attacker, attackerloc);
|
||||
|
||||
new bool:shotgun = (StrEqual(weapon, "m3") || StrEqual(weapon, "xm1014"));
|
||||
|
||||
KnockBack(index, clientloc, attackerloc, knockback, dmg, shotgun);
|
||||
}
|
||||
else
|
||||
{
|
||||
new Float:heLoc[3];
|
||||
FindExplodingGrenade(heLoc);
|
||||
|
||||
KnockBack(index, clientloc, heLoc, knockback, dmg, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!IsPlayerZombie(index))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (GetRandomInt(1, 5) == 1)
|
||||
{
|
||||
decl String:sound[64];
|
||||
new randsound = GetRandomInt(1, 6);
|
||||
|
||||
Format(sound, sizeof(sound), "npc/zombie/zombie_pain%d.wav", randsound);
|
||||
|
||||
PrecacheSound(sound);
|
||||
EmitSoundToAll(sound, index);
|
||||
}
|
||||
|
||||
new bool:napalm = GetClassNapalm(pClass[index]);
|
||||
if (napalm)
|
||||
{
|
||||
if (StrEqual(weapon, "hegrenade", false))
|
||||
{
|
||||
new Float:napalm_time = GetClassNapalmTime(pClass[index]);
|
||||
IgniteEntity(index, napalm_time);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateHPDisplay(index);
|
||||
|
||||
if (GetClassRegen(pClass[index]))
|
||||
{
|
||||
if (tHandles[index][TREGEN] == INVALID_HANDLE)
|
||||
{
|
||||
new Float:interval = GetClassRegenInterval(pClass[index]);
|
||||
tHandles[index][TREGEN] = CreateTimer(interval, Regenerate, index, TIMER_REPEAT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FindExplodingGrenade(Float:heLoc[3])
|
||||
{
|
||||
decl String:classname[64];
|
||||
|
||||
new maxentities = GetMaxEntities();
|
||||
for (new x = GetMaxClients(); x <= maxentities; x++)
|
||||
{
|
||||
if (IsValidEdict(x))
|
||||
{
|
||||
GetEdictClassname(x, classname, sizeof(classname));
|
||||
if (StrEqual(classname, "hegrenade_projectile"))
|
||||
{
|
||||
new takedamage = GetEntProp(x, Prop_Data, "m_takedamage");
|
||||
if (takedamage == 0)
|
||||
{
|
||||
GetEntPropVector(x, Prop_Send, "m_vecOrigin", heLoc);
|
||||
return x;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
{
|
||||
new index = GetClientOfUserId(GetEventInt(event, "userid"));
|
||||
new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
|
||||
|
||||
SetPlayerFOV(index, DEFAULT_FOV);
|
||||
|
||||
ExtinguishEntity(index);
|
||||
|
||||
decl String:weapon[32];
|
||||
|
||||
GetEventString(event, "weapon", weapon, sizeof(weapon));
|
||||
if (StrEqual(weapon, "zombie_claws_of_death", false))
|
||||
{
|
||||
if (index)
|
||||
{
|
||||
AddPlayerDeath(index, 1);
|
||||
}
|
||||
|
||||
if (attacker)
|
||||
{
|
||||
AddPlayerScore(attacker, 1);
|
||||
|
||||
new healthgain = GetClassInfectHealth(pClass[attacker]);
|
||||
new health = GetClientHealth(attacker);
|
||||
|
||||
SetEntityHealth(attacker, health + healthgain);
|
||||
|
||||
UpdateHPDisplay(attacker);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (IsPlayerZombie(index))
|
||||
{
|
||||
decl String:sound[64];
|
||||
|
||||
new randsound = GetRandomInt(1, 3);
|
||||
Format(sound, sizeof(sound), "npc/zombie/zombie_die%d.wav", randsound);
|
||||
|
||||
PrecacheSound(sound);
|
||||
EmitSoundToAll(sound, index);
|
||||
|
||||
if (attacker)
|
||||
{
|
||||
new bonus = GetClassKillBonus(pClass[index]);
|
||||
AddPlayerScore(attacker, bonus);
|
||||
}
|
||||
}
|
||||
|
||||
for (new x = 0; x < MAXTIMERS; x++)
|
||||
{
|
||||
if (tHandles[index][x] != INVALID_HANDLE)
|
||||
{
|
||||
CloseHandle(tHandles[index][x]);
|
||||
tHandles[index][x] = INVALID_HANDLE;
|
||||
}
|
||||
}
|
||||
|
||||
new bool:respawn = GetConVarBool(gCvars[CVAR_RESPAWN]);
|
||||
if (respawn)
|
||||
{
|
||||
new Float:delay = GetConVarFloat(gCvars[CVAR_RESPAWN_DELAY]);
|
||||
tHandles[index][TRESPAWN] = CreateTimer(delay, RespawnTimer, index, TIMER_FLAG_NO_MAPCHANGE);
|
||||
}
|
||||
}
|
||||
|
||||
new ZTeam:team = IsRoundOver();
|
||||
if (team == Neither)
|
||||
{
|
||||
ClientCommand(index, "r_screenoverlay \"\"");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
RoundWin(team);
|
||||
}
|
||||
|
||||
public Action:PlayerJump(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
{
|
||||
new index = GetClientOfUserId(GetEventInt(event, "userid"));
|
||||
|
||||
if (IsPlayerZombie(index))
|
||||
{
|
||||
new Float:distance = GetClassJumpDistance(pClass[index]);
|
||||
new Float:height = GetClassJumpHeight(pClass[index]);
|
||||
|
||||
JumpBoost(index, distance, height);
|
||||
}
|
||||
}
|
36
src/zr/global.inc
Normal file
36
src/zr/global.inc
Normal file
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* ====================
|
||||
* Zombie:Reloaded
|
||||
* File: global.inc
|
||||
* Author: Greyscale
|
||||
* ====================
|
||||
*/
|
||||
|
||||
new Handle:hZombify = INVALID_HANDLE;
|
||||
new Handle:hOnZClassChanged = INVALID_HANDLE;
|
||||
|
||||
CreateGlobals()
|
||||
{
|
||||
CreateNative("ZR_IsClientZombie", Native_IsClientZombie);
|
||||
CreateNative("ZR_GetClientZClass", Native_GetClientZClass);
|
||||
CreateNative("ZR_HasZombieSpawned", Native_HasZombieSpawned);
|
||||
|
||||
hZombify = CreateGlobalForward("ZR_Zombify", ET_Ignore, Param_Cell, Param_Cell);
|
||||
hOnZClassChanged = CreateGlobalForward("ZR_OnZClassChanged", ET_Ignore, Param_Cell, Param_Cell, Param_Cell);
|
||||
}
|
||||
|
||||
public Native_IsClientZombie(Handle:plugin, argc)
|
||||
{
|
||||
return gZombie[GetNativeCell(1)];
|
||||
}
|
||||
|
||||
public Native_GetClientZClass(Handle:plugin, argc)
|
||||
{
|
||||
new class = GetNativeCell(1);
|
||||
return pClass[class];
|
||||
}
|
||||
|
||||
public Native_HasZombieSpawned(Handle:plugin, argc)
|
||||
{
|
||||
return zombieSpawned;
|
||||
}
|
175
src/zr/menu.inc
Normal file
175
src/zr/menu.inc
Normal file
@ -0,0 +1,175 @@
|
||||
/**
|
||||
* ====================
|
||||
* Zombie:Reloaded
|
||||
* File: menu.sp
|
||||
* Author: Greyscale
|
||||
* ====================
|
||||
*/
|
||||
|
||||
MainMenu(client)
|
||||
{
|
||||
new Handle:menu_main = CreateMenu(MainMenuHandle);
|
||||
|
||||
SetGlobalTransTarget(client);
|
||||
|
||||
SetMenuTitle(menu_main, "%t\n ", "!zmenu title");
|
||||
|
||||
decl String:zmenu[128];
|
||||
decl String:zclass[128];
|
||||
decl String:zmarket[128];
|
||||
decl String:zspawn[128];
|
||||
decl String:ztele[128];
|
||||
decl String:zstuck[128];
|
||||
decl String:zhp[128];
|
||||
|
||||
Format(zmenu, sizeof(zmenu), "%t", "!zmenu menu");
|
||||
Format(zclass, sizeof(zclass), "%t", "!zmenu class");
|
||||
Format(zmarket, sizeof(zmarket), "%t", "!zmenu market");
|
||||
Format(zspawn, sizeof(zspawn), "%t", "!zmenu spawn");
|
||||
Format(ztele, sizeof(ztele), "%t", "!zmenu tele");
|
||||
Format(zstuck, sizeof(zstuck), "%t", "!zmenu stuck");
|
||||
Format(zhp, sizeof(zhp), "%t (%d HP)", "!zmenu hp", GetClientHealth(client));
|
||||
|
||||
AddMenuItem(menu_main, "zmenu", zmenu, ITEMDRAW_DISABLED);
|
||||
AddMenuItem(menu_main, "zclass", zclass);
|
||||
|
||||
if (market)
|
||||
{
|
||||
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, "zstuck", zstuck);
|
||||
AddMenuItem(menu_main, "zhp", zhp);
|
||||
|
||||
DisplayMenu(menu_main, client, MENU_TIME_FOREVER);
|
||||
}
|
||||
|
||||
public MainMenuHandle(Handle:menu_main, MenuAction:action, client, slot)
|
||||
{
|
||||
if (action == MenuAction_Select)
|
||||
{
|
||||
switch(slot)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
if (!ZClass(client))
|
||||
{
|
||||
MainMenu(client);
|
||||
}
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
if (!ZMarket(client))
|
||||
{
|
||||
MainMenu(client);
|
||||
}
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
ZSpawn(client);
|
||||
MainMenu(client);
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
ZTele(client);
|
||||
MainMenu(client);
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
ZStuck(client);
|
||||
MainMenu(client);
|
||||
}
|
||||
case 6:
|
||||
{
|
||||
ZHP(client);
|
||||
MainMenu(client);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (action == MenuAction_End)
|
||||
{
|
||||
CloseHandle(menu_main);
|
||||
}
|
||||
}
|
||||
|
||||
ClassMenu(client)
|
||||
{
|
||||
new Handle:menu_classes = CreateMenu(ClassMenuHandle);
|
||||
|
||||
decl String:menu_description[256];
|
||||
decl String:display[288]; // 32 + 256
|
||||
|
||||
SetGlobalTransTarget(client);
|
||||
|
||||
SetMenuTitle(menu_classes, "%t\n ", "!zclass title");
|
||||
|
||||
for (new x = 0; x < classCount; x++)
|
||||
{
|
||||
GetClassName(x, display, sizeof(display));
|
||||
GetClassMenuDescription(x, menu_description, sizeof(menu_description));
|
||||
|
||||
if (pNextClass[client] == -1)
|
||||
{
|
||||
if (x == pClass[client])
|
||||
{
|
||||
Format(display, sizeof(display), "%s (current)", display);
|
||||
}
|
||||
}
|
||||
else if (x == pNextClass[client])
|
||||
{
|
||||
Format(display, sizeof(display), "%s (current)", display);
|
||||
}
|
||||
|
||||
Format(display, sizeof(display), "%s\n %s", display, menu_description);
|
||||
|
||||
AddMenuItem(menu_classes, "", display);
|
||||
}
|
||||
|
||||
SetMenuExitBackButton(menu_classes, true);
|
||||
|
||||
DisplayMenu(menu_classes, client, MENU_TIME_FOREVER);
|
||||
}
|
||||
|
||||
public ClassMenuHandle(Handle:menu_classes, MenuAction:action, client, slot)
|
||||
{
|
||||
if (action == MenuAction_Select)
|
||||
{
|
||||
if (IsPlayerHuman(client) || !IsPlayerAlive(client))
|
||||
{
|
||||
Call_StartForward(hOnZClassChanged);
|
||||
Call_PushCell(client);
|
||||
Call_PushCell(pClass[client]);
|
||||
Call_PushCell(slot);
|
||||
Call_Finish();
|
||||
|
||||
pClass[client] = slot;
|
||||
}
|
||||
else
|
||||
{
|
||||
pNextClass[client] = slot;
|
||||
}
|
||||
|
||||
decl String:name[64];
|
||||
GetClassName(slot, name, sizeof(name));
|
||||
|
||||
ZR_PrintToChat(client, "Class select", name);
|
||||
}
|
||||
|
||||
if (action == MenuAction_Cancel)
|
||||
{
|
||||
if (slot == MenuCancel_ExitBack)
|
||||
{
|
||||
MainMenu(client);
|
||||
}
|
||||
}
|
||||
else if (action == MenuAction_End)
|
||||
{
|
||||
CloseHandle(menu_classes);
|
||||
}
|
||||
}
|
139
src/zr/models.inc
Normal file
139
src/zr/models.inc
Normal file
@ -0,0 +1,139 @@
|
||||
/**
|
||||
* ====================
|
||||
* Zombie:Reloaded
|
||||
* File: models.inc
|
||||
* Author: Greyscale
|
||||
* ====================
|
||||
*/
|
||||
|
||||
new String:modelSuffix[8][16] = {".dx80.vtx", ".dx90.vtx", ".mdl", ".phy", ".sw.vtx", ".vvd", ".xbox", ".xbox.vtx"};
|
||||
|
||||
new Handle:arrayModels = INVALID_HANDLE;
|
||||
|
||||
FileLinesToArray(Handle:array, const Handle:file)
|
||||
{
|
||||
ClearArray(array);
|
||||
|
||||
decl String:line[128];
|
||||
|
||||
while(!IsEndOfFile(file) && ReadFileLine(file, line, sizeof(line)))
|
||||
{
|
||||
if (StrContains(line, ";") == -1)
|
||||
{
|
||||
if (StrContains(line, "//") > -1)
|
||||
{
|
||||
SplitString(line, "//", line, sizeof(line));
|
||||
}
|
||||
TrimString(line);
|
||||
|
||||
if (!StrEqual(line, "", false))
|
||||
{
|
||||
PushArrayString(array, line);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LoadModelData()
|
||||
{
|
||||
decl String:path[PLATFORM_MAX_PATH];
|
||||
BuildPath(Path_SM, path, sizeof(path), "configs/zr/models.txt");
|
||||
|
||||
if (arrayModels != INVALID_HANDLE)
|
||||
{
|
||||
CloseHandle(arrayModels);
|
||||
}
|
||||
|
||||
arrayModels = CreateArray(256, 0);
|
||||
|
||||
new Handle:fileModels = OpenFile(path, "r");
|
||||
if (fileModels == INVALID_HANDLE)
|
||||
{
|
||||
SetFailState("\"%s\" missing from server", path);
|
||||
}
|
||||
|
||||
FileLinesToArray(arrayModels, fileModels);
|
||||
|
||||
if (!GetArraySize(arrayModels))
|
||||
{
|
||||
SetFailState("No models listed in models.txt, please add some models then restart");
|
||||
}
|
||||
|
||||
decl String:model[256];
|
||||
decl String:modelpath[256];
|
||||
|
||||
new modelsize = GetArraySize(arrayModels);
|
||||
for (new x = 0; x < modelsize; x++)
|
||||
{
|
||||
for (new y = 0; y < 8; y++)
|
||||
{
|
||||
GetArrayString(arrayModels, x, model, sizeof(model));
|
||||
Format(modelpath, sizeof(modelpath), "%s%s", model, modelSuffix[y]);
|
||||
if (FileExists(modelpath))
|
||||
{
|
||||
AddFileToDownloadsTable(modelpath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CloseHandle(fileModels);
|
||||
}
|
||||
|
||||
LoadDownloadData()
|
||||
{
|
||||
decl String:path[PLATFORM_MAX_PATH];
|
||||
BuildPath(Path_SM, path, sizeof(path), "configs/zr/downloads.txt");
|
||||
|
||||
new Handle:fileDownloads = OpenFile(path, "r");
|
||||
|
||||
if (fileDownloads == INVALID_HANDLE)
|
||||
{
|
||||
SetFailState("\"%s\" missing from server", path);
|
||||
}
|
||||
|
||||
new Handle:arrayDownloads = CreateArray(256, 0);
|
||||
|
||||
FileLinesToArray(arrayDownloads, fileDownloads);
|
||||
|
||||
decl String:file[256];
|
||||
|
||||
new downloadsize = GetArraySize(arrayDownloads);
|
||||
for (new x = 0; x < downloadsize; x++)
|
||||
{
|
||||
GetArrayString(arrayDownloads, x, file, sizeof(file));
|
||||
if (FileExists(file))
|
||||
{
|
||||
AddFileToDownloadsTable(file);
|
||||
}
|
||||
else
|
||||
{
|
||||
ZR_LogMessage("File load failed", file);
|
||||
}
|
||||
}
|
||||
|
||||
CloseHandle(fileDownloads);
|
||||
CloseHandle(arrayDownloads);
|
||||
}
|
||||
|
||||
ApplyZombieModel(client)
|
||||
{
|
||||
decl String:modelpath[256];
|
||||
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
{
|
||||
GetClassModel(pClass[client], modelpath, sizeof(modelpath));
|
||||
if (!StrEqual(modelpath, "default", false))
|
||||
{
|
||||
SetPlayerModel(client, modelpath);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
new randmodel = GetRandomInt(0, GetArraySize(arrayModels) - 1);
|
||||
GetArrayString(arrayModels, randmodel, modelpath, sizeof(modelpath));
|
||||
Format(modelpath, sizeof(modelpath), "%s.mdl", modelpath);
|
||||
|
||||
SetPlayerModel(client, modelpath);
|
||||
}
|
||||
|
190
src/zr/offsets.inc
Normal file
190
src/zr/offsets.inc
Normal file
@ -0,0 +1,190 @@
|
||||
/**
|
||||
* ====================
|
||||
* Zombie:Reloaded
|
||||
* File: offsets.inc
|
||||
* Author: Greyscale
|
||||
* ====================
|
||||
*/
|
||||
|
||||
new offsBaseVelocity;
|
||||
new offsGetVelocity0;
|
||||
new offsGetVelocity1;
|
||||
new offsGetVelocity2;
|
||||
new offsSpeed;
|
||||
new offsNVG;
|
||||
new offsNVGOn;
|
||||
new offsCollision;
|
||||
new offsMoney;
|
||||
new offsFOV;
|
||||
new offsBuyZone;
|
||||
|
||||
new Handle:hGameConf = INVALID_HANDLE;
|
||||
new Handle:hRemoveAllItems = INVALID_HANDLE;
|
||||
new Handle:hTerminateRound = INVALID_HANDLE;
|
||||
|
||||
FindOffsets()
|
||||
{
|
||||
offsBaseVelocity = FindSendPropInfo("CBasePlayer", "m_vecBaseVelocity");
|
||||
if (offsBaseVelocity == -1)
|
||||
{
|
||||
SetFailState("Couldn't find \"m_vecBaseVelocity\"!");
|
||||
}
|
||||
|
||||
offsGetVelocity0 = FindSendPropInfo("CBasePlayer", "m_vecVelocity[0]");
|
||||
if (offsGetVelocity0 == -1)
|
||||
{
|
||||
SetFailState("Couldn't find \"m_vecVelocity[0]\"!");
|
||||
}
|
||||
|
||||
offsGetVelocity1 = FindSendPropInfo("CBasePlayer", "m_vecVelocity[1]");
|
||||
if (offsGetVelocity1 == -1)
|
||||
{
|
||||
SetFailState("Couldn't find \"m_vecVelocity[1]\"!");
|
||||
}
|
||||
|
||||
offsGetVelocity2 = FindSendPropInfo("CBasePlayer", "m_vecVelocity[2]");
|
||||
if (offsGetVelocity2 == -1)
|
||||
{
|
||||
SetFailState("Couldn't find \"m_vecVelocity[2]\"!");
|
||||
}
|
||||
|
||||
offsSpeed = FindSendPropInfo("CCSPlayer", "m_flLaggedMovementValue");
|
||||
if (offsSpeed == -1)
|
||||
{
|
||||
SetFailState("Couldn't find \"m_flLaggedMovementValue\"!");
|
||||
}
|
||||
|
||||
offsNVG = FindSendPropInfo("CCSPlayer", "m_bHasNightVision");
|
||||
if (offsNVG == -1)
|
||||
{
|
||||
SetFailState("Couldn't find \"m_bHasNightVision\"!");
|
||||
}
|
||||
|
||||
offsNVGOn = FindSendPropInfo("CCSPlayer", "m_bNightVisionOn");
|
||||
if (offsNVGOn == -1)
|
||||
{
|
||||
SetFailState("Couldn't find \"m_bNightVisionOn\"!");
|
||||
}
|
||||
|
||||
offsCollision = FindSendPropInfo("CBaseEntity", "m_CollisionGroup");
|
||||
if (offsCollision == -1)
|
||||
{
|
||||
SetFailState("Couldn't find \"m_CollisionGroup\"!");
|
||||
}
|
||||
|
||||
offsMoney = FindSendPropInfo("CCSPlayer", "m_iAccount");
|
||||
if (offsMoney == -1)
|
||||
{
|
||||
SetFailState("Couldn't find \"m_iAccount\"!");
|
||||
}
|
||||
|
||||
offsFOV = FindSendPropInfo("CBasePlayer", "m_iDefaultFOV");
|
||||
if (offsFOV == -1)
|
||||
{
|
||||
SetFailState("Couldn't find \"m_iDefaultFOV\"!");
|
||||
}
|
||||
|
||||
offsBuyZone = FindSendPropInfo("CCSPlayer", "m_bInBuyZone");
|
||||
if (offsBuyZone == -1)
|
||||
{
|
||||
SetFailState("Couldn't find \"m_bInBuyZone\"!");
|
||||
}
|
||||
}
|
||||
|
||||
SetupGameData()
|
||||
{
|
||||
hGameConf = LoadGameConfigFile("plugin.zombiereloaded");
|
||||
|
||||
StartPrepSDKCall(SDKCall_Player);
|
||||
PrepSDKCall_SetFromConf(hGameConf, SDKConf_Virtual, "RemoveAllItems");
|
||||
hRemoveAllItems = EndPrepSDKCall();
|
||||
|
||||
StartPrepSDKCall(SDKCall_GameRules);
|
||||
PrepSDKCall_SetFromConf(hGameConf, SDKConf_Signature, "TerminateRound");
|
||||
PrepSDKCall_AddParameter(SDKType_Float, SDKPass_Plain);
|
||||
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
|
||||
hTerminateRound = EndPrepSDKCall();
|
||||
}
|
||||
|
||||
SetPlayerVelocity(client, const Float:vec[3])
|
||||
{
|
||||
SetEntDataVector(client, offsBaseVelocity, vec, true);
|
||||
}
|
||||
|
||||
GetPlayerVelocity(client, Float:vel[3])
|
||||
{
|
||||
vel[0] = GetEntDataFloat(client, offsGetVelocity0);
|
||||
vel[1] = GetEntDataFloat(client, offsGetVelocity1);
|
||||
vel[2] = GetEntDataFloat(client, offsGetVelocity2);
|
||||
}
|
||||
|
||||
SetPlayerSpeed(client, Float:speed)
|
||||
{
|
||||
new Float:newspeed = speed / 300.0;
|
||||
SetEntDataFloat(client, offsSpeed, newspeed, true);
|
||||
}
|
||||
|
||||
NightVision(client, bool:enable)
|
||||
{
|
||||
SetEntData(client, offsNVG, enable, 1, true);
|
||||
}
|
||||
|
||||
NightVisionOn(client, bool:enable)
|
||||
{
|
||||
SetEntData(client, offsNVGOn, enable, 1, true);
|
||||
}
|
||||
|
||||
NoCollide(client, bool:nocollide)
|
||||
{
|
||||
if (nocollide)
|
||||
{
|
||||
SetEntData(client, offsCollision, 2, 1, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetEntData(client, offsCollision, 5, 1, true);
|
||||
}
|
||||
}
|
||||
|
||||
SetPlayerMoney(client, amount)
|
||||
{
|
||||
SetEntData(client, offsMoney, amount, 4, true);
|
||||
}
|
||||
|
||||
SetPlayerFOV(client, fov)
|
||||
{
|
||||
SetEntData(client, offsFOV, fov, 1, true);
|
||||
}
|
||||
|
||||
bool:IsClientInBuyZone(client)
|
||||
{
|
||||
return bool:GetEntData(client, offsBuyZone);
|
||||
}
|
||||
|
||||
AddPlayerScore(client, amount)
|
||||
{
|
||||
new frags = GetEntProp(client, Prop_Data, "m_iFrags");
|
||||
SetEntProp(client, Prop_Data, "m_iFrags", frags + amount);
|
||||
}
|
||||
|
||||
AddPlayerDeath(client, amount)
|
||||
{
|
||||
new deaths = GetEntProp(client, Prop_Data, "m_iDeaths");
|
||||
SetEntProp(client, Prop_Data, "m_iDeaths", deaths + amount);
|
||||
}
|
||||
|
||||
RemoveAllPlayersWeapons(client)
|
||||
{
|
||||
SDKCall(hRemoveAllItems, client);
|
||||
}
|
||||
|
||||
TerminateRound(Float:delay, reason)
|
||||
{
|
||||
SDKCall(hTerminateRound, delay, reason);
|
||||
}
|
||||
|
||||
SetPlayerModel(client, const String:model[])
|
||||
{
|
||||
PrecacheModel(model);
|
||||
SetEntityModel(client, model);
|
||||
}
|
47
src/zr/overlays.inc
Normal file
47
src/zr/overlays.inc
Normal file
@ -0,0 +1,47 @@
|
||||
/**
|
||||
* ====================
|
||||
* Zombie:Reloaded
|
||||
* File: overlays.inc
|
||||
* Author: Greyscale
|
||||
* ====================
|
||||
*/
|
||||
|
||||
ShowOverlays(Float:time, ZTeam:winner)
|
||||
{
|
||||
new bool:overlays = GetConVarBool(gCvars[CVAR_OVERLAYS]);
|
||||
if (overlays)
|
||||
{
|
||||
decl String:overlay[64];
|
||||
if (winner == Human)
|
||||
{
|
||||
GetConVarString(gCvars[CVAR_OVERLAYS_HUMAN], overlay, sizeof(overlay));
|
||||
}
|
||||
else if (winner == Zombie)
|
||||
{
|
||||
GetConVarString(gCvars[CVAR_OVERLAYS_ZOMBIE], overlay, sizeof(overlay));
|
||||
}
|
||||
|
||||
new maxplayers = GetMaxClients();
|
||||
for (new x = 1; x <= maxplayers; x++)
|
||||
{
|
||||
if (IsClientInGame(x))
|
||||
{
|
||||
DisplayClientOverlay(x, overlay);
|
||||
}
|
||||
}
|
||||
|
||||
CreateTimer(time, KillOverlays);
|
||||
}
|
||||
}
|
||||
|
||||
public Action:KillOverlays(Handle:timer)
|
||||
{
|
||||
new maxplayers = GetMaxClients();
|
||||
for (new x = 1; x <= maxplayers; x++)
|
||||
{
|
||||
if (IsClientInGame(x))
|
||||
{
|
||||
ClientCommand(x, "r_screenoverlay \"\"");
|
||||
}
|
||||
}
|
||||
}
|
346
src/zr/sayhooks.inc
Normal file
346
src/zr/sayhooks.inc
Normal file
@ -0,0 +1,346 @@
|
||||
/**
|
||||
* ====================
|
||||
* Zombie:Reloaded
|
||||
* File: sayhooks.inc
|
||||
* Author: Greyscale
|
||||
* ====================
|
||||
*/
|
||||
|
||||
HookChatCmds()
|
||||
{
|
||||
RegConsoleCmd("say", SayCommand);
|
||||
RegConsoleCmd("say_team", SayCommand);
|
||||
}
|
||||
|
||||
public Action:SayCommand(client, argc)
|
||||
{
|
||||
new bool:enabled = GetConVarBool(gCvars[CVAR_ENABLE]);
|
||||
if (!client || !enabled)
|
||||
{
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
decl String:args[192];
|
||||
|
||||
GetCmdArgString(args, sizeof(args));
|
||||
ReplaceString(args, sizeof(args), "\"", "");
|
||||
|
||||
if (StrEqual(args, "!zmenu", false))
|
||||
{
|
||||
MainMenu(client);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
else if (StrEqual(args, "!zclass", false))
|
||||
{
|
||||
ZClass(client);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
else if (StrEqual(args, "!zmarket", false))
|
||||
{
|
||||
ZMarket(client);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
else if (StrEqual(args, "!zspawn", false))
|
||||
{
|
||||
ZSpawn(client);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
else if (StrEqual(args, "!ztele", false))
|
||||
{
|
||||
ZTele(client);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
else if (StrEqual(args, "!zstuck", false))
|
||||
{
|
||||
ZStuck(client);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
else if (StrEqual(args, "!zhp", false))
|
||||
{
|
||||
ZHP(client);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
bool:ZClass(client)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (!classes)
|
||||
{
|
||||
ZR_PrintToChat(client, "Feature is disabled");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
new bool:randomclass = GetConVarBool(gCvars[CVAR_CLASSES_RANDOM]);
|
||||
if (randomclass)
|
||||
{
|
||||
ZR_PrintToChat(client, "Random class is enabled");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
ClassMenu(client);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool:ZMarket(client)
|
||||
{
|
||||
if (!market)
|
||||
{
|
||||
ZR_PrintToChat(client, "Feature is disabled");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!IsPlayerAlive(client))
|
||||
{
|
||||
ZR_PrintToChat(client, "Must be alive");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
new bool:buyzone = GetConVarBool(gCvars[CVAR_ZMARKET_BUYZONE]);
|
||||
if (!IsClientInBuyZone(client) && buyzone)
|
||||
{
|
||||
ZR_PrintCenterText(client, "Market out of buyzone");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
SetGlobalTransTarget(client);
|
||||
|
||||
decl String:title[64];
|
||||
decl String:rebuy[64];
|
||||
|
||||
Format(title, sizeof(title), "%t\n ", "Market title");
|
||||
Format(rebuy, sizeof(rebuy), "%t\n ", "Market rebuy");
|
||||
|
||||
Market_Send(client, title, rebuy);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool:Market_OnWeaponSelected(client, String:weaponid[])
|
||||
{
|
||||
if (!weaponid[0] || !IsPlayerAlive(client))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IsPlayerZombie(client))
|
||||
{
|
||||
ZR_PrintToChat(client, "Zombie cant use weapon");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (StrEqual(weaponid, "rebuy"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
decl String:display[64];
|
||||
decl String:weapon[32];
|
||||
new price;
|
||||
|
||||
if (!Market_GetWeaponIDInfo(weaponid, display, weapon, price))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ReplaceString(weapon, sizeof(weapon), "weapon_", "");
|
||||
|
||||
if (IsWeaponRestricted(weapon))
|
||||
{
|
||||
ZR_PrintToChat(client, "Weapon is restricted", weapon);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
new bool:buyzone = GetConVarBool(gCvars[CVAR_ZMARKET_BUYZONE]);
|
||||
if (!IsClientInBuyZone(client) && buyzone)
|
||||
{
|
||||
ZR_PrintCenterText(client, "Market out of buyzone");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Market_PostOnWeaponSelected(client, &bool:allowed)
|
||||
{
|
||||
if (!allowed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ZMarket(client);
|
||||
}
|
||||
|
||||
ZSpawn(client)
|
||||
{
|
||||
new bool:spawn = GetConVarBool(gCvars[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) || IsPlayerInList(client))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RespawnPlayer(client);
|
||||
|
||||
AddPlayerToList(client);
|
||||
}
|
||||
|
||||
ZTele(client)
|
||||
{
|
||||
new bool:tele = GetConVarBool(gCvars[CVAR_ZTELE]);
|
||||
if (!tele)
|
||||
{
|
||||
ZR_PrintToChat(client, "Feature is disabled");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsPlayerZombie(client) && zombieSpawned)
|
||||
{
|
||||
ZR_PrintToChat(client, "!ztele humans restricted");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsPlayerAlive(client) || tHandles[client][TTELE] != INVALID_HANDLE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
new count = teleCount[client];
|
||||
new limit = GetConVarInt(gCvars[CVAR_ZTELE_LIMIT]);
|
||||
|
||||
if (limit > 0)
|
||||
{
|
||||
if (count < limit)
|
||||
{
|
||||
tHandles[client][TTELE] = CreateTimer(3.0, Teleport, client, TIMER_FLAG_NO_MAPCHANGE);
|
||||
teleCount[client]++;
|
||||
ZR_PrintToChat(client, "!ztele amount", limit - teleCount[client]);
|
||||
}
|
||||
else
|
||||
{
|
||||
ZR_PrintToChat(client, "!ztele limit reached");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tHandles[client][TTELE] = CreateTimer(3.0, Teleport, client, TIMER_FLAG_NO_MAPCHANGE);
|
||||
ZR_PrintToChat(client, "!ztele amount unlimited");
|
||||
}
|
||||
}
|
||||
|
||||
public Action:Teleport(Handle:timer, any:index)
|
||||
{
|
||||
TeleportEntity(index, spawnLoc[index], NULL_VECTOR, NULL_VECTOR);
|
||||
|
||||
tHandles[index][TTELE] = INVALID_HANDLE;
|
||||
}
|
||||
|
||||
ZStuck(client)
|
||||
{
|
||||
new bool:stuck = GetConVarBool(gCvars[CVAR_ZTELE]);
|
||||
if (!stuck)
|
||||
{
|
||||
ZR_PrintToChat(client, "Feature is disabled");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsPlayerAlive(client))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
new Float:clientloc[3];
|
||||
new Float:stuckloc[3];
|
||||
|
||||
GetClientAbsOrigin(client, clientloc);
|
||||
new maxplayers = GetMaxClients();
|
||||
for (new x = 1; x <= maxplayers; x++)
|
||||
{
|
||||
if (!IsClientInGame(x) || !IsPlayerAlive(x))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
GetClientAbsOrigin(x, stuckloc);
|
||||
if (GetVectorDistance(clientloc, stuckloc) <= 60)
|
||||
{
|
||||
NoCollide(x, true);
|
||||
CreateTimer(0.5, CollisionOn, x, TIMER_FLAG_NO_MAPCHANGE);
|
||||
}
|
||||
}
|
||||
|
||||
new Float:x = GetRandomFloat(-150.0, 150.0);
|
||||
new Float:y = GetRandomFloat(-150.0, 150.0);
|
||||
|
||||
new Float:nudge[3];
|
||||
|
||||
nudge[0] = x;
|
||||
nudge[1] = y;
|
||||
|
||||
SetPlayerVelocity(client, nudge);
|
||||
}
|
||||
|
||||
public Action:CollisionOn(Handle:timer, any:index)
|
||||
{
|
||||
if (!IsClientInGame(index))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
NoCollide(index, false);
|
||||
}
|
||||
|
||||
ZHP(client)
|
||||
{
|
||||
new bool:zhp = GetConVarBool(gCvars[CVAR_ZHP]);
|
||||
if (!zhp)
|
||||
{
|
||||
ZR_PrintToChat(client, "Feature is disabled");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (dispHP[client])
|
||||
{
|
||||
ZR_PrintToChat(client, "!zhp disabled");
|
||||
}
|
||||
else
|
||||
{
|
||||
ZR_PrintToChat(client, "!zhp enabled");
|
||||
UpdateHPDisplay(client);
|
||||
}
|
||||
|
||||
dispHP[client] = !dispHP[client];
|
||||
}
|
118
src/zr/translation.inc
Normal file
118
src/zr/translation.inc
Normal file
@ -0,0 +1,118 @@
|
||||
/**
|
||||
* ====================
|
||||
* Zombie:Reloaded
|
||||
* File: translations.inc
|
||||
* Author: Greyscale
|
||||
* ====================
|
||||
*/
|
||||
|
||||
FormatTextString(String:text[], maxlen)
|
||||
{
|
||||
Format(text, maxlen, "@green[%t] @default%s", "ZR", text);
|
||||
|
||||
ReplaceString(text, maxlen, "@default","\x01");
|
||||
ReplaceString(text, maxlen, "@lgreen","\x03");
|
||||
ReplaceString(text, maxlen, "@green","\x04");
|
||||
}
|
||||
|
||||
stock ZR_PrintToChat(client, any:...)
|
||||
{
|
||||
decl String:phrase[192];
|
||||
|
||||
if (client)
|
||||
{
|
||||
SetGlobalTransTarget(client);
|
||||
|
||||
VFormat(phrase, sizeof(phrase), "%t", 2);
|
||||
FormatTextString(phrase, sizeof(phrase));
|
||||
|
||||
PrintToChat(client, phrase);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetGlobalTransTarget(client);
|
||||
|
||||
VFormat(phrase, sizeof(phrase), "%t", 2);
|
||||
FormatTextString(phrase, sizeof(phrase));
|
||||
|
||||
PrintToServer(phrase);
|
||||
|
||||
new maxplayers = GetMaxClients();
|
||||
for (new x = 1; x <= maxplayers; x++)
|
||||
{
|
||||
if (IsClientInGame(x))
|
||||
{
|
||||
SetGlobalTransTarget(x);
|
||||
|
||||
VFormat(phrase, sizeof(phrase), "%t", 2);
|
||||
FormatTextString(phrase, sizeof(phrase));
|
||||
|
||||
PrintToChat(x, phrase);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stock ZR_PrintCenterText(client, any:...)
|
||||
{
|
||||
SetGlobalTransTarget(client);
|
||||
|
||||
decl String:phrase[192];
|
||||
|
||||
VFormat(phrase, sizeof(phrase), "%t", 2);
|
||||
|
||||
PrintCenterText(client, phrase);
|
||||
}
|
||||
|
||||
stock ZR_HudHint(client, any:...)
|
||||
{
|
||||
SetGlobalTransTarget(client);
|
||||
|
||||
decl String:phrase[192];
|
||||
|
||||
VFormat(phrase, sizeof(phrase), "%t", 2);
|
||||
|
||||
new Handle:hHintText = StartMessageOne("HintText", client);
|
||||
if (hHintText != INVALID_HANDLE)
|
||||
{
|
||||
BfWriteByte(hHintText, -1);
|
||||
BfWriteString(hHintText, phrase);
|
||||
EndMessage();
|
||||
}
|
||||
}
|
||||
|
||||
stock ZR_PrintToServer(any:...)
|
||||
{
|
||||
SetGlobalTransTarget(LANG_SERVER);
|
||||
|
||||
decl String:phrase[192];
|
||||
decl String:buffer[192];
|
||||
|
||||
VFormat(phrase, sizeof(phrase), "%t", 1);
|
||||
Format(buffer, sizeof(buffer), "[%t] %s", "ZR", phrase);
|
||||
|
||||
PrintToServer(buffer);
|
||||
}
|
||||
|
||||
stock ZR_LogMessage(any:...)
|
||||
{
|
||||
SetGlobalTransTarget(LANG_SERVER);
|
||||
|
||||
decl String:phrase[192];
|
||||
|
||||
VFormat(phrase, sizeof(phrase), "%t", 1);
|
||||
|
||||
LogMessage(phrase);
|
||||
}
|
||||
|
||||
stock ZR_ReplyToCommand(client, any:...)
|
||||
{
|
||||
decl String:phrase[192];
|
||||
|
||||
SetGlobalTransTarget(client);
|
||||
|
||||
VFormat(phrase, sizeof(phrase), "%t", 2);
|
||||
FormatTextString(phrase, sizeof(phrase));
|
||||
|
||||
ReplyToCommand(client, phrase);
|
||||
}
|
261
src/zr/weaponrestrict.inc
Normal file
261
src/zr/weaponrestrict.inc
Normal file
@ -0,0 +1,261 @@
|
||||
/**
|
||||
* ====================
|
||||
* Zombie:Reloaded
|
||||
* File: weaponrestrict.inc
|
||||
* Author: Greyscale
|
||||
* ====================
|
||||
*/
|
||||
|
||||
new Handle:restrictedWeapons = INVALID_HANDLE;
|
||||
|
||||
new gRestrict[MAXPLAYERS+1];
|
||||
|
||||
enum WepRestrictQuery
|
||||
{
|
||||
Successful, /** Weapon (un)restrict query was successful */
|
||||
Invalid, /** Weapon invalid */
|
||||
Existing, /** Already restricted */
|
||||
}
|
||||
|
||||
InitWeaponRestrict()
|
||||
{
|
||||
RegConsoleCmd("buy", BuyHook);
|
||||
|
||||
restrictedWeapons = CreateArray(32, 0);
|
||||
}
|
||||
|
||||
ClientHookUse(client)
|
||||
{
|
||||
gRestrict[client] = Hacks_Hook(client, HACKS_HTYPE_WEAPON_CANUSE, Weapon_CanUse, false);
|
||||
}
|
||||
|
||||
ClientUnHookUse(client)
|
||||
{
|
||||
Hacks_Unhook(gRestrict[client]);
|
||||
}
|
||||
|
||||
public Action:BuyHook(client, argc)
|
||||
{
|
||||
new bool:enabled = GetConVarBool(gCvars[CVAR_ENABLE]);
|
||||
if (!enabled)
|
||||
{
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
if (IsPlayerHuman(client))
|
||||
{
|
||||
decl String:weapon[64];
|
||||
GetCmdArg(1, weapon, sizeof(weapon));
|
||||
|
||||
ReplaceString(weapon, sizeof(weapon), "weapon_", "");
|
||||
|
||||
if (IsWeaponRestricted(weapon))
|
||||
{
|
||||
ZR_PrintToChat(client, "Weapon is restricted", weapon);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ZR_PrintToChat(client, "Zombie cant use weapon");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
WepRestrictQuery:RestrictWeapon(const String:weapon[])
|
||||
{
|
||||
if (IsWeaponGroup(weapon))
|
||||
{
|
||||
RestrictWeaponGroup(weapon);
|
||||
|
||||
ZR_PrintToChat(0, "Weapon group has been restricted", weapon);
|
||||
|
||||
return Successful;
|
||||
}
|
||||
|
||||
if (!IsWeaponRestricted(weapon))
|
||||
{
|
||||
PushArrayString(restrictedWeapons, weapon);
|
||||
|
||||
ZR_PrintToChat(0, "Weapon has been restricted", weapon);
|
||||
|
||||
return Successful;
|
||||
}
|
||||
|
||||
return Existing;
|
||||
}
|
||||
|
||||
RestrictWeaponGroup(const String:group[])
|
||||
{
|
||||
if (StrEqual(group, "pistols", false))
|
||||
{
|
||||
PushArrayString(restrictedWeapons, "glock");
|
||||
PushArrayString(restrictedWeapons, "usp");
|
||||
PushArrayString(restrictedWeapons, "p228");
|
||||
PushArrayString(restrictedWeapons, "deagle");
|
||||
PushArrayString(restrictedWeapons, "elite");
|
||||
PushArrayString(restrictedWeapons, "fiveseven");
|
||||
}
|
||||
else if (StrEqual(group, "shotguns", false))
|
||||
{
|
||||
PushArrayString(restrictedWeapons, "m3");
|
||||
PushArrayString(restrictedWeapons, "xm1014");
|
||||
}
|
||||
else if (StrEqual(group, "smgs", false))
|
||||
{
|
||||
PushArrayString(restrictedWeapons, "tmp");
|
||||
PushArrayString(restrictedWeapons, "mac10");
|
||||
PushArrayString(restrictedWeapons, "mp5navy");
|
||||
PushArrayString(restrictedWeapons, "ump45");
|
||||
PushArrayString(restrictedWeapons, "p90");
|
||||
}
|
||||
else if (StrEqual(group, "rifles", false))
|
||||
{
|
||||
PushArrayString(restrictedWeapons, "galil");
|
||||
PushArrayString(restrictedWeapons, "famas");
|
||||
PushArrayString(restrictedWeapons, "ak47");
|
||||
PushArrayString(restrictedWeapons, "m4a1");
|
||||
PushArrayString(restrictedWeapons, "sg552");
|
||||
PushArrayString(restrictedWeapons, "bullpup");
|
||||
}
|
||||
else if (StrEqual(group, "snipers", false))
|
||||
{
|
||||
PushArrayString(restrictedWeapons, "scout");
|
||||
PushArrayString(restrictedWeapons, "sg550");
|
||||
PushArrayString(restrictedWeapons, "g3sg1");
|
||||
PushArrayString(restrictedWeapons, "awp");
|
||||
}
|
||||
}
|
||||
|
||||
WepRestrictQuery:UnRestrictWeapon(const String:weapon[])
|
||||
{
|
||||
if (IsWeaponGroup(weapon))
|
||||
{
|
||||
UnRestrictWeaponGroup(weapon);
|
||||
|
||||
ZR_PrintToChat(0, "Weapon group has been unrestricted", weapon);
|
||||
|
||||
return Successful;
|
||||
}
|
||||
|
||||
new index = GetRestrictedWeaponIndex(weapon);
|
||||
|
||||
if (index > -1)
|
||||
{
|
||||
RemoveFromArray(restrictedWeapons, index);
|
||||
|
||||
ZR_PrintToChat(0, "Weapon has been unrestricted", weapon);
|
||||
|
||||
return Successful;
|
||||
}
|
||||
|
||||
return Invalid;
|
||||
}
|
||||
|
||||
UnRestrictWeaponGroup(const String:group[])
|
||||
{
|
||||
if (StrEqual(group, "pistols", false))
|
||||
{
|
||||
UnRestrictWeapon("glock");
|
||||
UnRestrictWeapon("usp");
|
||||
UnRestrictWeapon("p228");
|
||||
UnRestrictWeapon("deagle");
|
||||
UnRestrictWeapon("elite");
|
||||
UnRestrictWeapon("fiveseven");
|
||||
}
|
||||
else if (StrEqual(group, "shotguns", false))
|
||||
{
|
||||
UnRestrictWeapon("m3");
|
||||
UnRestrictWeapon("xm1014");
|
||||
}
|
||||
else if (StrEqual(group, "smgs", false))
|
||||
{
|
||||
UnRestrictWeapon("tmp");
|
||||
UnRestrictWeapon("mac10");
|
||||
UnRestrictWeapon("mp5navy");
|
||||
UnRestrictWeapon("ump45");
|
||||
UnRestrictWeapon("p90");
|
||||
}
|
||||
else if (StrEqual(group, "rifles", false))
|
||||
{
|
||||
UnRestrictWeapon("galil");
|
||||
UnRestrictWeapon("famas");
|
||||
UnRestrictWeapon("ak47");
|
||||
UnRestrictWeapon("m4a1");
|
||||
UnRestrictWeapon("sg552");
|
||||
UnRestrictWeapon("bullpup");
|
||||
}
|
||||
else if (StrEqual(group, "snipers", false))
|
||||
{
|
||||
UnRestrictWeapon("scout");
|
||||
UnRestrictWeapon("sg550");
|
||||
UnRestrictWeapon("g3sg1");
|
||||
UnRestrictWeapon("awp");
|
||||
}
|
||||
}
|
||||
|
||||
bool:IsWeaponRestricted(const String:weapon[])
|
||||
{
|
||||
for (new x = 0; x < GetArraySize(restrictedWeapons); x++)
|
||||
{
|
||||
decl String:restrictedweapon[32];
|
||||
GetArrayString(restrictedWeapons, x, restrictedweapon, sizeof(restrictedweapon));
|
||||
|
||||
if (StrEqual(weapon, restrictedweapon, false))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
GetRestrictedWeaponIndex(const String:weapon[])
|
||||
{
|
||||
for (new x = 0; x < GetArraySize(restrictedWeapons); x++)
|
||||
{
|
||||
decl String:restrictedweapon[32];
|
||||
GetArrayString(restrictedWeapons, x, restrictedweapon, sizeof(restrictedweapon));
|
||||
ReplaceString(restrictedweapon, sizeof(restrictedweapon), "weapon_", "");
|
||||
|
||||
if (StrEqual(weapon, restrictedweapon, false))
|
||||
{
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool:IsWeaponGroup(const String:weapon[])
|
||||
{
|
||||
return (StrEqual(weapon, "pistols", false) || StrEqual(weapon, "shotguns", false) || StrEqual(weapon, "smgs", false) || StrEqual(weapon, "rifles", false) || StrEqual(weapon, "snipers", false));
|
||||
}
|
||||
|
||||
public Weapon_CanUse(client, weapon, dummy1, dummy2, dummy3, dummy4)
|
||||
{
|
||||
new bool:enabled = GetConVarBool(gCvars[CVAR_ENABLE]);
|
||||
if (!enabled)
|
||||
{
|
||||
return Hacks_Continue;
|
||||
}
|
||||
|
||||
new String:weaponname[32];
|
||||
GetEdictClassname(weapon, weaponname, sizeof(weaponname));
|
||||
|
||||
ReplaceString(weaponname, sizeof(weaponname), "weapon_", "");
|
||||
|
||||
if (IsWeaponRestricted(weaponname))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (IsPlayerZombie(client) && !StrEqual(weaponname, "knife"))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Hacks_Continue;
|
||||
}
|
887
src/zr/zombie.inc
Normal file
887
src/zr/zombie.inc
Normal file
@ -0,0 +1,887 @@
|
||||
/**
|
||||
* ====================
|
||||
* Zombie:Reloaded
|
||||
* File: zombie.inc
|
||||
* Author: Greyscale
|
||||
* ====================
|
||||
*/
|
||||
|
||||
#define EXP_NODAMAGE 1
|
||||
#define EXP_REPEATABLE 2
|
||||
#define EXP_NOFIREBALL 4
|
||||
#define EXP_NOSMOKE 8
|
||||
#define EXP_NODECAL 16
|
||||
#define EXP_NOSPARKS 32
|
||||
#define EXP_NOSOUND 64
|
||||
#define EXP_RANDOMORIENTATION 128
|
||||
#define EXP_NOFIREBALLSMOKE 256
|
||||
#define EXP_NOPARTICLES 512
|
||||
#define EXP_NODLIGHTS 1024
|
||||
#define EXP_NOCLAMPMIN 2048
|
||||
#define EXP_NOCLAMPMAX 4096
|
||||
|
||||
new String:skyname[32];
|
||||
|
||||
HookCommands()
|
||||
{
|
||||
RegConsoleCmd("nightvision", Command_NightVision);
|
||||
}
|
||||
|
||||
public Action:Command_NightVision(client, argc)
|
||||
{
|
||||
new bool:allow_disable = GetConVarBool(gCvars[CVAR_ZVISION_ALLOW_DISABLE]);
|
||||
if (!allow_disable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
new bool:enabled = GetConVarBool(gCvars[CVAR_ENABLE]);
|
||||
if (!enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsPlayerZombie(client))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bZVision[client] = !bZVision[client];
|
||||
|
||||
if (bZVision[client])
|
||||
{
|
||||
StartZVision(client);
|
||||
}
|
||||
else
|
||||
{
|
||||
StopZVision(client);
|
||||
}
|
||||
}
|
||||
|
||||
FindMapSky()
|
||||
{
|
||||
GetConVarString(FindConVar("sv_skyname"), skyname, sizeof(skyname));
|
||||
}
|
||||
|
||||
ChangeLightStyle()
|
||||
{
|
||||
new bool:dark = GetConVarBool(gCvars[CVAR_DARK]);
|
||||
if (dark)
|
||||
{
|
||||
decl String:darkness[2];
|
||||
decl String:sky[32];
|
||||
|
||||
GetConVarString(gCvars[CVAR_DARK_LEVEL], darkness, sizeof(darkness));
|
||||
GetConVarString(gCvars[CVAR_DARK_SKY], sky, sizeof(sky));
|
||||
|
||||
SetLightStyle(0, darkness);
|
||||
SetConVarString(FindConVar("sv_skyname"), sky, true, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetLightStyle(0, "n");
|
||||
SetConVarString(FindConVar("sv_skyname"), skyname, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
public RestartGameHook(Handle:convar, const String:oldValue[], const String:newValue[])
|
||||
{
|
||||
SetConVarInt(FindConVar("mp_restartgame"), 0);
|
||||
TerminateRound(StringToFloat(newValue), Round_Draw);
|
||||
}
|
||||
|
||||
public Action:MotherZombie(Handle:timer)
|
||||
{
|
||||
RefreshList();
|
||||
|
||||
new size = GetArraySize(pList);
|
||||
new immune = 0;
|
||||
|
||||
for (new x = 0; x < size; x++)
|
||||
{
|
||||
new index = GetArrayCell(pList, x);
|
||||
|
||||
if (gBlockMotherInfect[index])
|
||||
{
|
||||
immune++;
|
||||
}
|
||||
|
||||
if (!IsPlayerAlive(index) || IsPlayerZombie(index))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
CS_SwitchTeam(index, CS_TEAM_CT);
|
||||
}
|
||||
|
||||
if (!(size - immune))
|
||||
{
|
||||
tInfect = INVALID_HANDLE;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
new randclient;
|
||||
new ratio = GetConVarInt(gCvars[CVAR_MOTHER_ZOMBIE_RATIO]);
|
||||
|
||||
if (ratio <= 0)
|
||||
{
|
||||
do
|
||||
{
|
||||
randclient = RandomPlayerFromList();
|
||||
} while (!IsPlayerAlive(randclient) || gBlockMotherInfect[randclient]);
|
||||
|
||||
Zombify_Mother(randclient);
|
||||
}
|
||||
else
|
||||
{
|
||||
new mothercount = RoundToCeil(float(size) / ratio);
|
||||
|
||||
for (new x = 0; x < mothercount; x++)
|
||||
{
|
||||
do
|
||||
{
|
||||
randclient = RandomPlayerFromList();
|
||||
} while (IsPlayerZombie(randclient) || !IsPlayerAlive(randclient) || gBlockMotherInfect[randclient]);
|
||||
|
||||
Zombify_Mother(randclient);
|
||||
}
|
||||
}
|
||||
|
||||
tInfect = INVALID_HANDLE;
|
||||
|
||||
zombieSpawned = true;
|
||||
}
|
||||
|
||||
Zombify_Mother(client)
|
||||
{
|
||||
Call_StartForward(hZombify);
|
||||
Call_PushCell(client);
|
||||
Call_PushCell(true);
|
||||
Call_Finish();
|
||||
|
||||
gZombie[client] = true;
|
||||
motherZombie[client] = true;
|
||||
|
||||
ApplyZombieHealth(client,true);
|
||||
|
||||
ApplyZombieSpeed(client);
|
||||
|
||||
CS_SwitchTeam(client, CS_TEAM_T);
|
||||
|
||||
RemoveAllPlayersWeapons(client);
|
||||
GivePlayerItem(client, "weapon_knife");
|
||||
|
||||
ApplyZombieNightVision(client);
|
||||
|
||||
ApplyZombieFOV(client);
|
||||
|
||||
ApplyZombieModel(client);
|
||||
|
||||
InfectionEffects(client);
|
||||
|
||||
ZR_PrintToChat(client, "You are a zombie");
|
||||
|
||||
if (bZVision[client])
|
||||
{
|
||||
StartZVision(client);
|
||||
}
|
||||
|
||||
new bool:mother_zombie_respawn = GetConVarBool(gCvars[CVAR_MOTHER_ZOMBIE_RESPAWN]);
|
||||
if (mother_zombie_respawn)
|
||||
{
|
||||
TeleportEntity(client, spawnLoc[client], NULL_VECTOR, NULL_VECTOR);
|
||||
}
|
||||
|
||||
new Float:interval = GetConVarFloat(gCvars[CVAR_EMITSOUNDS]);
|
||||
if (tHandles[client][TMOAN] != INVALID_HANDLE)
|
||||
{
|
||||
CloseHandle(tHandles[client][TMOAN]);
|
||||
}
|
||||
tHandles[client][TMOAN] = CreateTimer(interval, ZombieMoanTimer, client, TIMER_REPEAT);
|
||||
|
||||
if (tHandles[client][TPROTECT] != INVALID_HANDLE)
|
||||
{
|
||||
TriggerTimer(tHandles[client][TPROTECT]);
|
||||
tHandles[client][TPROTECT] = INVALID_HANDLE;
|
||||
}
|
||||
|
||||
if (tHandles[client][TZHP] != INVALID_HANDLE)
|
||||
{
|
||||
CloseHandle(tHandles[client][TZHP]);
|
||||
tHandles[client][TZHP] = INVALID_HANDLE;
|
||||
}
|
||||
|
||||
new bool:zhp = GetConVarBool(gCvars[CVAR_ZHP]);
|
||||
if (zhp)
|
||||
{
|
||||
UpdateHPDisplay(client);
|
||||
|
||||
tHandles[client][TZHP] = CreateTimer(5.0, ZHPTimer, client, TIMER_REPEAT);
|
||||
}
|
||||
}
|
||||
|
||||
Zombify(client, attacker)
|
||||
{
|
||||
if (attacker != 0)
|
||||
{
|
||||
new Handle:event = CreateEvent("player_death");
|
||||
if (event != INVALID_HANDLE)
|
||||
{
|
||||
SetEventInt(event, "userid", GetClientUserId(client));
|
||||
SetEventInt(event, "attacker", GetClientUserId(attacker));
|
||||
SetEventString(event, "weapon", "zombie_claws_of_death");
|
||||
FireEvent(event, false);
|
||||
}
|
||||
}
|
||||
|
||||
Call_StartForward(hZombify);
|
||||
Call_PushCell(client);
|
||||
Call_PushCell(false);
|
||||
Call_Finish();
|
||||
|
||||
gZombie[client] = true;
|
||||
|
||||
ApplyZombieHealth(client, false);
|
||||
|
||||
ApplyZombieSpeed(client);
|
||||
|
||||
RemoveAllPlayersWeapons(client);
|
||||
GivePlayerItem(client, "weapon_knife");
|
||||
|
||||
ApplyZombieNightVision(client);
|
||||
|
||||
ApplyZombieFOV(client);
|
||||
|
||||
ApplyZombieModel(client);
|
||||
|
||||
if (bZVision[client])
|
||||
{
|
||||
StartZVision(client);
|
||||
}
|
||||
|
||||
InfectionEffects(client);
|
||||
|
||||
new ZTeam:team = IsRoundOver();
|
||||
RoundWin(team);
|
||||
|
||||
CS_SwitchTeam(client, CS_TEAM_T);
|
||||
|
||||
new Float:interval = GetConVarFloat(gCvars[CVAR_EMITSOUNDS]);
|
||||
if (tHandles[client][TMOAN] != INVALID_HANDLE)
|
||||
{
|
||||
CloseHandle(tHandles[client][TMOAN]);
|
||||
}
|
||||
tHandles[client][TMOAN] = CreateTimer(interval, ZombieMoanTimer, client, TIMER_REPEAT);
|
||||
|
||||
if (tHandles[client][TPROTECT] != INVALID_HANDLE)
|
||||
{
|
||||
TriggerTimer(tHandles[client][TPROTECT]);
|
||||
tHandles[client][TPROTECT] = INVALID_HANDLE;
|
||||
}
|
||||
|
||||
if (tHandles[client][TZHP] != INVALID_HANDLE)
|
||||
{
|
||||
CloseHandle(tHandles[client][TZHP]);
|
||||
tHandles[client][TZHP] = INVALID_HANDLE;
|
||||
}
|
||||
|
||||
new bool:zhp = GetConVarBool(gCvars[CVAR_ZHP]);
|
||||
if (zhp)
|
||||
{
|
||||
UpdateHPDisplay(client);
|
||||
|
||||
tHandles[client][TZHP] = CreateTimer(5.0, ZHPTimer, client, TIMER_REPEAT);
|
||||
}
|
||||
|
||||
AntiStick(attacker, client);
|
||||
}
|
||||
|
||||
InfectionEffects(client)
|
||||
{
|
||||
new Float:clientloc[3];
|
||||
new Float:direction[3] = {0.0, 0.0, 0.0};
|
||||
|
||||
GetClientAbsOrigin(client, clientloc);
|
||||
clientloc[2] += 30;
|
||||
|
||||
decl String:sound[128];
|
||||
GetConVarString(gCvars[CVAR_INFECT_SOUND], sound, sizeof(sound));
|
||||
if (sound[0])
|
||||
{
|
||||
PrecacheSound(sound);
|
||||
EmitSoundToAll(sound, client, SNDCHAN_AUTO, SNDLEVEL_SCREAMING);
|
||||
}
|
||||
|
||||
new bool:esplash = GetConVarBool(gCvars[CVAR_INFECT_ESPLASH]);
|
||||
if (esplash)
|
||||
{
|
||||
TE_SetupEnergySplash(clientloc, direction, true);
|
||||
TE_SendToAll();
|
||||
}
|
||||
|
||||
new explosion = CreateEntityByName("env_explosion");
|
||||
|
||||
if (explosion != -1)
|
||||
{
|
||||
new flags = GetEntProp(explosion, Prop_Data, "m_spawnflags");
|
||||
flags = flags | EXP_NODAMAGE | EXP_NODECAL;
|
||||
|
||||
new bool:fireball = GetConVarBool(gCvars[CVAR_INFECT_FIREBALL]);
|
||||
if (!fireball)
|
||||
{
|
||||
flags = flags | EXP_NOFIREBALL;
|
||||
}
|
||||
|
||||
new bool:smoke = GetConVarBool(gCvars[CVAR_INFECT_SMOKE]);
|
||||
if (!smoke)
|
||||
{
|
||||
flags = flags | EXP_NOSMOKE;
|
||||
}
|
||||
|
||||
new bool:sparks = GetConVarBool(gCvars[CVAR_INFECT_SPARKS]);
|
||||
if (!sparks)
|
||||
{
|
||||
flags = flags | EXP_NOSPARKS;
|
||||
}
|
||||
|
||||
SetEntProp(explosion, Prop_Data, "m_spawnflags", flags);
|
||||
|
||||
DispatchSpawn(explosion);
|
||||
|
||||
PrecacheModel("materials/sprites/xfireball3.vmt");
|
||||
|
||||
DispatchKeyValueVector(explosion, "origin", clientloc);
|
||||
DispatchKeyValue(explosion, "fireballsprite", "materials/sprites/xfireball3.vmt");
|
||||
|
||||
AcceptEntityInput(explosion, "Explode");
|
||||
}
|
||||
|
||||
new bool:shake = GetConVarBool(gCvars[CVAR_INFECT_SHAKE]);
|
||||
if (shake)
|
||||
{
|
||||
new Handle:hShake = StartMessageOne("Shake", client);
|
||||
if (hShake != INVALID_HANDLE)
|
||||
{
|
||||
BfWriteByte(hShake, 0);
|
||||
BfWriteFloat(hShake, GetConVarFloat(gCvars[CVAR_INFECT_SHAKE_AMP]));
|
||||
BfWriteFloat(hShake, GetConVarFloat(gCvars[CVAR_INFECT_SHAKE_FREQUENCY]));
|
||||
BfWriteFloat(hShake, GetConVarFloat(gCvars[CVAR_INFECT_SHAKE_DURATION]));
|
||||
|
||||
EndMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ApplyZombieHealth(client, bool:mother)
|
||||
{
|
||||
new health = GetClassHealth(pClass[client]);
|
||||
|
||||
if (mother)
|
||||
{
|
||||
health *= 2;
|
||||
}
|
||||
|
||||
SetEntityHealth(client, health);
|
||||
}
|
||||
|
||||
ApplyZombieSpeed(client)
|
||||
{
|
||||
new Float:speed = GetClassSpeed(pClass[client]);
|
||||
SetPlayerSpeed(client, speed);
|
||||
}
|
||||
|
||||
ApplyZombieNightVision(client)
|
||||
{
|
||||
new bool:nvgs = GetClassNVGs(pClass[client]);
|
||||
NightVision(client, nvgs);
|
||||
NightVisionOn(client, nvgs);
|
||||
}
|
||||
|
||||
ApplyZombieFOV(client)
|
||||
{
|
||||
new fov = GetClassFOV(pClass[client]);
|
||||
SetPlayerFOV(client, fov);
|
||||
}
|
||||
|
||||
KnockBack(client, const Float:clientloc[3], const Float:attackerloc[3], Float:power, dmg, bool:boost)
|
||||
{
|
||||
if (!IsPlayerZombie(client))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
new Float:vector[3];
|
||||
|
||||
MakeVectorFromPoints(attackerloc, clientloc, vector);
|
||||
NormalizeVector(vector, vector);
|
||||
|
||||
vector[0] *= power * (float(dmg) * 1.5);
|
||||
vector[1] *= power * (float(dmg) * 1.5);
|
||||
vector[2] *= power * (float(dmg) * 1.5);
|
||||
|
||||
if (boost)
|
||||
{
|
||||
ScaleVector(vector, 4.0);
|
||||
}
|
||||
|
||||
SetPlayerVelocity(client, vector);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
PlayerLeft(client)
|
||||
{
|
||||
if (!IsClientInGame(client))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
new ZTeam:team = IsRoundOver();
|
||||
if (team == Zombie)
|
||||
{
|
||||
RoundWin(team);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsPlayerAlive(client) || !IsPlayerZombie(client))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
new zombiecount = GetZTeamCount(Zombie);
|
||||
if (zombiecount > 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
new count = GetTeamClientCount(CS_TEAM_CT);
|
||||
if (count <= 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
new Handle:aClients = CreateArray();
|
||||
|
||||
new maxplayers = GetMaxClients();
|
||||
for (new x = 1; x <= maxplayers; x++)
|
||||
{
|
||||
if (!IsClientInGame(x) || !IsPlayerAlive(x) || client == x || GetClientTeam(x) != CS_TEAM_CT || gBlockMotherInfect[x])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
PushArrayCell(aClients, x);
|
||||
}
|
||||
|
||||
new size = GetArraySize(aClients);
|
||||
if (!size)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
new randclient = GetArrayCell(aClients, GetRandomInt(0, size-1));
|
||||
Zombify_Mother(randclient);
|
||||
|
||||
ZR_PrintToChat(randclient, "Zombie replacement");
|
||||
|
||||
CloseHandle(aClients);
|
||||
}
|
||||
|
||||
GetZTeamCount(ZTeam:team)
|
||||
{
|
||||
new count = 0;
|
||||
|
||||
new maxplayers = GetMaxClients();
|
||||
for (new x = 1; x <= maxplayers; x++)
|
||||
{
|
||||
if (!IsClientInGame(x) || !IsPlayerAlive(x))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
new ZTeam:pTeam = GetPlayerZTeam(x);
|
||||
if (pTeam == team)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
ZTeam:IsRoundOver()
|
||||
{
|
||||
new bool:zombies = false;
|
||||
new bool:humans = false;
|
||||
|
||||
new maxplayers = GetMaxClients();
|
||||
for (new x = 1; x <= maxplayers; x++)
|
||||
{
|
||||
if (!IsClientInGame(x) || !IsPlayerAlive(x))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (IsPlayerZombie(x))
|
||||
{
|
||||
zombies = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
humans = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (zombies && !humans)
|
||||
{
|
||||
return Zombie;
|
||||
}
|
||||
|
||||
if (humans && !zombies)
|
||||
{
|
||||
if (zombieSpawned)
|
||||
{
|
||||
return Human;
|
||||
}
|
||||
}
|
||||
|
||||
return Neither;
|
||||
}
|
||||
|
||||
RoundWin(ZTeam:team)
|
||||
{
|
||||
if (team == Human)
|
||||
{
|
||||
TerminateRound(5.0, CTs_PreventEscape);
|
||||
}
|
||||
else if (team == Zombie)
|
||||
{
|
||||
TerminateRound(5.0, Terrorists_Escaped);
|
||||
}
|
||||
}
|
||||
|
||||
BalanceTeams()
|
||||
{
|
||||
new count = 0;
|
||||
new cPlayers[MAXPLAYERS];
|
||||
|
||||
new maxplayers = GetMaxClients();
|
||||
for (new x = 1; x <= maxplayers; x++)
|
||||
{
|
||||
if (!IsClientInGame(x) || GetClientTeam(x) <= 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
CS_SwitchTeam(x, CS_TEAM_T);
|
||||
cPlayers[count++] = x;
|
||||
}
|
||||
|
||||
for (new x = 0; x < count; x++)
|
||||
{
|
||||
if (!IsClientInGame(cPlayers[x]) || GetClientTeam(cPlayers[x]) <= 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
CS_SwitchTeam(cPlayers[x], CS_TEAM_CT);
|
||||
x++;
|
||||
}
|
||||
}
|
||||
|
||||
RemoveObjectives()
|
||||
{
|
||||
decl String:classname[64];
|
||||
|
||||
new maxentities = GetMaxEntities();
|
||||
for (new x = 0; x <= maxentities; x++)
|
||||
{
|
||||
if(!IsValidEdict(x))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
GetEdictClassname(x, classname, sizeof(classname));
|
||||
if( StrEqual(classname, "func_bomb_target") ||
|
||||
StrEqual(classname, "func_hostage_rescue") ||
|
||||
StrEqual(classname, "c4") ||
|
||||
StrEqual(classname, "hostage_entity"))
|
||||
{
|
||||
RemoveEdict(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AntiStick(attacker, client)
|
||||
{
|
||||
if (!attacker || !IsClientInGame(attacker))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
new Float:vector[3];
|
||||
|
||||
new Float:attackerloc[3];
|
||||
new Float:clientloc[3];
|
||||
|
||||
GetClientAbsOrigin(attacker, attackerloc);
|
||||
GetClientAbsOrigin(client, clientloc);
|
||||
|
||||
MakeVectorFromPoints(attackerloc, clientloc, vector);
|
||||
|
||||
NormalizeVector(vector, vector);
|
||||
ScaleVector(vector, -160.0);
|
||||
|
||||
TeleportEntity(attacker, NULL_VECTOR, NULL_VECTOR, vector);
|
||||
}
|
||||
|
||||
StartZVision(client)
|
||||
{
|
||||
if (tHandles[client][TZVISION] != INVALID_HANDLE)
|
||||
{
|
||||
CloseHandle(tHandles[client][TZVISION]);
|
||||
}
|
||||
|
||||
new bool:zvision = ZVision(client);
|
||||
if (zvision)
|
||||
{
|
||||
new Float:redisplay = GetConVarFloat(gCvars[CVAR_ZVISION_REDISPLAY]);
|
||||
tHandles[client][TZVISION] = CreateTimer(redisplay, ZVisionTimer, client, TIMER_REPEAT);
|
||||
}
|
||||
}
|
||||
|
||||
StopZVision(client)
|
||||
{
|
||||
if (tHandles[client][TZVISION] != INVALID_HANDLE)
|
||||
{
|
||||
CloseHandle(tHandles[client][TZVISION]);
|
||||
tHandles[client][TZVISION] = INVALID_HANDLE;
|
||||
}
|
||||
|
||||
ClientCommand(client, "r_screenoverlay \"\"");
|
||||
}
|
||||
|
||||
bool:ZVision(client)
|
||||
{
|
||||
if (IsFakeClient(client))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
decl String:zvision[64];
|
||||
GetClassZVision(pClass[client], zvision, sizeof(zvision));
|
||||
|
||||
if (zvision[0])
|
||||
{
|
||||
DisplayClientOverlay(client, zvision);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public Action:ZVisionTimer(Handle:timer, any:index)
|
||||
{
|
||||
if (!IsClientInGame(index) || !IsPlayerZombie(index))
|
||||
{
|
||||
tHandles[index][TZVISION] = INVALID_HANDLE;
|
||||
|
||||
return Plugin_Stop;
|
||||
}
|
||||
|
||||
ZVision(index);
|
||||
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
ZombieMoan(client)
|
||||
{
|
||||
decl String:sound[64];
|
||||
|
||||
new randsound = GetRandomInt(1, 14);
|
||||
Format(sound, sizeof(sound), "npc/zombie/zombie_voice_idle%d.wav", randsound);
|
||||
|
||||
PrecacheSound(sound);
|
||||
EmitSoundToAll(sound, client, SNDCHAN_AUTO, SNDLEVEL_SCREAMING);
|
||||
}
|
||||
|
||||
public Action:ZombieMoanTimer(Handle:timer, any:index)
|
||||
{
|
||||
if (!IsClientInGame(index) || !IsPlayerZombie(index))
|
||||
{
|
||||
tHandles[index][TMOAN] = INVALID_HANDLE;
|
||||
|
||||
return Plugin_Stop;
|
||||
}
|
||||
|
||||
ZombieMoan(index);
|
||||
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
public Action:Regenerate(Handle:timer, any:index)
|
||||
{
|
||||
if (!IsClientInGame(index) || !IsPlayerZombie(index))
|
||||
{
|
||||
tHandles[index][TREGEN] = INVALID_HANDLE;
|
||||
|
||||
return Plugin_Stop;
|
||||
}
|
||||
|
||||
new health = GetClassRegenHealth(pClass[index]);
|
||||
new maxhealth = GetClassHealth(pClass[index]);
|
||||
|
||||
if (motherZombie[index])
|
||||
{
|
||||
maxhealth *= 2;
|
||||
}
|
||||
|
||||
new newhealth = GetClientHealth(index) + health;
|
||||
if (newhealth > maxhealth)
|
||||
{
|
||||
newhealth = maxhealth;
|
||||
|
||||
tHandles[index][TREGEN] = INVALID_HANDLE;
|
||||
|
||||
return Plugin_Stop;
|
||||
}
|
||||
|
||||
SetEntityHealth(index, newhealth);
|
||||
|
||||
UpdateHPDisplay(index);
|
||||
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
UpdateHPDisplay(client)
|
||||
{
|
||||
new bool:zhp = GetConVarBool(gCvars[CVAR_ZHP]);
|
||||
if (!zhp)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsPlayerZombie(client) || !dispHP[client])
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
new health = GetClientHealth(client);
|
||||
if (health < 0)
|
||||
{
|
||||
health = 0;
|
||||
}
|
||||
|
||||
ZR_HudHint(client, "Display HP", health);
|
||||
}
|
||||
|
||||
public Action:ZHPTimer(Handle:timer, any:index)
|
||||
{
|
||||
if (!IsClientInGame(index))
|
||||
{
|
||||
tHandles[index][TZHP] = INVALID_HANDLE;
|
||||
|
||||
return Plugin_Stop;
|
||||
}
|
||||
|
||||
UpdateHPDisplay(index);
|
||||
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
public Action:EndProtect(Handle:timer, any:index)
|
||||
{
|
||||
if (!IsClientInGame(index))
|
||||
{
|
||||
tHandles[index][TPROTECT] = INVALID_HANDLE;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
pProtect[index] = false;
|
||||
|
||||
if (IsPlayerHuman(index))
|
||||
{
|
||||
ZR_PrintCenterText(index, "Spawn protection end");
|
||||
}
|
||||
|
||||
tHandles[index][TPROTECT] = INVALID_HANDLE;
|
||||
}
|
||||
|
||||
RespawnPlayer(client)
|
||||
{
|
||||
if (!IsClientInGame(client))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CS_RespawnPlayer(client);
|
||||
|
||||
if (!zombieSpawned)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
decl String:team[32];
|
||||
GetConVarString(gCvars[CVAR_RESPAWN_TEAM], team, sizeof(team));
|
||||
|
||||
if (StrEqual(team, "zombie", false))
|
||||
{
|
||||
Zombify(client, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public Action:RespawnTimer(Handle:timer, any:index)
|
||||
{
|
||||
new team = GetClientTeam(index);
|
||||
if (!IsClientInGame(index) || IsPlayerAlive(index) || team != CS_TEAM_T && team != CS_TEAM_CT)
|
||||
{
|
||||
tHandles[index][TZHP] = INVALID_HANDLE;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
RespawnPlayer(index);
|
||||
|
||||
tHandles[index][TRESPAWN] = INVALID_HANDLE;
|
||||
}
|
||||
|
||||
public Action:RoundOver(Handle:timer)
|
||||
{
|
||||
tRound = INVALID_HANDLE;
|
||||
|
||||
RoundWin(Human);
|
||||
}
|
||||
|
||||
bool:IsPlayerZombie(client)
|
||||
{
|
||||
return gZombie[client];
|
||||
}
|
||||
|
||||
bool:IsPlayerHuman(client)
|
||||
{
|
||||
return !gZombie[client];
|
||||
}
|
||||
|
||||
ZTeam:GetPlayerZTeam(client)
|
||||
{
|
||||
if (IsPlayerZombie(client))
|
||||
{
|
||||
return Zombie;
|
||||
}
|
||||
|
||||
return Human;
|
||||
}
|
177
src/zr/zombiereloaded.inc
Normal file
177
src/zr/zombiereloaded.inc
Normal file
@ -0,0 +1,177 @@
|
||||
/**
|
||||
* ====================
|
||||
* Zombie:Reloaded
|
||||
* File: zombiereloaded.inc
|
||||
* Author: Greyscale
|
||||
* ====================
|
||||
*/
|
||||
|
||||
enum ZTeam
|
||||
{
|
||||
Neither, /** Round is not over */
|
||||
Zombie, /** Round is over because zombies win */
|
||||
Human, /** Round is over because humans wins */
|
||||
}
|
||||
|
||||
#define Target_Bombed 1 // Target Successfully Bombed!
|
||||
#define VIP_Escaped 2 // The VIP has escaped!
|
||||
#define VIP_Assassinated 3 // VIP has been assassinated!
|
||||
#define Terrorists_Escaped 4 // The terrorists have escaped!
|
||||
#define CTs_PreventEscape 5 // The CT's have prevented most of the terrorists from escaping!
|
||||
#define Escaping_Terrorists_Neutralized 6 // Escaping terrorists have all been neutralized!
|
||||
#define Bomb_Defused 7 // The bomb has been defused!
|
||||
#define CTs_Win 8 // Counter-Terrorists Win!
|
||||
#define Terrorists_Win 9 // Terrorists Win!
|
||||
#define Round_Draw 10 // Round Draw!
|
||||
#define All_Hostages_Rescued 11 // All Hostages have been rescued!
|
||||
#define Target_Saved 12 // Target has been saved!
|
||||
#define Hostages_Not_Rescued 13 // Hostages have not been rescued!
|
||||
#define Terrorists_Not_Escaped 14 // Terrorists have not escaped!
|
||||
#define VIP_Not_Escaped 15 // VIP has not escaped!
|
||||
#define Game_Commencing 16 // Game Commencing!
|
||||
|
||||
#define DXLEVEL_MIN 90
|
||||
|
||||
#define DEFAULT_FOV 90
|
||||
|
||||
new bool:market;
|
||||
|
||||
new dxLevel[MAXPLAYERS+1];
|
||||
|
||||
new bool:zombieSpawned;
|
||||
new bool:motherZombie[MAXPLAYERS+1];
|
||||
new bool:gZombie[MAXPLAYERS+1];
|
||||
new bool:gBlockMotherInfect[MAXPLAYERS+1];
|
||||
new bool:bZVision[MAXPLAYERS+1];
|
||||
new bool:dispHP[MAXPLAYERS+1];
|
||||
new bool:pProtect[MAXPLAYERS+1];
|
||||
|
||||
new pClass[MAXPLAYERS+1];
|
||||
new pNextClass[MAXPLAYERS+1];
|
||||
|
||||
new teleCount[MAXPLAYERS+1];
|
||||
new Float:spawnLoc[MAXPLAYERS+1][3];
|
||||
|
||||
new Handle:tRound = INVALID_HANDLE;
|
||||
new Handle:tInfect = INVALID_HANDLE;
|
||||
|
||||
new Handle:pList = INVALID_HANDLE;
|
||||
|
||||
#define MAXTIMERS 7
|
||||
|
||||
#define TMOAN 0
|
||||
#define TREGEN 1
|
||||
#define TTELE 2
|
||||
#define TZHP 3
|
||||
#define TPROTECT 4
|
||||
#define TRESPAWN 5
|
||||
#define TZVISION 6
|
||||
|
||||
new Handle:tHandles[MAXPLAYERS+1][MAXTIMERS];
|
||||
|
||||
new QueryCookie:mat_dxlevel;
|
||||
|
||||
FindClientDXLevel(client)
|
||||
{
|
||||
if (IsFakeClient(client))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
mat_dxlevel = QueryClientConVar(client, "mat_dxlevel", DXLevelClientQuery);
|
||||
}
|
||||
|
||||
public DXLevelClientQuery(QueryCookie:cookie, client, ConVarQueryResult:result, const String:cvarName[], const String:cvarValue[])
|
||||
{
|
||||
if (cookie != mat_dxlevel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
dxLevel[client] = 0;
|
||||
|
||||
if (result != ConVarQuery_Okay)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
dxLevel[client] = StringToInt(cvarValue);
|
||||
}
|
||||
|
||||
DisplayClientOverlay(client, const String:overlay[])
|
||||
{
|
||||
if (!dxLevel[client])
|
||||
{
|
||||
FindClientDXLevel(client);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (dxLevel[client] >= DXLEVEL_MIN)
|
||||
{
|
||||
ClientCommand(client, "r_screenoverlay \"%s\"", overlay);
|
||||
}
|
||||
else
|
||||
{
|
||||
ZR_PrintCenterText(client, "DX90 not supported", dxLevel[client], DXLEVEL_MIN);
|
||||
}
|
||||
}
|
||||
|
||||
RefreshList()
|
||||
{
|
||||
ClearList();
|
||||
|
||||
pList = CreateArray();
|
||||
|
||||
new maxplayers = GetMaxClients();
|
||||
for (new x = 1; x <= maxplayers; x++)
|
||||
{
|
||||
if (IsClientInGame(x))
|
||||
{
|
||||
new team = GetClientTeam(x);
|
||||
if (team == CS_TEAM_T || team == CS_TEAM_CT)
|
||||
{
|
||||
PushArrayCell(pList, x);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AddPlayerToList(client)
|
||||
{
|
||||
if (pList != INVALID_HANDLE)
|
||||
{
|
||||
PushArrayCell(pList, client);
|
||||
}
|
||||
}
|
||||
|
||||
ClearList()
|
||||
{
|
||||
if (pList != INVALID_HANDLE)
|
||||
{
|
||||
ClearArray(pList);
|
||||
}
|
||||
}
|
||||
|
||||
RandomPlayerFromList()
|
||||
{
|
||||
if (pList != INVALID_HANDLE)
|
||||
{
|
||||
new size = GetArraySize(pList);
|
||||
new index = GetRandomInt(0, size - 1);
|
||||
|
||||
return GetArrayCell(pList, index);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool:IsPlayerInList(client)
|
||||
{
|
||||
if (pList != INVALID_HANDLE)
|
||||
{
|
||||
return (FindValueInArray(pList, client) != -1);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
Reference in New Issue
Block a user