Recoded ztele, removed old ztele, made conversion function.

This commit is contained in:
Greyscale 2009-05-05 06:56:34 +02:00
parent dca8aa330b
commit a36e0dab5a
12 changed files with 369 additions and 674 deletions

View File

@ -34,62 +34,6 @@
"en" "Type !zmenu in chat to view all ZR commands."
"ru" "Напишите !zmenu в чате для просмотра всех команд."
}
"!ztele amount"
{
"#format" "{1:d}"
"en" "You have @green{1}@default teleports left this round."
"ru" "У вас осталось @green{1}@default телепортов в этом раунде."
}
"!ztele time left"
{
"#format" "{1:d}"
"en" "You will be teleported in {1} seconds."
"ru" "Вы будете телепортированы через {1} секунды."
}
"!ztele limit reached"
{
"en" "Teleportation limit has been reached."
"ru" "Вы использовали все свои телепорты."
}
"!ztele humans restricted"
{
"en" "Once a player has been infected, only zombies can use !ztele."
"ru" "После инфицирования кого-либо, только зомби могут использовать !ztele"
}
"!ztele zombies restricted"
{
"en" "The teleporter is disabled for zombies."
}
"!ztele not spawned"
{
"en" "You cannot use the teleporter before you've spawned."
}
"!ztele offline"
{
"en" "The teleporter is not online yet."
}
"!ztele cooldown"
{
"en" "Your teleporter is still on a cooldown."
}
"!ztele in progress"
{
"en" "You already have a teleportation in progress."
}
"!ztele successful"
{
"en" "Teleport successful."
}
// ===========================
// Generic
@ -97,40 +41,39 @@
// General
"Console restricted"
{
"en" "Command not usable from console."
"ru" "Команда не используется для консоли."
}
"Feature is disabled"
{
"en" "This feature has been disabled by the server host."
"ru" "Данная функция отключена."
"en" "This feature is currently disabled by the server host."
}
"Must be player"
{
"en" "This feature is reserved for players only."
}
"Must be admin"
{
"en" "Can only be used by admins."
"ru" "Может быть использовано только, когда жив."
"en" "This feature is reserved for admins only."
}
"Must be alive"
{
"en" "Can only be used when alive."
"ru" "Может быть использовано только, когда жив."
"en" "This feature requires that you are alive."
}
"Must be dead"
{
"en" "Can only be used when dead."
"ru" "Может быть использовано только, когда мертв."
"en" "This feature requires that you are dead."
}
"Must be zombie"
{
"en" "Can only be used while zombie."
"ru" "Может быть использовано только, когда зомби."
"en" "This feature requires that you are a zombie.
}
"Must be human"
{
"en" "This feature requires that you are a human."
}
// Menu
@ -442,6 +385,49 @@
"ru" "Здоровье: {1}"
}
// ===========================
// ZTele
// ===========================
// General
"ZTele restricted human"
{
"en" "ZTele is restricted for humans at this time."
}
"ZTele max"
{
"#format" "{1:d}"
"en" "You have reached your max of {1} teleports per round."
}
"ZTele autocancel text"
{
"#format" "{1:d}"
"en" "Teleport has been cancelled. (Restrictive boundary is {1} ft.)"
}
// Center Text
"ZTele countdown"
{
"#format" "{1:d}"
"en" "Teleporting back to spawn in: {1} seconds."
}
"ZTele autocancel centertext"
{
"en" "Teleport has been cancelled."
}
"ZTele countdown end"
{
"#format" "{1:d},{2:d}"
"en" "Teleported back to spawn. (Count: {1}/{2})"
}
"Unfair camping"
{
@ -633,17 +619,4 @@
"en" "-----------| Zombie:Reloaded Loaded |----------"
"ru" "-----------| Zombie:Reloaded Загружен |----------"
}
"Models loaded"
{
"en" "--- Models Loaded ---"
"ru" "--- Модели Загружены ---"
}
"File load failed"
{
"#format" "{1:s}"
"en" "Missing file for download: \"{1}\", check downloads.txt"
"ru" "Пропущен файл для скачивания: \"{1}\", проверьте downloads.txt"
}
}
}

View File

@ -51,10 +51,10 @@
#include "zr/respawn"
#include "zr/napalm"
#include "zr/zspawn"
#include "zr/ztele"
#include "zr/zhp"
#include "zr/jumpboost"
#include "zr/anticamp"
#include "zr/teleport"
// Almost replaced! :)
#include "zr/zombie"
@ -216,6 +216,7 @@ public OnClientPutInServer(client)
SEffectsClientInit(client);
SpawnProtectClientInit(client);
RespawnClientInit(client);
ZTeleClientInit(client);
ZHPClientInit(client);
}
@ -232,5 +233,4 @@ public OnClientDisconnect(client)
InfectOnClientDisconnect(client);
DamageOnClientDisconnect(client);
ZSpawnOnClientDisconnect(client);
ZTeleResetClient(client);
}

View File

@ -11,11 +11,6 @@ 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_teleport", Command_Teleport, ADMFLAG_GENERIC, "Teleports one or more players to spawn. Usage: zr_teleport <target>");
RegAdminCmd("zr_tele_saveloc", Command_TeleSaveLocation, ADMFLAG_GENERIC, "Saves your or a players location to a buffer. Usage: zr_tele_saveloc [#userid|name]");
RegAdminCmd("zr_tele_loc", Command_TeleportToLocation, ADMFLAG_GENERIC, "Teleports you or a player to the saved location. Usage: zr_tele_loc [#userid|name]");
RegAdminCmd("zr_tele_abort", Command_TeleportAbort, ADMFLAG_GENERIC, "Aborts a teleportation or cooldown on a client. Usage: zr_tele_abort <target>");
// Weapon restrict commands
RegAdminCmd("zr_restrict", Command_Restrict, ADMFLAG_GENERIC, "Restrict a specified weapon");
RegAdminCmd("zr_unrestrict", Command_Unrestrict, ADMFLAG_GENERIC, "Unrestrict a specified weapon");
@ -25,7 +20,6 @@ CreateCommands()
RegAdminCmd("zr_admin", Command_AdminMenu, ADMFLAG_GENERIC, "Displays the admin menu for Zombie: Reloaded.");
//RegAdminCmd("zr_knockback_m", Command_KnockbackMMenu, ADMFLAG_GENERIC, "Displays the knockback multiplier menu.");
RegAdminCmd("zr_teleadmin", Command_TeleMenu, ADMFLAG_GENERIC, "Displays the teleport admin menu for Zombie: Reloaded.");
RegAdminCmd("zr_anticamp_create_volume", Command_AnticampCreateVolume, ADMFLAG_GENERIC, "Creates a rectangular hurt volume between two points. Usage: ht_create_volume <damage> <interval> <x1> <y1> <z1> <x2> <y2> <z2>");
RegAdminCmd("zr_anticamp_remove_volume", Command_AnticampRemoveVolume, ADMFLAG_GENERIC, "Removes a volume. Use zr_anticamp_list to list volumes. Usage: zr_anticamp_remove_volume <volume index>");

View File

