Added support for a random !ztele.
This commit is contained in:
parent
71d5c297d3
commit
678ad2ef0c
|
@ -89,6 +89,7 @@ public Action:EventRoundStart(Handle:event, const String:name[], bool:dontBroadc
|
||||||
SEffectsOnRoundStart();
|
SEffectsOnRoundStart();
|
||||||
ZSpawnOnRoundStart();
|
ZSpawnOnRoundStart();
|
||||||
VolOnRoundStart();
|
VolOnRoundStart();
|
||||||
|
ZTeleOnRoundStart();
|
||||||
|
|
||||||
// Fire post round_start event.
|
// Fire post round_start event.
|
||||||
//CreateTimer(0.0, EventRoundStartPost);
|
//CreateTimer(0.0, EventRoundStartPost);
|
||||||
|
|
|
@ -34,6 +34,7 @@ Handle ZTeleCvar_MaxZombie;
|
||||||
Handle ZTeleCvar_MaxHuman;
|
Handle ZTeleCvar_MaxHuman;
|
||||||
Handle ZTeleCvar_AutoCancel;
|
Handle ZTeleCvar_AutoCancel;
|
||||||
Handle ZTeleCvar_AutoCancelDistance;
|
Handle ZTeleCvar_AutoCancelDistance;
|
||||||
|
Handle ZTeleCvar_RandomPosition;
|
||||||
|
|
||||||
void ZTele_OnCvarsCreate()
|
void ZTele_OnCvarsCreate()
|
||||||
{
|
{
|
||||||
|
@ -46,6 +47,7 @@ void ZTele_OnCvarsCreate()
|
||||||
ZTeleCvar_MaxHuman = CreateConVar("zr_ztele_max_human", "1", "Max number of times a human is allowed to use ZTele per round. [Dependency: zr_ztele_human_(before)/(after)]");
|
ZTeleCvar_MaxHuman = CreateConVar("zr_ztele_max_human", "1", "Max number of times a human is allowed to use ZTele per round. [Dependency: zr_ztele_human_(before)/(after)]");
|
||||||
ZTeleCvar_AutoCancel = CreateConVar("zr_ztele_autocancel", "1", "Automatically cancel ZTele if player moves out of a set boundary. [Dependency: zr_ztele_(zombie)/(human)[_(before)/(after)]]");
|
ZTeleCvar_AutoCancel = CreateConVar("zr_ztele_autocancel", "1", "Automatically cancel ZTele if player moves out of a set boundary. [Dependency: zr_ztele_(zombie)/(human)[_(before)/(after)]]");
|
||||||
ZTeleCvar_AutoCancelDistance = CreateConVar("zr_ztele_autocancel_distance", "20", "Maximum distance, in feet, player is allowed to travel before teleport is cancelled. [Dependency: zr_ztele_autocancel]");
|
ZTeleCvar_AutoCancelDistance = CreateConVar("zr_ztele_autocancel_distance", "20", "Maximum distance, in feet, player is allowed to travel before teleport is cancelled. [Dependency: zr_ztele_autocancel]");
|
||||||
|
ZTeleCvar_RandomPosition = CreateConVar("zr_ztele_random_position", "0", "Teleport player to the random spawn position, not only his own one.");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZTele_ZombieCanTeleport()
|
bool ZTele_ZombieCanTeleport()
|
||||||
|
@ -92,3 +94,8 @@ float ZTele_GetAutoCancelDistance()
|
||||||
{
|
{
|
||||||
return GetConVarFloat(ZTeleCvar_AutoCancelDistance);
|
return GetConVarFloat(ZTeleCvar_AutoCancelDistance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ZTele_IsRandomPositionEnabled()
|
||||||
|
{
|
||||||
|
return GetConVarBool(ZTeleCvar_RandomPosition);
|
||||||
|
}
|
|
@ -29,6 +29,8 @@
|
||||||
|
|
||||||
#include "zr/ztele/cvars"
|
#include "zr/ztele/cvars"
|
||||||
|
|
||||||
|
#define MAX_PLAYER_SPAWNS 128
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array to store client's spawn location.
|
* Array to store client's spawn location.
|
||||||
*/
|
*/
|
||||||
|
@ -54,6 +56,9 @@ Handle tZTele[MAXPLAYERS + 1];
|
||||||
*/
|
*/
|
||||||
int g_iZTeleTimeLeft[MAXPLAYERS + 1];
|
int g_iZTeleTimeLeft[MAXPLAYERS + 1];
|
||||||
|
|
||||||
|
float g_vecZTeleSpawnPoints[MAX_PLAYER_SPAWNS][3];
|
||||||
|
int g_iZTeleSpawnPointsCount = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create commands specific to ZTele.
|
* Create commands specific to ZTele.
|
||||||
*/
|
*/
|
||||||
|
@ -66,6 +71,36 @@ void ZTele_OnCommandsCreate()
|
||||||
RegConsoleCmd("zr_ztele_force", ZTele_ForceCommand, "Force ZTele on a client. Usage: zr_ztele_force <client>");
|
RegConsoleCmd("zr_ztele_force", ZTele_ForceCommand, "Force ZTele on a client. Usage: zr_ztele_force <client>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ZTeleOnRoundStart()
|
||||||
|
{
|
||||||
|
char classname[64];
|
||||||
|
int maxentities = GetMaxEntities();
|
||||||
|
|
||||||
|
g_iZTeleSpawnPointsCount = 0;
|
||||||
|
|
||||||
|
for (int i = MaxClients; i <= maxentities; i++)
|
||||||
|
{
|
||||||
|
if (!IsValidEdict(i))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_iZTeleSpawnPointsCount >= MAX_PLAYER_SPAWNS)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
GetEdictClassname(i, classname, sizeof(classname));
|
||||||
|
|
||||||
|
if (StrEqual(classname, "info_player_terrorist", true) || StrEqual(classname, "info_player_counterterrorist", true))
|
||||||
|
{
|
||||||
|
GetEntPropVector(i, Prop_Send, "m_vecOrigin", g_vecZTeleSpawnPoints[g_iZTeleSpawnPointsCount]);
|
||||||
|
|
||||||
|
g_iZTeleSpawnPointsCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Client is joining the server.
|
* Client is joining the server.
|
||||||
*
|
*
|
||||||
|
@ -215,7 +250,26 @@ bool ZTeleClient(int client, bool force = false)
|
||||||
void ZTele_TeleportClient(int client)
|
void ZTele_TeleportClient(int client)
|
||||||
{
|
{
|
||||||
// Teleport client.
|
// Teleport client.
|
||||||
|
CreateTimer(0.0, Timer_PerformZtele, client);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action Timer_PerformZtele(Handle timer, any data)
|
||||||
|
{
|
||||||
|
int client = view_as<int>(data);
|
||||||
|
if (!IsClientInGame(client))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ZTele_IsRandomPositionEnabled())
|
||||||
|
{
|
||||||
|
int select = Math_GetRandomInt(0, g_iZTeleSpawnPointsCount - 1);
|
||||||
|
TeleportEntity(client, g_vecZTeleSpawnPoints[select], NULL_VECTOR, view_as<float>({0.0, 0.0, 0.0}));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
TeleportEntity(client, g_vecZTeleSpawn[client], NULL_VECTOR, view_as<float>({0.0, 0.0, 0.0}));
|
TeleportEntity(client, g_vecZTeleSpawn[client], NULL_VECTOR, view_as<float>({0.0, 0.0, 0.0}));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user