ZSpawn: Add auto zspawn.

This commit is contained in:
2019-03-10 19:59:20 +01:00
parent 177d9217b8
commit 6334246ced
5 changed files with 64 additions and 0 deletions

View File

@ -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);
}