Updated basetriggers to use more translation friendly phrases (bug 3330, r=dvander).

Basetriggers now counts rounds remaining for mp_maxrounds output.
This commit is contained in:
Matt Woodrow
2008-10-16 10:54:23 +13:00
parent 4a1c565b62
commit 07cbe39552
2 changed files with 134 additions and 18 deletions
+91 -6
View File
@@ -64,6 +64,8 @@ new Handle:g_Cvar_MaxRounds = INVALID_HANDLE;
new bool:mapchooser;
new g_TotalRounds;
public OnPluginStart()
{
LoadTranslations("common.phrases");
@@ -81,6 +83,11 @@ public OnPluginStart()
HookConVarChange(g_Cvar_TimeleftInterval, ConVarChange_TimeleftInterval);
HookEvent("round_end", Event_RoundEnd);
HookEvent("game_start", Event_GameStart);
HookEventEx("teamplay_win_panel", Event_TeamPlayWinPanel);
HookEventEx("teamplay_restart_round", Event_TFRestartRound);
HookEventEx("arena_win_panel", Event_TeamPlayWinPanel);
g_Cvar_WinLimit = FindConVar("mp_winlimit");
g_Cvar_FragLimit = FindConVar("mp_fraglimit");
@@ -89,6 +96,37 @@ public OnPluginStart()
mapchooser = LibraryExists("mapchooser");
}
public OnMapStart()
{
g_TotalRounds = 0;
}
/* Round count tracking */
public Event_TFRestartRound(Handle:event, const String:name[], bool:dontBroadcast)
{
/* Game got restarted - reset our round count tracking */
g_TotalRounds = 0;
}
public Event_GameStart(Handle:event, const String:name[], bool:dontBroadcast)
{
/* Game got restarted - reset our round count tracking */
g_TotalRounds = 0;
}
public Event_TeamPlayWinPanel(Handle:event, const String:name[], bool:dontBroadcast)
{
if(GetEventInt(event, "round_complete") == 1 || StrEqual(name, "arena_win_panel"))
{
g_TotalRounds++;
}
}
/* You ask, why don't you just use team_score event? And I answer... Because CSS doesn't. */
public Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
{
g_TotalRounds++;
}
public OnLibraryRemoved(const String:name[])
{
if (StrEqual(name, "mapchooser"))
@@ -330,12 +368,27 @@ ShowTimeLeft(client, who)
new len = strlen(finalOutput);
if (len < sizeof(finalOutput))
{
FormatEx(finalOutput[len], sizeof(finalOutput)-len, "%T", "WinLimitAppend" ,client, winlimit, (winlimit == 1)? "":"s");
if (winlimit > 1)
{
FormatEx(finalOutput[len], sizeof(finalOutput)-len, "%T", "WinLimitAppendPlural" ,client, winlimit);
}
else
{
FormatEx(finalOutput[len], sizeof(finalOutput)-len, "%T", "WinLimitAppend" ,client);
}
}
}
else
{
FormatEx(finalOutput, sizeof(finalOutput), "%T", "WinLimit", client, winlimit, (winlimit == 1)? "":"s");
if (winlimit > 1)
{
FormatEx(finalOutput, sizeof(finalOutput), "%T", "WinLimitPlural", client, winlimit);
}
else
{
FormatEx(finalOutput, sizeof(finalOutput), "%T", "WinLimit", client);
}
written = true;
}
}
@@ -352,12 +405,27 @@ ShowTimeLeft(client, who)
new len = strlen(finalOutput);
if (len < sizeof(finalOutput))
{
FormatEx(finalOutput[len], sizeof(finalOutput)-len, "%T", "FragLimitAppend", client, fraglimit, (fraglimit == 1)? "":"s");
if (fraglimit > 1)
{
FormatEx(finalOutput[len], sizeof(finalOutput)-len, "%T", "FragLimitAppendPlural", client, fraglimit);
}
else
{
FormatEx(finalOutput[len], sizeof(finalOutput)-len, "%T", "FragLimitAppend", client);
}
}
}
else
{
FormatEx(finalOutput, sizeof(finalOutput), "%T", "FragLimit", client, fraglimit, (fraglimit == 1)? "":"s");
if (fraglimit > 1)
{
FormatEx(finalOutput, sizeof(finalOutput), "%T", "FragLimitPlural", client, fraglimit);
}
else
{
FormatEx(finalOutput, sizeof(finalOutput), "%T", "FragLimit", client);
}
written = true;
}
}
@@ -369,17 +437,34 @@ ShowTimeLeft(client, who)
if (maxrounds > 0)
{
new remaining = maxrounds - g_TotalRounds;
if (written)
{
new len = strlen(finalOutput);
if (len < sizeof(finalOutput))
{
FormatEx(finalOutput[len], sizeof(finalOutput)-len, "%T", "MaxRoundsAppend", client, maxrounds, (maxrounds == 1)? "":"s");
if (remaining > 1)
{
FormatEx(finalOutput[len], sizeof(finalOutput)-len, "%T", "MaxRoundsAppendPlural", client, remaining);
}
else
{
FormatEx(finalOutput[len], sizeof(finalOutput)-len, "%T", "MaxRoundsAppend", client);
}
}
}
else
{
FormatEx(finalOutput, sizeof(finalOutput), "%T", "MaxRounds", client, maxrounds, (maxrounds == 1)? "":"s");
if (remaining > 1)
{
FormatEx(finalOutput, sizeof(finalOutput), "%T", "MaxRoundsPlural", client, remaining);
}
else
{
FormatEx(finalOutput, sizeof(finalOutput), "%T", "MaxRounds", client);
}
written = true;
}
}