@ -95,6 +95,15 @@ enum CvarsList
Handle:CVAR_RESPAWN_ZOMBIE,
Handle:CVAR_RESPAWN_ZOMBIE_WORLD,
Handle:CVAR_ZSPAWN,
Handle:CVAR_ZTELE_ZOMBIE,
Handle:CVAR_ZTELE_HUMAN_BEFORE,
Handle:CVAR_ZTELE_HUMAN_AFTER,
Handle:CVAR_ZTELE_DELAY_ZOMBIE,
Handle:CVAR_ZTELE_DELAY_HUMAN,
Handle:CVAR_ZTELE_MAX_ZOMBIE,
Handle:CVAR_ZTELE_MAX_HUMAN,
Handle:CVAR_ZTELE_AUTOCANCEL,
Handle:CVAR_ZTELE_AUTOCANCEL_DISTANCE,
Handle:CVAR_ZHP,
Handle:CVAR_ZHP_DEFAULT,
@ -102,14 +111,6 @@ enum CvarsList
Handle:CVAR_OVERLAY_REDISPLAY,
Handle:CVAR_ZVISION_ALLOW_DISABLE,
Handle:CVAR_MENU_AUTOCLOSE,
Handle:CVAR_ZTELE,
Handle:CVAR_ZTELE_STARTUP_DELAY,
Handle:CVAR_ZTELE_COOLDOWN,
Handle:CVAR_ZTELE_HUMAN_DELAY,
Handle:CVAR_ZTELE_HUMAN_LIMIT,
Handle:CVAR_ZTELE_ZOMBIE_DELAY,
Handle:CVAR_ZTELE_ZOMBIE_LIMIT,
Handle:CVAR_ZTELE_RESET_BUFFERS,
Handle:CVAR_ANTICAMP,
Handle:CVAR_ANTICAMP_UPDATE_INTERVAL,
}
@ -430,6 +431,20 @@ CvarsCreate()
g_hCvarsList[CVAR_ZSPAWN] = CreateConVar("zr_zspawn", "1", "");
// Old Desc: Allow players to spawn if they just joined the game (0: Disable)
// ===========================
// ZTele (module)
// ===========================
g_hCvarsList[CVAR_ZTELE_ZOMBIE] = CreateConVar("zr_ztele_zombie", "1", "");
g_hCvarsList[CVAR_ZTELE_HUMAN_BEFORE] = CreateConVar("zr_ztele_human_before", "1", "");
g_hCvarsList[CVAR_ZTELE_HUMAN_AFTER] = CreateConVar("zr_ztele_human_after", "0", "");
g_hCvarsList[CVAR_ZTELE_DELAY_ZOMBIE] = CreateConVar("zr_ztele_delay_zombie", "3", "");
g_hCvarsList[CVAR_ZTELE_DELAY_HUMAN] = CreateConVar("zr_ztele_delay_human", "3", "");
g_hCvarsList[CVAR_ZTELE_MAX_ZOMBIE] = CreateConVar("zr_ztele_max_zombie", "3", "");
g_hCvarsList[CVAR_ZTELE_MAX_HUMAN] = CreateConVar("zr_ztele_max_human", "1", "");
g_hCvarsList[CVAR_ZTELE_AUTOCANCEL] = CreateConVar("zr_ztele_autocancel", "1", "");
g_hCvarsList[CVAR_ZTELE_AUTOCANCEL_DISTANCE] = CreateConVar("zr_ztele_autocancel_distance", "20", "");
// ===========================
// ZHP (module)
// ===========================
@ -447,22 +462,6 @@ CvarsCreate()
// Old Desc: Allow users to disable ZVision with their nightvision key (0: Disable)
g_hCvarsList[CVAR_MENU_AUTOCLOSE] = CreateConVar("zr_menu_autoclose", "0", "");
// Old Desc: Automatically close menus on selection. If disabled the menu will remain open.
g_hCvarsList[CVAR_ZTELE] = CreateConVar("zr_tele", "1", "");
// Old Desc: Allow players to use the teleporter to get to spawn. (0: Disable)
g_hCvarsList[CVAR_ZTELE_STARTUP_DELAY] = CreateConVar("zr_tele_startup_delay", "30", "");
// Old Desc: Number of seconds to wait before the teleporter is enabled (0: Always enabled)
g_hCvarsList[CVAR_ZTELE_COOLDOWN] = CreateConVar("zr_tele_cooldown", "20", "");
// Old Desc: Number of seconds to wait before the teleporter can be used again, after a teleport. (0: Disable)
g_hCvarsList[CVAR_ZTELE_HUMAN_DELAY] = CreateConVar("zr_tele_human_delay", "10", "");
// Old Desc: Teleport delay for humans. (0: No delay)
g_hCvarsList[CVAR_ZTELE_HUMAN_LIMIT] = CreateConVar("zr_tele_human_limit", "3", "");
// Old Desc: Maximum number of teleports humans can do. (0: Humans can't use the teleporter. -1: Unlimited)
g_hCvarsList[CVAR_ZTELE_ZOMBIE_DELAY] = CreateConVar("zr_tele_zombie_delay", "0", "");
// Old Desc: Teleport delay for zombies. (0: No delay)
g_hCvarsList[CVAR_ZTELE_ZOMBIE_LIMIT] = CreateConVar("zr_tele_zombie_limit", "8", "");
// Old Desc: Maximum number of teleports zombies can do. (0: Zombies can't use the teleporter. -1: Unlimited)
g_hCvarsList[CVAR_ZTELE_RESET_BUFFERS] = CreateConVar("zr_tele_reset_buffers", "1", "");
// Old Desc: Reset custom saved teleport locations on each round start. (0: Disable)
g_hCvarsList[CVAR_ANTICAMP] = CreateConVar("zr_anticamp", "1", "");
// Old Desc: Enables or disables hurt volumes for preventing unfair camping. (0: Disable)
g_hCvarsList[CVAR_ANTICAMP_UPDATE_INTERVAL] = CreateConVar("zr_anticamp_update_interval", "1", "");

View File

