Quote:
Originally Posted by Lazyneer
[...] the auto restart doesnt work right. It ends the round as soon someone dies, connects or disconnects, whether team RED is empty or not.
|
Copied the code after the edits? It earlier had an incorrect test that checks that the team size was greater than zero instead of equal to it, which would explain why the round ends prematurely. Oops.
If that's not it, it sounds like some weird SourcePython-specific quirk (I know some Python, but I have no idea how SourcePython handles things), or maybe the events aren't being handled in the correct order. The hooked
player_team event in the Python code suggests the round would end if any player joins any non-RED team including spectate.
Could check if the round is running (see
EmptyRed function below); no idea if that'd help any though.
Code:
#include <sourcemod>
#include <tf2_stocks>
#pragma semicolon 1
#pragma newdecls required
public Plugin myinfo = {
name = "Omniwolf's Auto Restart Zombies",
author = "Omniwolf",
description = "Auto Restarts when RED is empty",
version = "1.0",
url = ""
};
public void OnPluginStart() {
HookEvent("player_death", OnPlayerDeath, EventHookMode_PostNoCopy);
HookEvent("player_team", OnPlayerTeam, EventHookMode_PostNoCopy);
}
public void OnPlayerDeath(Event event, const char[] name, bool dontBroadcast) {
EmptyRed();
}
public void OnPlayerTeam(Event event, const char[] name, bool dontBroadcast) {
EmptyRed();
}
void EmptyRed() {
if (GameRules_GetRoundState() == RoundState_RoundRunning && GetTeamClientCount(view_as<int>(TFTeam_Red)) == 0) {
CreateTimer(1.0, OnRedEmpty, _, TIMER_FLAG_NO_MAPCHANGE);
}
}
public Action OnRedEmpty(Handle timer, any data) {
ServerCommand("sm_settime 1; sm_hsay Round Over");
return Plugin_Handled;
}
I'll revisit this a bit later in the day if it remains unfulfilled.
__________________