Improved teleporter: Per client custom buffers, reset buffers on round start (CVAR), made teleabort chat trigger. Blocked teleport on dead players. Changed ztele to tele in CVAR names.

This commit is contained in:
richard 2009-01-13 23:24:10 +01:00
parent 03c2a00d22
commit 525d25efd4
6 changed files with 72 additions and 44 deletions

View File

@ -1,3 +1,10 @@
2009.01.13 - 2.5.1.19
* Added per-client teleport buffers instead of one common (still only for admins).
* Made zr_tele_reset_buffers CVAR for resetting custom saved locations on round start. Abuse protection.
* Fixed spectactors able to teleport, using admin commands.
* Added !teleabort chat trigger. Doesn't abort cooldown.
* Changed ztele to tele in CVAR names.
2008.12.27 - 2.5.1.18
* Made zr_suicide_world_damage CVAR for respawning as zombie if a zombie was killed by the world.
* Removed spawn protection on respawned zombies.

View File

@ -15,7 +15,7 @@
#undef REQUIRE_PLUGIN
#include <market>
#define VERSION "2.5.1.18"
#define VERSION "2.5.1.19"
#include "zr/zombiereloaded"
#include "zr/global"

View File

@ -66,6 +66,7 @@ enum ZRSettings
Handle:CVAR_ZTELE_HUMAN_LIMIT,
Handle:CVAR_ZTELE_ZOMBIE_DELAY,
Handle:CVAR_ZTELE_ZOMBIE_LIMIT,
Handle:CVAR_ZTELE_RESET_BUFFERS,
Handle:CVAR_ZSTUCK,
Handle:CVAR_ZHP,
Handle:CVAR_ZHP_DEFAULT,
@ -137,13 +138,14 @@ CreateCvars()
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", "Allow players to use the teleporter to get to spawn. (0: Disable)");
gCvars[CVAR_ZTELE_STARTUP_DELAY] = CreateConVar("zr_ztele_startup_delay", "40", "Number of seconds to wait before the teleporter is enabled (0: Always enabled)");
gCvars[CVAR_ZTELE_COOLDOWN] = CreateConVar("zr_ztele_cooldown", "30", "Number of seconds to wait before the teleporter can be used again, after a teleport. (0: Disable)");
gCvars[CVAR_ZTELE_HUMAN_DELAY] = CreateConVar("zr_ztele_human_delay", "20", "Teleport delay for humans. (0: No delay)");
gCvars[CVAR_ZTELE_HUMAN_LIMIT] = CreateConVar("zr_ztele_human_limit", "3", "Maximum number of teleports humans can do. (0: Humans can't use the teleporter. -1: Unlimited)");
gCvars[CVAR_ZTELE_ZOMBIE_DELAY] = CreateConVar("zr_ztele_zombie_delay", "0", "Teleport delay for zombies. (0: No delay)");
gCvars[CVAR_ZTELE_ZOMBIE_LIMIT] = CreateConVar("zr_ztele_zombie_limit", "8", "Maximum number of teleports zombies can do. (0: Zombies can't use the teleporter. -1: Unlimited)");
gCvars[CVAR_ZTELE] = CreateConVar("zr_tele", "1", "Allow players to use the teleporter to get to spawn. (0: Disable)");
gCvars[CVAR_ZTELE_STARTUP_DELAY] = CreateConVar("zr_tele_startup_delay", "30", "Number of seconds to wait before the teleporter is enabled (0: Always enabled)");
gCvars[CVAR_ZTELE_COOLDOWN] = CreateConVar("zr_tele_cooldown", "20", "Number of seconds to wait before the teleporter can be used again, after a teleport. (0: Disable)");
gCvars[CVAR_ZTELE_HUMAN_DELAY] = CreateConVar("zr_tele_human_delay", "10", "Teleport delay for humans. (0: No delay)");
gCvars[CVAR_ZTELE_HUMAN_LIMIT] = CreateConVar("zr_tele_human_limit", "3", "Maximum number of teleports humans can do. (0: Humans can't use the teleporter. -1: Unlimited)");
gCvars[CVAR_ZTELE_ZOMBIE_DELAY] = CreateConVar("zr_tele_zombie_delay", "0", "Teleport delay for zombies. (0: No delay)");
gCvars[CVAR_ZTELE_ZOMBIE_LIMIT] = CreateConVar("zr_tele_zombie_limit", "8", "Maximum number of teleports zombies can do. (0: Zombies can't use the teleporter. -1: Unlimited)");
gCvars[CVAR_ZTELE_RESET_BUFFERS] = CreateConVar("zr_tele_reset_buffers", "1", "Reset custom saved teleport locations on each round start. (0: Disable)");
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)");

View File

