Added amb1665 and amb1381 - Added other map limits to 'timeleft' and handling of timeleft/nextmap console commands.
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%402195
This commit is contained in:
parent
c9b320d645
commit
bff2b0a95d
@ -50,6 +50,10 @@ new Handle:g_Cvar_FriendlyFire = INVALID_HANDLE;
|
||||
|
||||
new Handle:g_Timer_TimeShow = INVALID_HANDLE;
|
||||
|
||||
new Handle:g_Cvar_WinLimit = INVALID_HANDLE;
|
||||
new Handle:g_Cvar_FragLimit = INVALID_HANDLE;
|
||||
new Handle:g_Cvar_MaxRounds = INVALID_HANDLE;
|
||||
|
||||
public OnPluginStart()
|
||||
{
|
||||
LoadTranslations("common.phrases");
|
||||
@ -62,7 +66,14 @@ public OnPluginStart()
|
||||
RegConsoleCmd("say", Command_Say);
|
||||
RegConsoleCmd("say_team", Command_Say);
|
||||
|
||||
RegConsoleCmd("timeleft", Command_Timeleft);
|
||||
|
||||
HookConVarChange(g_Cvar_TimeleftInterval, ConVarChange_TimeleftInterval);
|
||||
|
||||
|
||||
g_Cvar_WinLimit = FindConVar("mp_winlimit");
|
||||
g_Cvar_FragLimit = FindConVar("mp_fraglimit");
|
||||
g_Cvar_MaxRounds = FindConVar("mp_maxrounds");
|
||||
}
|
||||
|
||||
public ConVarChange_TimeleftInterval(Handle:convar, const String:oldValue[], const String:newValue[])
|
||||
@ -90,19 +101,14 @@ public ConVarChange_TimeleftInterval(Handle:convar, const String:oldValue[], con
|
||||
|
||||
public Action:Timer_DisplayTimeleft(Handle:timer)
|
||||
{
|
||||
new timeleft;
|
||||
if (GetMapTimeLeft(timeleft))
|
||||
{
|
||||
new mins, secs;
|
||||
|
||||
if (timeleft > 0)
|
||||
{
|
||||
mins = timeleft / 60;
|
||||
secs = timeleft % 60;
|
||||
}
|
||||
|
||||
PrintToChatAll("[SM] %T %d:%02d", "Timeleft", LANG_SERVER, mins, secs);
|
||||
}
|
||||
ShowTimeLeft(0, true);
|
||||
}
|
||||
|
||||
public Action:Command_Timeleft(client, args)
|
||||
{
|
||||
ShowTimeLeft(client);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_Say(client, args)
|
||||
@ -125,27 +131,7 @@ public Action:Command_Say(client, args)
|
||||
|
||||
if (strcmp(text[startidx], "timeleft", false) == 0)
|
||||
{
|
||||
new timeleft;
|
||||
if (GetMapTimeLeft(timeleft))
|
||||
{
|
||||
new mins, secs;
|
||||
|
||||
if (timeleft > 0)
|
||||
{
|
||||
mins = timeleft / 60;
|
||||
secs = timeleft % 60;
|
||||
}
|
||||
|
||||
if(GetConVarInt(g_Cvar_TriggerShow))
|
||||
{
|
||||
PrintToChatAll("[SM] %t %d:%02d", "Timeleft", mins, secs);
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintToChat(client,"[SM] %t %d:%02d", "Timeleft", mins, secs);
|
||||
}
|
||||
}
|
||||
|
||||
ShowTimeLeft(client);
|
||||
}
|
||||
else if (strcmp(text[startidx], "thetime", false) == 0)
|
||||
{
|
||||
@ -201,4 +187,135 @@ public Action:Command_Say(client, args)
|
||||
}
|
||||
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
ShowTimeLeft(client, bool:all=false)
|
||||
{
|
||||
new bool:lastround = false;
|
||||
new bool:written = false;
|
||||
new bool:notimelimit = false;
|
||||
|
||||
decl String:finalOutput[1024];
|
||||
finalOutput[0] = 0;
|
||||
|
||||
if(GetConVarInt(g_Cvar_TriggerShow) || all)
|
||||
{
|
||||
client = 0;
|
||||
}
|
||||
|
||||
new timeleft;
|
||||
if (GetMapTimeLeft(timeleft))
|
||||
{
|
||||
new mins, secs;
|
||||
new timelimit;
|
||||
|
||||
if (timeleft > 0)
|
||||
{
|
||||
mins = timeleft / 60;
|
||||
secs = timeleft % 60;
|
||||
written = true;
|
||||
FormatEx(finalOutput, sizeof(finalOutput), "%T %d:%02d", "Timeleft", client, mins, secs);
|
||||
}
|
||||
else if (GetMapTimeLimit(timelimit) && timelimit == 0)
|
||||
{
|
||||
notimelimit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 0 timeleft so this must be the last round */
|
||||
lastround=true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!lastround)
|
||||
{
|
||||
if (g_Cvar_WinLimit != INVALID_HANDLE)
|
||||
{
|
||||
new winlimit = GetConVarInt(g_Cvar_WinLimit);
|
||||
|
||||
if (winlimit > 0)
|
||||
{
|
||||
if (written)
|
||||
{
|
||||
new len = strlen(finalOutput);
|
||||
if (len < sizeof(finalOutput))
|
||||
{
|
||||
FormatEx(finalOutput[len], sizeof(finalOutput)-len, "%T", "WinLimitAppend" ,client, winlimit, (winlimit == 1)? "":"s");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FormatEx(finalOutput, sizeof(finalOutput), "%T", "WinLimit", client, winlimit, (winlimit == 1)? "":"s");
|
||||
written = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (g_Cvar_FragLimit != INVALID_HANDLE)
|
||||
{
|
||||
new fraglimit = GetConVarInt(g_Cvar_FragLimit);
|
||||
|
||||
if (fraglimit > 0)
|
||||
{
|
||||
if (written)
|
||||
{
|
||||
new len = strlen(finalOutput);
|
||||
if (len < sizeof(finalOutput))
|
||||
{
|
||||
FormatEx(finalOutput[len], sizeof(finalOutput)-len, "%T", "FragLimitAppend", client, fraglimit, (fraglimit == 1)? "":"s");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FormatEx(finalOutput, sizeof(finalOutput), "%T", "FragLimit", client, fraglimit, (fraglimit == 1)? "":"s");
|
||||
written = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (g_Cvar_MaxRounds != INVALID_HANDLE)
|
||||
{
|
||||
new maxrounds = GetConVarInt(g_Cvar_MaxRounds);
|
||||
|
||||
if (maxrounds > 0)
|
||||
{
|
||||
if (written)
|
||||
{
|
||||
new len = strlen(finalOutput);
|
||||
if (len < sizeof(finalOutput))
|
||||
{
|
||||
FormatEx(finalOutput[len], sizeof(finalOutput)-len, "%T", "MaxRoundsAppend", client, maxrounds, (maxrounds == 1)? "":"s");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FormatEx(finalOutput, sizeof(finalOutput), "%T", "MaxRounds", client, maxrounds, (maxrounds == 1)? "":"s");
|
||||
written = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lastround)
|
||||
{
|
||||
FormatEx(finalOutput, sizeof(finalOutput), "%T", "LastRound", client);
|
||||
}
|
||||
else if (notimelimit && !written)
|
||||
{
|
||||
FormatEx(finalOutput, sizeof(finalOutput), "%T", "NoTimelimit", client);
|
||||
}
|
||||
|
||||
if(GetConVarInt(g_Cvar_TriggerShow) || all)
|
||||
{
|
||||
PrintToChatAll("[SM] %s", finalOutput);
|
||||
}
|
||||
else if (client != 0)
|
||||
{
|
||||
PrintToChat(client, "[SM] %s", finalOutput);
|
||||
}
|
||||
|
||||
if (client == 0)
|
||||
{
|
||||
PrintToServer("[SM] %s", finalOutput);
|
||||
}
|
||||
}
|
@ -61,10 +61,7 @@ public OnPluginStart()
|
||||
RegConsoleCmd("say", Command_Say);
|
||||
RegConsoleCmd("say_team", Command_Say);
|
||||
|
||||
if (GetCommandFlags("nextmap") == INVALID_FCVAR_FLAGS)
|
||||
{
|
||||
RegServerCmd("nextmap", Command_Nextmap);
|
||||
}
|
||||
RegConsoleCmd("nextmap", Command_Nextmap);
|
||||
|
||||
RegAdminCmd("sm_setnextmap", Command_SetNextmap, ADMFLAG_CHANGEMAP, "sm_setnextmap <map>");
|
||||
RegConsoleCmd("listmaps", Command_List);
|
||||
@ -113,7 +110,7 @@ public Action:Command_Say(client, args)
|
||||
decl String:map[32];
|
||||
GetNextMap(map, sizeof(map));
|
||||
|
||||
PrintToChat(client, "%t", "Next Map", map);
|
||||
PrintToChat(client, "[SM] %t", "Next Map", map);
|
||||
}
|
||||
|
||||
return Plugin_Continue;
|
||||
@ -159,13 +156,13 @@ public Action:Command_List(client, args)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_Nextmap(args)
|
||||
public Action:Command_Nextmap(client, args)
|
||||
{
|
||||
decl String:map[64];
|
||||
|
||||
GetNextMap(map, sizeof(map));
|
||||
|
||||
ReplyToCommand(0, "%t", "Next Map", map);
|
||||
ReplyToCommand(client, "[SM] %t", "Next Map", map);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
@ -26,4 +26,49 @@
|
||||
"#format" "{1:s}"
|
||||
"en" "The current map is {1}."
|
||||
}
|
||||
|
||||
"WinLimitAppend"
|
||||
{
|
||||
"#format" "{1:i},{2:s}"
|
||||
"en" ", or change map after a team wins {1} round{2}"
|
||||
}
|
||||
|
||||
"WinLimit"
|
||||
{
|
||||
"#format" "{1:i},{2:s}"
|
||||
"en" "Map will change after a team wins {1} round{2}"
|
||||
}
|
||||
|
||||
"MaxRoundsAppend"
|
||||
{
|
||||
"#format" "{1:i},{2:s}"
|
||||
"en" ", or change map after {1} round{2}"
|
||||
}
|
||||
|
||||
"MaxRounds"
|
||||
{
|
||||
"#format" "{1:i},{2:s}"
|
||||
"en" "Map will change after {1} round{2}"
|
||||
}
|
||||
|
||||
"FragLimitAppend"
|
||||
{
|
||||
"#format" "{1:i},{2:s}"
|
||||
"en" ", or change map after player reaches {1} frag{2}"
|
||||
}
|
||||
"FragLimit"
|
||||
{
|
||||
"#format" "{1:i},{2:s}"
|
||||
"en" "Map will change after a player reaches {1} frag{2}"
|
||||
}
|
||||
|
||||
"LastRound"
|
||||
{
|
||||
"en" "This is the last round!!"
|
||||
}
|
||||
|
||||
"NoTimelimit"
|
||||
{
|
||||
"en" "No timelimit for map"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user