@ -91,8 +91,6 @@ public Action:EventRoundFreezeEnd(Handle:event, const String:name[], bool:dontBr
// Forward events to modules.
RoundEndOnRoundFreezeEnd();
InfectOnRoundFreezeEnd();
ZTeleEnable();
}
/**
@ -112,7 +110,6 @@ public Action:EventRoundEnd(Handle:event, const String:name[], bool:dontBroadcas
RoundEndOnRoundEnd(reason);
InfectOnRoundEnd();
RespawnOnRoundEnd();
ZTeleReset();
}
/**
@ -179,8 +176,8 @@ public Action:EventPlayerSpawn(Handle:event, const String:name[], bool:dontBroad
AccountOnClientSpawn(index);
SpawnProtectOnClientSpawn(index);
RespawnOnClientSpawn(index);
ZTeleOnClientSpawn(index);
ZHPOnClientSpawn(index);
ZTeleClientSpawned(index);
ZR_PrintToChat(index, "!zmenu reminder");
}
@ -259,6 +256,7 @@ public Action:EventPlayerDeath(Handle:event, const String:name[], bool:dontBroad
SEffectsOnClientDeath(index);
SpawnProtectOnClientDeath(index);
RespawnOnClientDeath(index, attacker, weapon);
ZTeleOnClientDeath(index);
ZHPOnClientDeath(index);
}

View File

@ -568,8 +568,8 @@ InfectClient(client, attacker = -1, bool:motherinfect = false)
ClassOnClientInfected(client, motherinfect);
RoundEndOnClientInfected();
SEffectsOnClientInfected(client);
ZTeleOnClientInfected(client);
ZHPOnClientInfected(client);
TeleportOnClientInfected(client);
}
/**

View File

@ -101,7 +101,7 @@ public MenuMainHandle(Handle:menu, MenuAction:action, client, slot)
case 3:
{
// Copy return to resend variable.
resend = !ZTele(client);
resend = !ZTeleClient(client);
}
// Select zhp.
case 4:

View File

@ -105,7 +105,7 @@ public Action:SayHooksCmdSay(client, argc)
// Client triggered ZTele flag.
case SAYHOOKS_KEYWORD_FLAG_ZTELE:
{
ZTele(client);
ZTeleClient(client);
}
// Client triggered ZHP flag.
case SAYHOOKS_KEYWORD_FLAG_ZHP:

View File

@ -1,548 +0,0 @@
/**
* ====================
* Zombie:Reloaded
* File: teleport.inc
* Authors: Richard Helgeby, Cpt.Moore
* ====================
*/
new Float:spawnLoc[MAXPLAYERS + 1][3];
new Float:bufferLoc[MAXPLAYERS + 1][3];
new bool:ztele_spawned[MAXPLAYERS + 1] = {false, ...};
new bool:bufferLocSaved[MAXPLAYERS + 1] = {false, ...};
new ztele_countdown[MAXPLAYERS + 1] = {-1, ...};
new ztele_count[MAXPLAYERS + 1];
new bool:ztele_online = false;
new Handle:ztele_startup_timer = INVALID_HANDLE;
new Handle:ztele_countdown_timer[MAXPLAYERS + 1] = {INVALID_HANDLE, ...};
new Handle:ztele_cooldown_timer[MAXPLAYERS + 1] = {INVALID_HANDLE, ...};
ZTeleEnable()
{
ztele_online = false;
if (ztele_startup_timer != INVALID_HANDLE)
{
KillTimer(ztele_startup_timer);
}
new Float:startup_delay = GetConVarFloat(g_hCvarsList[CVAR_ZTELE_STARTUP_DELAY]);
if (startup_delay > 0)
{
ztele_startup_timer = CreateTimer(startup_delay, Event_TeleporterStartup);
}
else
{
ztele_online = true;
}
}
ZTeleReset()
{
ztele_online = false;
if (ztele_startup_timer != INVALID_HANDLE)
{
KillTimer(ztele_startup_timer);
ztele_startup_timer = INVALID_HANDLE;
}
for (new client = 1; client <= MAXPLAYERS; client++)
{
spawnLoc[client] = NULL_VECTOR;
ztele_spawned[client] = false;
ztele_countdown[client] = -1;
ztele_count[client] = 0;
bufferLoc[client] = NULL_VECTOR;
bufferLocSaved[client] = false;
// Stop any cooldown or teleportation in progress.
if (ztele_countdown_timer[client] != INVALID_HANDLE)
{
KillTimer(ztele_countdown_timer[client]);
ztele_countdown_timer[client] = INVALID_HANDLE;
}
if (ztele_cooldown_timer[client] != INVALID_HANDLE)
{
KillTimer(ztele_cooldown_timer[client]);
ztele_cooldown_timer[client] = INVALID_HANDLE;
}
}
}
ZTeleResetClient(client, bool:soft_reset = false)
{
if (!soft_reset)
{
spawnLoc[client] = NULL_VECTOR;
ztele_spawned[client] = false;
}
ztele_countdown[client] = -1;
ztele_count[client] = 0;
// Stop any cooldown or teleportation in progress.
if (ztele_countdown_timer[client] != INVALID_HANDLE)
{
KillTimer(ztele_countdown_timer[client]);
ztele_countdown_timer[client] = INVALID_HANDLE;
}
if (ztele_cooldown_timer[client] != INVALID_HANDLE)
{
KillTimer(ztele_cooldown_timer[client]);
ztele_cooldown_timer[client] = INVALID_HANDLE;
}
}
ZTeleClientSpawned(client)
{
if (IsFakeClient(client))
{
return;
}
ZTeleResetClient(client, true);
// Store location if not already stored.
if (!ztele_spawned[client])
{
GetClientAbsOrigin(client, spawnLoc[client]);
}
}
TeleportOnClientInfected(client)
{
ztele_count[client] = 0;
AbortTeleport(client);
}
public Action:Event_TeleporterStartup(Handle:timer)
{
ztele_online = true;
ztele_startup_timer = INVALID_HANDLE;
}
public Action:Event_TeleportCountdown(Handle:timer, any:client)
{
ztele_countdown[client]--;
if (ztele_countdown[client] <= 0)
{
KillTimer(ztele_countdown_timer[client]);
ztele_countdown_timer[client] = INVALID_HANDLE;
// Do teleport.
TeleportClient(client, true);
}
else if ((ztele_countdown[client] % 3) == 0)
{
// Display countdown message.
ZR_PrintToChat(client, "!ztele time left", ztele_countdown[client]);
}
}
public Action:Event_TeleportCooldown(Handle:Timer, any:client)
{
ztele_countdown[client]--;
if (ztele_countdown[client] <= 0)
{
KillTimer(ztele_cooldown_timer[client]);
ztele_cooldown_timer[client] = INVALID_HANDLE;
}
}
public Action:Command_Teleport(client, argc)
{
decl String:arg1[MAX_TARGET_LENGTH];
decl String:target_name_list[192];
decl String:target_name[192];
decl String:client_name[192];
new bool:tn_is_ml;
GetClientName(client, client_name, sizeof(client_name));
if (argc >= 1)
{
GetCmdArg(1, arg1, sizeof(arg1));
new target_list[MAXPLAYERS];
new target_count;
if ((target_count = ProcessTargetString(
arg1,
client,
target_list,
MAXPLAYERS,
COMMAND_FILTER_ALIVE,
target_name_list,
sizeof(target_name_list),
tn_is_ml)) <= 0)
{
ReplyToTargetError(client, target_count);
return Plugin_Handled;
}
for (new i = 0; i < target_count; i++)
{
if (IsPlayerAlive(client))
{
AbortTeleport(target_list[i]);
TeleportClient(target_list[i], true, true);
GetClientName(target_list[i], target_name, sizeof(target_name));
if (LogCheckFlag(LOG_GAME_EVENTS, LOG_MODULE_TELEPORT)) LogMessageFormatted(client, "teleport", "manual teleport", "\"%s\" teleported \"%s\" to spawn.", true, client_name, target_name);
}
}
}
else
{
if (IsPlayerAlive(client))
{
AbortTeleport(client);
TeleportClient(client, true, true);
if (LogCheckFlag(LOG_GAME_EVENTS, LOG_MODULE_TELEPORT)) LogMessageFormatted(client, "teleport", "manual teleport", "\"%s\" self-teleported to spawn.", true, client_name);
}
}
if (tn_is_ml)
{
ShowActivity2(client, "[ZR] ", "%t teleported to spawn.", target_name_list);
}
else
{
ShowActivity2(client, "[ZR] ", "%s teleported to spawn.", target_name);
}
return Plugin_Handled;
}
public Action:Command_TeleSaveLocation(client, argc)
{
new String:target_name[MAX_TARGET_LENGTH];
new String:target_client;
if (argc >= 1)
{
GetCmdArg(1, target_name, sizeof(target_name));
target_client = FindTarget(client, target_name);
}
else
{
target_client = client;
}
if (target_client > 0 && target_client <= MAXPLAYERS)
{
GetClientAbsOrigin(target_client, bufferLoc[client]);
bufferLocSaved[client] = true;
GetClientName(target_client, target_name, sizeof(target_name));
ReplyToCommand(client, "Saved location to %s (x:%f, y:%f, z:%f).", target_name, bufferLoc[client][0], bufferLoc[client][1], bufferLoc[client][2]);
}
else
{
ReplyToCommand(client, "Unable to target %s", target_name);
}
return Plugin_Handled;
}
public Action:Command_TeleportToLocation(client, argc)
{
decl String:client_name[64];
decl String:target_name[64];
new target_client;
new Float:empty_vector[3] = {0.0, 0.0, 0.0};
// Don't teleport if a location isn't saved yet.
if (bufferLocSaved[client])
{
if (argc >= 1)
{
GetCmdArg(1, target_name, sizeof(target_name));
target_client = FindTarget(client, target_name);
}
else
{
target_client = client;
}
if (target_client > 0 && target_client <= MAXPLAYERS)
{
if (client > 0)
{
GetClientName(client, client_name, sizeof(client_name));
}
else
{
client_name = "Console\0";
}
GetClientName(target_client, target_name, sizeof(target_name));
if (IsPlayerAlive(target_client))
{
AbortTeleport(target_client);
TeleportEntity(target_client, bufferLoc[client], NULL_VECTOR, empty_vector);
ZR_PrintToChat(client, "!ztele successful");
if (target_client != client) ZR_PrintToChat(target_client, "!ztele successful");
if (LogCheckFlag(LOG_GAME_EVENTS, LOG_MODULE_TELEPORT)) LogMessageFormatted(client, "teleport", "custom teleport", "\"%s\" teleported \"%s\".", true, client_name, target_name);
}
else
{
ReplyToCommand(client, "Player \"%s\" is dead. Only alive players can be teleported.", target_name);
}
}
else
{
ReplyToCommand(client, "Unable to target \"%s\"", target_name);
}
}
else
{
ReplyToCommand(client, "Location not set.");
}
return Plugin_Handled;
}
public Action:Command_TeleportAbort(client, argc)
{
new String:arg1[MAX_TARGET_LENGTH];
new String:target_name[MAX_TARGET_LENGTH];
new bool:tn_is_ml;
if (argc >= 1)
{
GetCmdArg(1, arg1, sizeof(arg1));
new target_list[MAXPLAYERS];
new target_count;
if ((target_count = ProcessTargetString(
arg1,
client,
target_list,
MAXPLAYERS,
COMMAND_FILTER_ALIVE,
target_name,
sizeof(target_name),
tn_is_ml)) <= 0)
{
ReplyToTargetError(client, target_count);
return Plugin_Handled;
}
for (new i = 0; i < target_count; i++)
{
AbortTeleport(target_list[i]);
LogAction(client, target_list[i], "%L aborted teleport on %L.", client, target_list[i]);
}
}
else
{
AbortTeleport(client);
GetClientName(client, target_name, sizeof(target_name));
LogAction(client, client, "[ZR] Player %s teleported %s to spawn.", target_name);
}
if (tn_is_ml)
{
ShowActivity2(client, "[ZR] ", "Aborted teleport and cooldown on %t.", target_name);
}
else
{
ShowActivity2(client, "[ZR] ", "Aborted teleport and cooldown on %s.", target_name);
}
return Plugin_Handled;
}
bool:ZTele(client)
{
// Check if the teleporter is disabled.
new bool:tele = GetConVarBool(g_hCvarsList[CVAR_ZTELE]);
if (!tele)
{
ZR_PrintToChat(client, "Feature is disabled");
return false;
}
// Check if the teleporter is online.
if (!ztele_online)
{
ZR_PrintToChat(client, "!ztele offline");
return false;
}
// Check if the player is alive and is not a spectactor.
new team = GetClientTeam(client);
if (!IsPlayerAlive(client) || (team != CS_TEAM_T && team != CS_TEAM_CT))
{
ZR_PrintToChat(client, "Must be alive");
return false;
}
// Check if there's already a teleport in process.
if (ztele_countdown_timer[client] != INVALID_HANDLE)
{
ZR_PrintToChat(client, "!ztele in progress");
return false;
}
// Check if the cooldown isn't done yet.
if (ztele_cooldown_timer[client] != INVALID_HANDLE)
{
ZR_PrintToChat(client, "!ztele cooldown");
return false;
}
// Check limits.
if (InfectIsClientHuman(client))
{
new human_limit = GetConVarInt(g_hCvarsList[CVAR_ZTELE_HUMAN_LIMIT]);
new bool:tele_humans;
if (human_limit == 0)
{
tele_humans = false;
}
else
{
tele_humans = true;
}
if (!tele_humans && g_bZombieSpawned)
{
ZR_PrintToChat(client, "!ztele humans restricted");
return false;
}
if (human_limit > 0 && (ztele_count[client] >= human_limit))
{
ZR_PrintToChat(client, "!ztele limit reached");
return false;
}
}
else
{
new zombie_limit = GetConVarInt(g_hCvarsList[CVAR_ZTELE_ZOMBIE_LIMIT]);
new bool:tele_zombies;
if (zombie_limit == 0)
{
tele_zombies = false;
}
else
{
tele_zombies = true;
}
if (!tele_zombies)
{
ZR_PrintToChat(client, "!ztele zombies restricted");
return false;
}
if (zombie_limit > 0 && (ztele_count[client] >= zombie_limit))
{
ZR_PrintToChat(client, "!ztele limit reached");
return false;
}
}
TeleportClient(client);
return true;
}
/*
* Note: free_tele only works if no_delay is true.
*/
TeleportClient(client, bool:no_delay = false, bool:free_tele = false, bool:no_cooldown = false)
{
new teleports_left;
new bool:teleports_unlimited = false;
new Float:empty_vector[3] = {0.0, 0.0, 0.0};
if (InfectIsClientHuman(client))
{
new human_delay = GetConVarInt(g_hCvarsList[CVAR_ZTELE_HUMAN_DELAY]);
new human_limit = GetConVarInt(g_hCvarsList[CVAR_ZTELE_HUMAN_LIMIT]);
if (human_delay > 0)
{
ztele_countdown[client] = human_delay;
}
else
{
no_delay = true;
}
if (human_limit > 0)
{
teleports_left = human_limit - ztele_count[client] - 1;
}
else
{
teleports_unlimited = true;
}
}
else
{
new zombie_delay = GetConVarInt(g_hCvarsList[CVAR_ZTELE_ZOMBIE_DELAY]);
new zombie_limit = GetConVarInt(g_hCvarsList[CVAR_ZTELE_ZOMBIE_LIMIT]);
if (zombie_delay > 0)
{
ztele_countdown[client] = zombie_delay;
}
else
{
no_delay = true;
}
if (zombie_limit > 0)
{
teleports_left = zombie_limit - ztele_count[client] - 1;
}
else
{
teleports_unlimited = true;
}
}
if (no_delay)
{
ztele_countdown[client] = -1;
if (!free_tele) ztele_count[client]++;
TeleportEntity(client, spawnLoc[client], NULL_VECTOR, empty_vector);
// Create cooldown timer if enabled.
new cooldown = GetConVarInt(g_hCvarsList[CVAR_ZTELE_COOLDOWN]);
if (!no_cooldown && cooldown)
{
ztele_countdown[client] = cooldown;
ztele_cooldown_timer[client] = CreateTimer(1.0, Event_TeleportCooldown, client, TIMER_REPEAT);
}
ZR_PrintToChat(client, "!ztele successful");
if (!teleports_unlimited && !free_tele)
{
ZR_PrintToChat(client, "!ztele amount", teleports_left);
}
}
else
{
ztele_countdown_timer[client] = CreateTimer(1.0, Event_TeleportCountdown, client, TIMER_REPEAT);
if (!teleports_unlimited)
{
ZR_PrintToChat(client, "!ztele amount", teleports_left);
}
}
}
AbortTeleport(client, bool:abort_cooldown = true)
{
ztele_countdown[client] = -1;
// Stop any cooldown or teleportation in progress.
if (ztele_countdown_timer[client] != INVALID_HANDLE)
{
KillTimer(ztele_countdown_timer[client]);
ztele_countdown_timer[client] = INVALID_HANDLE;
}
if (abort_cooldown && ztele_cooldown_timer[client] != INVALID_HANDLE)
{
KillTimer(ztele_cooldown_timer[client]);
ztele_cooldown_timer[client] = INVALID_HANDLE;
}
}

