ZSpawn: Add auto zspawn.
This commit is contained in:
parent
177d9217b8
commit
6334246ced
|
@ -719,6 +719,10 @@ zr_vol_trigger_interval "1.0"
|
|||
// Default: "1"
|
||||
zr_zspawn "1"
|
||||
|
||||
// Should zspawn spawn joining players?
|
||||
// Default: "1"
|
||||
zr_zspawn_auto "1"
|
||||
|
||||
// Override spawn team when spawning by means of ZSpawn.
|
||||
// Default: "1"
|
||||
zr_zspawn_team_override "1"
|
||||
|
|
|
@ -719,6 +719,10 @@ zr_vol_trigger_interval "1.0"
|
|||
// Default: "1"
|
||||
zr_zspawn "1"
|
||||
|
||||
// Should zspawn spawn joining players?
|
||||
// Default: "1"
|
||||
zr_zspawn_auto "1"
|
||||
|
||||
// Override spawn team when spawning by means of ZSpawn.
|
||||
// Default: "1"
|
||||
zr_zspawn_team_override "1"
|
||||
|
|
|
@ -174,6 +174,7 @@ enum CvarsList
|
|||
Handle:CVAR_VOL_UPDATE_INTERVAL,
|
||||
Handle:CVAR_VOL_TRIGGER_INTERVAL,
|
||||
Handle:CVAR_ZSPAWN,
|
||||
Handle:CVAR_ZSPAWN_AUTO,
|
||||
Handle:CVAR_ZSPAWN_TEAM_OVERRIDE,
|
||||
Handle:CVAR_ZSPAWN_TEAM_ZOMBIE,
|
||||
Handle:CVAR_ZSPAWN_BLOCK_REJOIN,
|
||||
|
@ -498,6 +499,7 @@ CvarsCreate()
|
|||
// ZSpawn (module)
|
||||
// ===========================
|
||||
g_hCvarsList[CVAR_ZSPAWN] = CreateConVar("zr_zspawn", "1", "Allow players to spawn into the game late.");
|
||||
g_hCvarsList[CVAR_ZSPAWN_AUTO] = CreateConVar("zr_zspawn_auto", "1", "Should zspawn spawn joining players?");
|
||||
|
||||
g_hCvarsList[CVAR_ZSPAWN_TEAM_OVERRIDE] = CreateConVar("zr_zspawn_team_override", "1", "Override spawn team when spawning by means of ZSpawn.");
|
||||
g_hCvarsList[CVAR_ZSPAWN_TEAM_ZOMBIE] = CreateConVar("zr_zspawn_team_zombie", "0", "Spawn player on zombie team when spawning by means of ZSpawn. [Dependency: zr_zspawn_team_override | Override: zr_respawn_team_zombie]");
|
||||
|
|
|
@ -54,6 +54,9 @@ EventHook(bool:unhook = false)
|
|||
UnhookEvent("player_death", EventPlayerDeath);
|
||||
UnhookEvent("player_jump", EventPlayerJump);
|
||||
|
||||
// Unhook all listeners.
|
||||
RemoveCommandListener(CommandPlayerClass, "joinclass");
|
||||
|
||||
// Stop after unhooking events.
|
||||
return;
|
||||
}
|
||||
|
@ -67,6 +70,9 @@ EventHook(bool:unhook = false)
|
|||
HookEvent("player_hurt", EventPlayerHurt);
|
||||
HookEvent("player_death", EventPlayerDeath);
|
||||
HookEvent("player_jump", EventPlayerJump);
|
||||
|
||||
// Hook all listeners used by plugin.
|
||||
AddCommandListener(CommandPlayerClass, "joinclass");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -148,6 +154,12 @@ public Action:EventPlayerTeam(Handle:event, const String:name[], bool:dontBroadc
|
|||
InfectOnClientTeam(index, team);
|
||||
ImmunityOnClientTeam(index);
|
||||
|
||||
// Bots dont call `joinclass`. So call here.
|
||||
if (IsFakeClient(index))
|
||||
{
|
||||
ZSpawnOnClientTeam(index);
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
|
@ -317,3 +329,20 @@ public Action:EventPlayerJumpPost(Handle:timer, any:client)
|
|||
// Forward event to modules.
|
||||
JumpBoostOnClientJumpPost(client);
|
||||
}
|
||||
|
||||
/**
|
||||
* Command callback (joinclass)
|
||||
* Client is joining a class.
|
||||
*
|
||||
* @param client The client.
|
||||
* @param command The command performed.
|
||||
* @param argc The amount of arguments.
|
||||
*/
|
||||
public Action:CommandPlayerClass(int client, const char[] command, int argc)
|
||||
{
|
||||
if (IsFakeClient(client))
|
||||
return;
|
||||
|
||||
// Forward event to modules.
|
||||
ZSpawnOnClientTeam(client);
|
||||
}
|
||||
|
|
|
@ -115,6 +115,31 @@ ZSpawnOnClientDeath(client)
|
|||
// Add client to the SteamID cache.
|
||||
SteamidCacheAddClient(g_hZSpawnSteamIDCache, client);
|
||||
}
|
||||
/**
|
||||
* Client is joining a team/class.
|
||||
*
|
||||
* @param client The client index.
|
||||
*/
|
||||
ZSpawnOnClientTeam(client)
|
||||
{
|
||||
// Is auto zspawn enabled and is the client death?
|
||||
new bool:autozspawn = GetConVarBool(g_hCvarsList[CVAR_ZSPAWN_AUTO]);
|
||||
if (autozspawn && !IsPlayerAlive(client))
|
||||
{
|
||||
// Get our zspawn condition.
|
||||
new ZSpawnCondition:condition = GetZSpawnCondition();
|
||||
|
||||
switch(condition)
|
||||
{
|
||||
case ZSpawn_Human, ZSpawn_Zombie:
|
||||
{
|
||||
// Respawn client.
|
||||
CS_RespawnPlayer(client);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Client is spawning into the game.
|
||||
|
|
Loading…
Reference in New Issue
Block a user