#pragma semicolon 1
#include <sourcemod>
#include <sdktools_functions>
#undef REQUIRE_PLUGIN
#include <zombiereloaded>
#define PLUGIN_NAME "ZR Tele Infected"
#define PLUGIN_VERSION "1.1.1"
new Handle:Spawn_Origins;
new Handle:Spawn_Angles;
new Float:OriginBuffer[3];
new Float:AnglesBuffer[3];
new SpawnCount;
public Plugin:myinfo =
{
name = PLUGIN_NAME,
author = "GoD-Tony",
description = "Teleports all infected players back to spawn",
version = PLUGIN_VERSION,
url = "http://www.sourcemod.net/"
};
public OnPluginStart()
{
CreateConVar("zr_teleinfected_version", PLUGIN_VERSION, PLUGIN_NAME, FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
HookEvent("player_death", Event_PlayerDeath);
Spawn_Origins = CreateArray(3);
Spawn_Angles = CreateArray(3);
}
public OnConfigsExecuted()
{
/* Clear our arrays for the current map */
ClearArray(Spawn_Origins);
ClearArray(Spawn_Angles);
SpawnCount = 0;
/* Store all of the spawnpoints */
decl String:sClassName[30];
for (new iEntity = GetEntityCount() - 1; iEntity > MaxClients; --iEntity)
{
if (IsValidEntity(iEntity))
{
GetEdictClassname(iEntity, sClassName, sizeof(sClassName));
if (strcmp("info_player_terrorist", sClassName) == 0 || strcmp("info_player_counterterrorist", sClassName) == 0)
{
GetEntPropVector(iEntity, Prop_Send, "m_vecOrigin", OriginBuffer);
PushArrayArray(Spawn_Origins, OriginBuffer);
GetEntPropVector(iEntity, Prop_Send, "m_angRotation", AnglesBuffer);
PushArrayArray(Spawn_Angles, AnglesBuffer);
++SpawnCount;
}
}
}
if (SpawnCount == 0) SetFailState("Spawn points for map not found ('info_player_terrorist' & 'info_player_counterterrorist')!");
}
public ZR_OnClientInfected(client, attacker, bool:motherInfect, bool:respawnOverride, bool:respawn)
{
/* There is already a Cvar for mother zombies */
if (!motherInfect) TelePlayer(client);
}
public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
/* Adds support for older versions of ZR */
decl String:weapon[23];
GetEventString(event, "weapon", weapon, sizeof(weapon));
if (strcmp("zombie_claws_of_death", weapon) == 0) TelePlayer(GetClientOfUserId(GetEventInt(event, "userid")));
}
TelePlayer(client)
{
/* Teleport the player to a random spawnpoint */
decl iSpawn;
GetArrayArray(Spawn_Origins, iSpawn = RoundToCeil(float(iSpawn = GetURandomInt() ? iSpawn:1) / (2147483647.0 / float(SpawnCount))) - 1, OriginBuffer);
GetArrayArray(Spawn_Angles, iSpawn, AnglesBuffer);
TeleportEntity(client, OriginBuffer, AnglesBuffer, NULL_VECTOR);
}