Hi. I don't think TF2's handling of rounds is that great when it comes to 5CP and attack defense.
I'm trying to make a plugin that works like this:
If it's a CP_ map the plugin runs, if not , it doesn't run.
When 60 seconds remains of maptime, it sets mp_timelimit to "" (infinite) and the mp_maxrounds to +1 of the total rounds played.
Right now I'm not sure what it's called what I'm looking for. I also haven't been able to figure out how to get the long value from the "tf_map_time_remaining" hook.
Below is the code so far.
Code:
#include <sourcemod>
#include <tf2>
int RoundCount = 0;
char mapname[80];
public void OnMapStart(){
GetCurrentMap(mapname, 80);
RoundCount = 0;
public void OnPluginStart(){
//Not sure how/where to make the plugin terminate if the map doesn't start with a cp_
if (StrContains(mapname, "cp_", false) != -1) //if the string doesn't contain cp_
{
return Plugin_Handled;
}
else{
HookEvent("tf_map_time_remaining", Event_Map_Time_Remaining);
HookEvent("teamplay_round_start", Event_RoundStart);
}
}
public Action FixTime() //Does the server commands, setting timelimit to blank (infinite) and the maxrounds to 1 more than currently played
{
ServerCommand("mp_timelimit \"\""); //sets timelimit to blank
ServerCommand("mp_maxrounds %s", RoundCount+1); //Sets the max rounds to one more than rounds played, so map ends when round is over
return Plugin_Handled;
}
public Action Event_Map_Time_Remaining(Event event, const char[] name, bool dontBroadcast) //Triggers when a map isn't over and triggers the event that prevents the map from ending on map timer, rather than round timer
{
//not sure of the right method to get the time remaining when there's 60 seconds left. tf_map_time_remaining contains a long value called seconds
new seconds = (event handle).GetInt("seconds");
if (seconds == 60)
{
FixTime()
}
}
public Action Event_RoundStart(Event event, const char[] name, bool dontBroadcast) //Counts each round played
{
RoundCount++;
return Plugin_Continue;
}