Last active
September 12, 2016 20:54
-
-
Save roflmuffin/bed001ee2d12cb49deff to your computer and use it in GitHub Desktop.
Block command if time left in round is less than 5 seconds. (Sourcemod, CSGO)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sdktools> | |
#pragma newdecls required | |
#pragma semicolon 1 | |
#include <sourcemod> | |
int g_roundStartedTime = -1; | |
public void OnPluginStart() | |
{ | |
RegConsoleCmd("test_command", Command_Test); | |
HookEvent("round_start", Event_RoundStart); | |
} | |
public Action Event_RoundStart(Handle event, const char[] name, bool dontBroadcast) { | |
g_roundStartedTime = GetTime(); | |
} | |
public int GetTotalRoundTime() { | |
return GameRules_GetProp("m_iRoundTime"); | |
} | |
public int GetCurrentRoundTime() { | |
Handle h_freezeTime = FindConVar("mp_freezetime"); // Freezetime Handle | |
int freezeTime = GetConVarInt(h_freezeTime); // Freezetime in seconds (5 by default) | |
return (GetTime() - g_roundStartedTime) - freezeTime; | |
} | |
public Action Command_Test(int client, int args) { | |
if (GetTotalRoundTime() - GetCurrentRoundTime() <= 5) { | |
ReplyToCommand(client, "Its too late to use this command.."); | |
return Plugin_Handled; | |
} else { | |
// Do command stuff. | |
return Plugin_Handled; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment