Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- new g_iTimeLimit;
- ConVar g_Cvar_Timelimit;
- int g_iTeamsReady;
- bool g_bTimerSetBack; //i.e have we already changed the var to its default
- public Plugin myinfo =
- {
- name = "TimeLimit Toggle",
- author = "tevo",
- description = "toggles the command mp_timelimit between 0 and the set server time limit",
- version = "0.1",
- url = "http://www.sourcemod.net/"
- };
- public void OnPluginStart()
- {
- g_Cvar_Timelimit = FindConVar("mp_timelimit");
- RegAdminCmd("sm_timeon", Command_TimeOn, ADMFLAG_GENERIC);
- RegAdminCmd("sm_timeoff", Command_TimeOff, ADMFLAG_GENERIC);
- HookEvent("teamplay_round_start", Event_RoundStart);
- HookEvent("tournament_stateupdate", Event_StateUpdate);
- }
- public void OnConfigsExecuted()
- {
- g_bTimerSetBack = false;
- g_iTeamsReady = 0;
- g_iTimeLimit = g_Cvar_Timelimit.IntValue; //stores the timelimit value as loaded in server.cfg file.
- g_Cvar_Timelimit.SetInt(0); //disables timelimit
- }
- public Action Command_TimeOn(int client, int args)
- {
- PrintToServer("Timeon");
- g_Cvar_Timelimit.SetInt(g_iTimeLimit);
- return Plugin_Handled;
- }
- public Action Command_TimeOff(int client, int args)
- {
- PrintToServer("Timeoff");
- g_Cvar_Timelimit.SetInt(0);
- return Plugin_Handled;
- }
- public void Event_StateUpdate(Event event, const char[] name, bool dontBroadcast)
- {
- new iStateUpdate = event.GetBool("readystate");
- if (iStateUpdate == 1)
- {
- g_iTeamsReady++;
- }
- else
- {
- g_iTeamsReady--;
- }
- PrintToServer("TEAMS READY: %d", g_iTeamsReady);
- }
- public void Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
- {
- if ((g_bTimerSetBack == false) && (g_iTeamsReady == 2))
- {
- g_Cvar_Timelimit.SetInt(g_Cvar_Timelimit);
- g_bTimerSetBack = true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement