N
nightcore
В общем, не могу сообразить как заставить автоматически снимать матч с паузы через 2 минуты после того, как админ поставил.
C-подобный:
#include <sourcemod>
#include <sdktools>
#pragma semicolon 1
#pragma tabsize 0
new bool:allowed = false;
new Handle:g_PauseTimer[MAXPLAYERS+1] = INVALID_HANDLE;
#define PLUGIN_VERSION "1.0"
#define TIMER_LIMIT 120.0
public Plugin:myinfo =
{
name = "Server Pause",
author = "madwayz x hlmod",
description = "Enable/Disable pause on server",
version = PLUGIN_VERSION,
url = ""
};
public OnPluginStart()
{
RegAdminCmd("sm_pause", pause_on, ADMFLAG_GENERIC, "Pause the match");
RegAdminCmd("sm_unpause", pause_off, ADMFLAG_GENERIC, "Unpause the match");
}
public Action:pause_on(client, args)
{
decl String:name[16];
GetClientName(client, name, sizeof(name));
if (!allowed)
{
if (g_PauseTimer[client] != INVALID_HANDLE)
{
PrintToChat(client, "[SM] Паузу можно ставить 1 раз в 2 минуты!");
return Plugin_Handled;
}
LogAction(client, -1, "%L поставил матч на паузу", client);
PrintToChatAll("[SM] Админ %s поставил матч на паузу. Автоматически снимется через 2 минуты.", name);
allowed = true;
ServerCommand("mp_pause_match", client);
g_PauseTimer[client] = CreateTimer(TIMER_LIMIT, RemoveRestriction, client);
if (IsPaused())
{
PrintToChat(client, "[SM] Матч и так стоит на паузе.");
return Plugin_Handled;
}
}
return Plugin_Handled;
}
public Action:pause_off(client, args)
{
decl String:name[16];
GetClientName(client, name, sizeof(name));
if (allowed)
{
if (g_PauseTimer[client] != INVALID_HANDLE)
{
PrintToChat(client, "[SM] Пауза снята автоматически");
return Plugin_Continue;
}
LogAction(client, -1, "%L снял матч с паузы", client);
PrintToChatAll("[SM] Админ %s снял матч с паузы", name);
allowed = false;
ServerCommand("mp_unpause_match", client);
if (!IsPaused())
{
PrintToChat(client, "[SM] Матч не стоит на паузе.");
return Plugin_Handled;
}
}
return Plugin_Handled;
}
public Action:RemoveRestriction(Handle:RemoveRestriction, any:client)
{
if (g_PauseTimer[client] != INVALID_HANDLE)
{
g_PauseTimer[client] = INVALID_HANDLE;
}
}
stock bool:IsPaused()
{
return bool:GameRules_GetProp("m_bMatchWaitingForResume");
}