sm-plugins/_CTimer/scripting/ctimer/commands.sp

138 lines
3.0 KiB
SourcePawn
Raw Normal View History

2019-06-19 20:54:56 +02:00
public Action Command_Time(int client, int args)
{
if (!g_bActive)
return Plugin_Handled;
if (g_fMapTime[client] != 0.0)
{
char cTime[16];
TimerFormat(g_fMapTime[client], cTime, sizeof(cTime), true, false);
TimerPrintToChat(client, false, "%T", "PlayerTime", LANG_SERVER, cTime);
}
else
TimerPrintToChat(client, false, "%T", "PlayerNoTime", LANG_SERVER);
return Plugin_Handled;
}
public Action Command_Stop(int client, int args)
{
if (!g_bActive)
return Plugin_Handled;
if (g_iActivity[client] == 0)
{
g_iActivity[client] = -1;
TimerPrintToChat(client, false, "%T", "TimerStopped", LANG_SERVER);
}
else if (g_iActivity[client] == 1)
{
TimerPrintToChat(client, false, "%T", "TimerCantBeStopped", LANG_SERVER);
}
else if (g_iActivity[client] == -1)
{
TimerPrintToChat(client, false, "%T", "TimerNotRunning", LANG_SERVER);
}
return Plugin_Handled;
}
public Action Command_Zones(int client, int args)
{
if (g_iEditor != -1)
{
TimerPrintToChat(client, false, "%T", "ZoneMenuUnavailable", LANG_SERVER);
//PrintToChat(client, "Zone menu currently unavailable");
return Plugin_Handled;
}
g_iEditor = client;
g_iActivity[client] = -1;
g_bEditorComesFromMenu = false;
ZoneMenu(client, g_bEditorComesFromMenu);
return Plugin_Handled;
}
public Action Command_Top(int client, int args)
{
char sMapName[129];
if (args > 0)
{
GetCmdArg(1, sMapName, sizeof(sMapName));
if (strlen(sMapName) > 64)
{
TimerPrintToChat(client, false, "%T", "MapNameTooLong", LANG_SERVER);
return Plugin_Handled;
}
g_hDatabase.Escape(sMapName, sMapName, sizeof(sMapName));
}
else
{
if (!g_bActive)
return Plugin_Handled;
strcopy(sMapName, sizeof(sMapName), g_sMapName);
}
int userid = GetClientUserId(client);
RequestTop(userid, sMapName, 10);
return Plugin_Handled;
}
public Action Command_TimerAdmin(int client, int args)
{
TimerAdminMenu(client);
return Plugin_Handled;
}
public Action Command_WR(int client, int args)
{
if (args == 0)
{
if (!g_bActive)
return Plugin_Handled;
if (g_fWrTime == 0.0)
{
TimerPrintToChat(client, false, "%T", "TimesNotFound", LANG_SERVER, g_sMapName);
return Plugin_Handled;
}
else
{
char cWRTime[16];
TimerFormat(g_fWrTime, cWRTime, sizeof(cWRTime), true, false);
TimerPrintToChat(client, false, "%T", "WR", LANG_SERVER, g_sWrHolder, g_sMapName, cWRTime);
return Plugin_Handled;
}
}
else
{
char sMapName[129];
GetCmdArg(1, sMapName, sizeof(sMapName));
if (strlen(sMapName) > 64)
{
TimerPrintToChat(client, false, "%T", "MapNameTooLong", LANG_SERVER);
return Plugin_Handled;
}
g_hDatabase.Escape(sMapName, sMapName, sizeof(sMapName));
int userid = GetClientUserId(client);
RequestWR(userid, sMapName);
}
return Plugin_Handled;
}
public int Native_StopTime(Handle hPlugin, int numParams)
{
int client = GetNativeCell(1);
if (!isValidClient(client))
return;
if (g_iActivity[client] == -1)
return;
g_iActivity[client] = -1;
TimerPrintToChat(client, false, "%T", "TimerCheatStopped", LANG_SERVER);
return;
}