@ -53,6 +53,11 @@ public Action:SayCommand(client, argc)
ZTeleClientCheck(client);
}
else if (StrEqual(args, "!teleabort", false))
{
AbortTeleport(client, false);
}
else if (StrEqual(args, "!zstuck", false))
{
ZStuck(client);

View File

@ -40,6 +40,8 @@ ZTeleReset()
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)
@ -110,14 +112,6 @@ public Action:Event_TeleportCountdown(Handle:timer, any:client)
// Do teleport.
TeleportClient(client, true);
// Create cooldown timer if enabled.
new cooldown = GetConVarInt(gCvars[CVAR_ZTELE_COOLDOWN]);
if (cooldown)
{
ztele_countdown[client] = cooldown;
ztele_cooldown_timer[client] = CreateTimer(1.0, Event_TeleportCooldown, client, TIMER_REPEAT);
}
}
else if ((ztele_countdown[client] % 3) == 0)
{
@ -164,18 +158,23 @@ public Action:Command_Teleport(client, argc)
for (new i = 0; i < target_count; i++)
{
AbortTeleport(target_list[i]);
TeleportClient(target_list[i], true, true);
LogAction(client, target_list[i], "\"%L\" teleported \"%L\" to spawn", client, target_list[i]);
if (IsPlayerAlive(client))
{
AbortTeleport(target_list[i]);
TeleportClient(target_list[i], true, true);
LogAction(client, target_list[i], "\"%L\" teleported \"%L\" to spawn", client, target_list[i]);
}
}
}
else
{
AbortTeleport(client);
TeleportClient(client, true, true);
GetClientName(client, target_name, sizeof(target_name));
LogAction(client, client, "[ZR] Player %s teleported %s to spawn.", target_name, target_name);
if (IsPlayerAlive(client))
{
AbortTeleport(client);
TeleportClient(client, true, true);
GetClientName(client, target_name, sizeof(target_name));
LogAction(client, client, "[ZR] Player %s teleported %s to spawn.", target_name, target_name);
}
}
if (tn_is_ml)
@ -207,10 +206,10 @@ public Action:Command_TeleSaveLocation(client, argc)
if (target_client > 0 && target_client <= MAXPLAYERS)
{
GetClientAbsOrigin(target_client, bufferLoc);
bufferLocSaved = true;
GetClientAbsOrigin(target_client, bufferLoc[client]);
bufferLocSaved[client] = true;
GetClientName(target_client, target_name, sizeof(target_name));
ReplyToCommand(client, "Saved location to %s (%d, %d, %d).", target_name, bufferLoc[0], bufferLoc[1], bufferLoc[2]);
ReplyToCommand(client, "Saved location to %s (%d, %d, %d).", target_name, bufferLoc[client][0], bufferLoc[client][1], bufferLoc[client][2]);
}
else
{
@ -227,7 +226,7 @@ public Action:Command_TeleportToLocation(client, argc)
new Float:empty_vector[3] = {0.0, 0.0, 0.0};
// Don't teleport if a location isn't saved yet.
if (bufferLocSaved)
if (bufferLocSaved[client])
{
if (argc >= 1)
{
@ -240,10 +239,14 @@ public Action:Command_TeleportToLocation(client, argc)
}
if (target_client > 0 && target_client <= MAXPLAYERS)
{
AbortTeleport(target_client);
TeleportEntity(target_client, bufferLoc, NULL_VECTOR, empty_vector);
ZR_PrintToChat(client, "!ztele successful");
if (target_client != client) ZR_PrintToChat(target_client, "!ztele successful");
if (IsPlayerAlive(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");
}
}
else
{
@ -311,6 +314,7 @@ public Action:Command_TeleportAbort(client, argc)
ZTeleClientCheck(client)
{
// Check if the teleporter is disabled.
new bool:tele = GetConVarBool(gCvars[CVAR_ZTELE]);
if (!tele)
{
@ -318,19 +322,21 @@ ZTeleClientCheck(client)
return;
}
new team = GetClientTeam(client);
if (team != CS_TEAM_T && team != CS_TEAM_CT)
{
ZR_PrintToChat(client, "Must be alive");
return;
}
// Check if the teleporter is online.
if (!ztele_online)
{
ZR_PrintToChat(client, "!ztele offline");
return;
}
// 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;
}
// Check if there's already a teleport in process.
if (ztele_countdown_timer[client] != INVALID_HANDLE)
{
@ -403,7 +409,7 @@ ZTeleClientCheck(client)
/*
* Note: free_tele only works if no_delay is true.
*/
TeleportClient(client, bool:no_delay = false, bool:free_tele = false)
TeleportClient(client, bool:no_delay = false, bool:free_tele = false, bool:no_cooldown = false)
{
new teleports_left;
new bool:teleports_unlimited = false;
@ -461,6 +467,14 @@ TeleportClient(client, bool:no_delay = false, bool:free_tele = false)
TeleportEntity(client, spawnLoc[client], NULL_VECTOR, empty_vector);
// Create cooldown timer if enabled.
new cooldown = GetConVarInt(gCvars[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)
{
@ -477,7 +491,7 @@ TeleportClient(client, bool:no_delay = false, bool:free_tele = false)
}
}
AbortTeleport(client)
AbortTeleport(client, bool:abort_cooldown = true)
{
ztele_countdown[client] = -1;
@ -487,7 +501,7 @@ AbortTeleport(client)
KillTimer(ztele_countdown_timer[client]);
ztele_countdown_timer[client] = INVALID_HANDLE;
}
if (ztele_cooldown_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

@ -53,9 +53,9 @@ new pNextClass[MAXPLAYERS+1];
new protCount[MAXPLAYERS+1];
new Float:spawnLoc[MAXPLAYERS + 1][3];
new Float:bufferLoc[3];
new Float:bufferLoc[MAXPLAYERS + 1][3];
new bool:ztele_spawned[MAXPLAYERS + 1] = {false, ...};
new bool:bufferLocSaved = false;
new bool:bufferLocSaved[MAXPLAYERS + 1] = {false, ...};
new ztele_countdown[MAXPLAYERS + 1] = {-1, ...};
new ztele_count[MAXPLAYERS + 1];
new bool:ztele_online = false;