View File

@ -192,7 +192,7 @@ ZHPUpdateHUD(client)
*
* @param timer The timer handle.
* @param client The client index.
*/
*/
public Action:ZHPTimer(Handle:timer, any:client)
{
// If client leaves, then stop timer.

View File

@ -14,6 +14,15 @@
*/
#define GENERAL_DXLEVEL_MIN 90
/**
* @section Conversion factors.
*/
#define CONVERSION_UNITS_TO_FEET 16.000
#define CONVERSION_FEET_TO_UNITS 0.0625
/**
* @endsection
*/
/**
* The DirectX level of a client.
*/
@ -24,6 +33,18 @@ new dxLevel[MAXPLAYERS + 1];
*/
new bool:g_bZombieSpawned;
/**
* Function to convert numbers to defined units.
*
* @param number The number to convert.
* @param conversion The conversion factor to multiply by. (See defines above)
* @return The converted number.
*/
Float:ZRConvertUnitsFloat(Float:number, Float:conversion)
{
return number / conversion;
}
/**
* Create an array populated with eligible clients to be zombie.
*

258
src/zr/ztele.inc Normal file
View File

@ -0,0 +1,258 @@
/*
* ============================================================================
*
* Zombie:Reloaded
*
* File: ztele.inc
* Description: ZTele handle functions.
*
* ============================================================================
*/
/**
* Array to store client's spawn location.
*/
new Float:g_vecZTeleSpawn[MAXPLAYERS + 1][3];
/**
* Array to store client's current location.
*/
new Float:g_vecZTeleOrigin[MAXPLAYERS + 1][3];
/**
* Array to store the tele count of each client.
*/
new g_iZTeleCount[MAXPLAYERS + 1];
/**
* Array for storing ZTele timer handles per client.
*/
new Handle:tZTele[MAXPLAYERS + 1];
/**
* Array to store time left before teleport.
*/
new g_iZTeleTimeLeft[MAXPLAYERS + 1];
/**
* Client is joining the server.
*
* @param client The client index.
*/
ZTeleClientInit(client)
{
// Reset timer handle.
tZTele[client] = INVALID_HANDLE;
}
/**
* Client is spawning into the game.
*
* @param client The client index.
*/
ZTeleOnClientSpawn(client)
{
// Reset tele count.
g_iZTeleCount[client] = 0;
// Get spawn location.
GetClientAbsOrigin(client, g_vecZTeleSpawn[client]);
// If timer is running, kill it.
if (tZTele[client] != INVALID_HANDLE)
{
KillTimer(tZTele[client]);
}
// Reset timer handle.
tZTele[client] = INVALID_HANDLE;
}
/**
* Client has been killed.
*
* @param client The client index.
*/
ZTeleOnClientDeath(client)
{
// If timer is running, kill it.
if (tZTele[client] != INVALID_HANDLE)
{
KillTimer(tZTele[client]);
}
// Reset timer handle.
tZTele[client] = INVALID_HANDLE;
}
/**
* Player has been infected.
*
* @param client The client index.
*/
ZTeleOnClientInfected(client)
{
// If timer is running, kill it.
if (tZTele[client] != INVALID_HANDLE)
{
KillTimer(tZTele[client]);
}
// Reset timer handle.
tZTele[client] = INVALID_HANDLE;
}
/**
* Teleports a client back to spawn if conditions are met.
*
* @param client The client index.
* @return True if teleport was successful, false otherwise.
*/
bool:ZTeleClient(client)
{
// If the client is dead, then stop.
if (!IsPlayerAlive(client))
{
return false;
}
new bool:infected = InfectIsClientInfected(client);
// If zombie cvar is disabled and the client is a zombie, then stop.
new bool:ztelezombie = GetConVarBool(g_hCvarsList[CVAR_ZTELE_ZOMBIE]);
if (infected && !ztelezombie)
{
// Tell client they must be human to use this feature.
ZR_PrintToChat(client, "Must be human");
return false;
}
// If zombie has spawned, get before value, get the after value otherwise.
// If the cvar is disabled and the client is a human, then stop.
new bool:ztelehuman = g_bZombieSpawned ? GetConVarBool(g_hCvarsList[CVAR_ZTELE_HUMAN_AFTER]) : GetConVarBool(g_hCvarsList[CVAR_ZTELE_HUMAN_BEFORE]);
if (!infected && !ztelehuman)
{
// Tell client that feature is restricted at this time.
ZR_PrintToChat(client, "ZTele restricted human");
return false;
}
// If the tele limit has been reached, then stop.
new ztelemax = infected ? GetConVarInt(g_hCvarsList[CVAR_ZTELE_MAX_ZOMBIE]) : GetConVarInt(g_hCvarsList[CVAR_ZTELE_MAX_HUMAN]);
if (g_iZTeleCount[client] >= ztelemax)
{
// Tell client that they have already reached their limit.
ZR_PrintToChat(client, "ZTele max", ztelemax);
return false;
}
// Get current location.
GetClientAbsOrigin(client, g_vecZTeleOrigin[client]);
// If timer is running, kill it.
if (tZTele[client] != INVALID_HANDLE)
{
KillTimer(tZTele[client]);
}
// Set timeleft array to value of respective cvar.
g_iZTeleTimeLeft[client] = infected ? GetConVarInt(g_hCvarsList[CVAR_ZTELE_DELAY_ZOMBIE]) : GetConVarInt(g_hCvarsList[CVAR_ZTELE_DELAY_HUMAN]);
if (g_iZTeleTimeLeft[client] > 0)
{
// Tell client how much time is left until teleport.
ZR_PrintCenterText(client, "ZTele countdown", g_iZTeleTimeLeft[client]);
// Start repeating timer.
tZTele[client] = CreateTimer(1.0, ZTeleTimer, client, TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT);
}
else
{
// Reset timer handle.
tZTele[client] = INVALID_HANDLE;
// Teleport client.
TeleportEntity(client, g_vecZTeleSpawn[client], NULL_VECTOR, NULL_VECTOR);
// Tell client they've been teleported.
ZR_PrintCenterText(client, "ZTele countdown end", g_iZTeleCount[client], ztelemax);
// Increment teleport count.
g_iZTeleCount[client]++;
}
return true;
}
/**
* Timer callback, counts down teleport to the client.
*
* @param timer The timer handle.
* @param client The client index.
*/
public Action:ZTeleTimer(Handle:timer, any:client)
{
// If client leaves, then stop timer.
if (!IsClientInGame(client))
{
return Plugin_Stop;
}
new bool:zteleautocancel = GetConVarBool(g_hCvarsList[CVAR_ZTELE_AUTOCANCEL]);
if (zteleautocancel)
{
// If client has been running around after using ZTele, then stop timer.
new Float:vecClient[3];
GetClientAbsOrigin(client, vecClient);
new Float:distance = GetVectorDistance(vecClient, g_vecZTeleOrigin[client]);
new Float:autocanceldistance = GetConVarFloat(g_hCvarsList[CVAR_ZTELE_AUTOCANCEL_DISTANCE]);
// Convert cvar units
new Float:unitdistance = ZRConvertUnitsFloat(autocanceldistance, CONVERSION_FEET_TO_UNITS);
// Check if distance has been surpassed.
if (distance > unitdistance)
{
// Reset timer handle.
tZTele[client] = INVALID_HANDLE;
// Tell client teleport has been cancelled.
ZR_PrintCenterText(client, "ZTele autocancel centertext");
ZR_PrintToChat(client, "ZTele autocancel text", RoundToNearest(autocanceldistance));
// Stop timer.
return Plugin_Stop;
}
}
// Decrement time left.
g_iZTeleTimeLeft[client]--;
// Tell client how much time is left until teleport.
ZR_PrintCenterText(client, "ZTele countdown", g_iZTeleTimeLeft[client]);
// Time has expired.
if (g_iZTeleTimeLeft[client] <= 0)
{
// Teleport client.
TeleportEntity(client, g_vecZTeleSpawn[client], NULL_VECTOR, NULL_VECTOR);
// Increment teleport count.
g_iZTeleCount[client]++;
// Get max teleports per round.
new ztelemax = InfectIsClientInfected(client) ? GetConVarInt(g_hCvarsList[CVAR_ZTELE_MAX_ZOMBIE]) : GetConVarInt(g_hCvarsList[CVAR_ZTELE_MAX_HUMAN]);
// Tell client spawn protection is over.
ZR_PrintCenterText(client, "ZTele countdown end", g_iZTeleCount[client], ztelemax);
// Clear timer handle.
tZTele[client] = INVALID_HANDLE;
// Stop timer.
return Plugin_Stop;
}
// Allow timer to continue repeating.
return Plugin_Continue;
}