Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- addMessageCallback("MsgPracticeEnd", StopTimer);
- addMessageCallback("MsgCtfLlamaGrab", StartTimer);
- addMessageCallback("MsgCtfOdGrab", StartTimer);
- addMessageCallback("MsgCtfFlagGrab", StartTimer);
- addMessageCallback("MsgCtfFlagPickup", StartTimer);
- addMessageCallback("MsgCtfFlagThrow", StopTimerNonReset);
- addMessageCallback("MsgCtfFlagDrop", StopTimerNonReset);
- addMessageCallback("MsgCtfFlagCap", StopTimer);
- addMessageCallback("MsgCtfFlagReturn", StopTimer);
- if(!isObject(FlagTimer))
- {
- new ScriptObject(FlagTimer)
- {
- FlagTakenBeta = 0;
- FlagTakenAlpha = 0;
- BetaTime = 0;
- LastBetaTime = 0;
- AlphaTime = 0;
- LastAlphaTime = 0;
- };
- }
- function HudUpdate(%fillervar, %fillervar, %team)
- {
- %data = "Alpha: " TAB FlagTimer.AlphaTime NL
- "Beta: " TAB FlagTimer.BetaTime NL
- "Last Alpha Cap: " TAB FlagTimer.LastAlphaTime NL
- "Last Beta Cap: " TAB FlagTimer.LastBetaTime;
- HudOverlay.setHudElementText($HudOverlay::FlagTimer, %data);
- }
- function StartTimer(%fillervar, %fillervar, %team)
- {
- HudUpdate();
- //Get the team name, (Alph = Alpha)
- $team3 = getSubStr(deTag(%team), 3, 4);
- $team3 = (stripTrailingSpaces($team3));
- //If its alpha, go to "StartTimerAlpha" and set the flag taken to "1".
- if($team3 $= "Alph")
- {
- FlagTimer.FlagTakenAlpha = 1;
- StartTimerAlph();
- }
- //If its Beta, go to "StartTimerBeta" and set the flag taken to "1".
- if($team3 $= "Beta")
- {
- FlagTimer.FlagTakenBeta = 1;
- StartTimerBeta();
- }
- }
- function StartTimerAlph()
- {
- //If the flag is still taken, wait one second then go to "AddTimeAlph"
- if(FlagTimer.FlagTakenAlpha == 1)
- {
- schedule(10, 0, "AddTimeAlph");
- }
- }
- function StartTimerBeta()
- {
- //If the flag is still taken, wait one second then go to "AddTimeBeta"
- if(FlagTimer.FlagTakenBeta == 1)
- {
- schedule(10, 0, "AddTimeBeta");
- }
- }
- function AddTimeAlph()
- {
- //Here, go to function StartTimer again
- FlagTimer.AlphaTime += 0.01;
- HudUpdate();
- StartTimerAlph();
- }
- function AddTimeBeta()
- {
- //Here, go to function StartTimer again
- FlagTimer.BetaTime += 0.01;
- HudUpdate();
- StartTimerBeta();
- }
- //--------------------------
- //Stop Functions
- //--------------------------
- function StopTimer(%fillervar, %fillervar, %stopTeam)
- {
- HudUpdate();
- //Get the team name, (Alph = Alpha)
- $stopteam3 = getSubStr(deTag(%stopTeam), 3, 4);
- $stopteam3 = (stripTrailingSpaces($stopteam3));
- //If its Alpha, go to "StopTimeAlpha"
- if($stopteam3 $= "Alph")
- {
- StopTimerAlpha();
- }
- //If its Beta, go to "StopTimeBeta"
- if($stopteam3 $= "Beta")
- {
- StopTimerBeta();
- }
- }
- //Do not reset
- function StopTimerNonReset(%fillervar, %fillervar, %stopTeam)
- {
- //Get the team name, (Alph = Alpha)
- $stopteam3 = getSubStr(deTag(%stopTeam), 3, 4);
- $stopteam3 = (stripTrailingSpaces($stopteam3));
- //If its Alpha, go to "StopTimeAlpha"
- if($stopteam3 $= "Alph")
- {
- StopTimerNonResetAlpha();
- }
- //If its Beta, go to "StopTimeBeta"
- if($stopteam3 $= "Beta")
- {
- StopTimerNonResetBeta();
- }
- }
- function StopTimerAlpha()
- {
- FlagTimer.FlagTakenAlpha = 0;
- FlagTimer.LastAlphaTime = FlagTimer.AlphaTime;
- FlagTimer.AlphaTime = 0;
- //Stop the timer for alpha, and reset the time to 0
- HudUpdate();
- }
- function StopTimerNonResetAlpha()
- {
- HudUpdate();
- //Stop the timer for Alpha, but don't reset the time.
- FlagTimer.FlagTakenAlpha = 0;
- }
- function StopTimerBeta()
- {
- //Stop the timer for beta, and reset the time to 0
- FlagTimer.FlagTakenBeta = 0;
- FlagTimer.LastBetaTime = FlagTimer.BetaTime;
- FlagTimer.BetaTime = 0;
- HudUpdate();
- }
- function StopTimerNonResetBeta()
- {
- HudUpdate();
- //Stop the timer for beta, but don't reset the time.
- FlagTimer.FlagTakenBeta = 0;
- }
- //--------------------------
- //HUD Code
- //--------------------------
- package FlagTimer
- {
- function HudOverlay::AddHudElements(%this)
- {
- parent::AddHudElements(%this);
- %index = %this.AddHudElement();
- %this.setHudElementPosition(%index, 825, 10);
- %this.setHudElementParent(%index, $HudElement::FlagTime);
- %this.setHudElementPositionAnchor(%index, "Left", "Top");
- %this.setHudElementRenderWhenDead(%index, true);
- $HudOverlay::FlagTimer = %index;
- %data = "Alpha Flag: " TAB FlagTimer.AlphaTime NL
- "Beta Flag: " TAB FlagTimer.BetaTime NL
- "Last Alpha Cap: " TAB FlagTimer.LastAlphaTime NL
- "Last Beta Cap: " TAB FlagTimer.LastBetaTime;
- HudOverlay.setHudElementText($HudOverlay::FlagTimer, %data);
- }
- };
- activatepackage(FlagTimer);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement