#include common_scripts\utility; #include maps\mp\_utility; #include maps\mp\gametypes\_hud_util; /* * Clears the memory of shown hints for a player once he disconnects. */ clearHintsShownOnDisconnect() { logString("clearHintsShownOnDisconnect called"); if (IsDefined(self.clearHintsShownOnDisconnectThreadRunning) && self.clearHintsShownOnDisconnectThreadRunning) { return; } self.clearHintsShownOnDisconnectThreadRunning = true; id = self getEntityNumber(); self waittill("disconnect"); self clearHintsShownOnDisconnect(); } /* * Clears the memory of shown hints for the player. */ clearHintsShown() { logString("clearHintsShown called"); id = self.guid; if (!IsDefined(level.shownPlayerHints)) { level.shownPlayerHints = []; } if (IsDefined(level.shownPlayerHints[id])) { level.shownPlayerHints[id] = undefined; } } /* * Displays a hint for the player (self) if it hasn't been shown before for him. */ showHintOnce(text) { logString("showHintOnce called"); id = self.guid; if (!IsDefined(level.shownPlayerHints)) { level.shownPlayerHints = []; } if (!IsDefined(level.shownPlayerHints[id])) { level.shownPlayerHints[id] = []; } if (!IsDefined(level.shownPlayerHints[id][text]) || !level.shownPlayerHints[id][text]) { level.shownPlayerHints[id][text] = true; self showHint(text); } else { self hideHint(); } } /* * Displays a small hint for the player (self) at the bottom of the screen. */ showHint(text) { logString("showHint called"); player = self; player notify("hint_about_to_be_changed"); if (!IsDefined(player.hudHintElement)) { player.hudHintElement = createFontString("default", 1.5, player); // "default" player.hudHintElement setPoint("BOTTOMRIGHT", "BOTTOMRIGHT", -96, -72); player.hudHintElement.alpha = 0; player.hudHintElement.hideWhenInMenu = true; } else { player fadeHint(0); } player.hudHintElement setText(text); player fadeHint(1); player thread hideHintInSeconds(15); } hideHintInSeconds(time) { logString("hideHintInSeconds called"); player = self; player endon("hint_about_to_be_changed"); wait time; player hideHint(); } /* * Hides the hint message for the player (self). */ hideHint() { logString("hideHint called"); player = self; if (!IsDefined(player.hudHintElement)) { return; } player fadeHint(0); player.hudHintElement destroyElem(); player.hudHintElement = undefined; } fadeHint(alpha, length) { logString("fadeHint called"); player = self; if (!IsDefined(player.hudHintElement)) { return; } if (length == undefined) { length = 0.33; } interval = 0.05; if (player.hudHintElement.alpha < alpha) { // fade in step = (alpha - player.hudHintElement.alpha) / (length / interval); for (a = player.hudHintElement.alpha; a < alpha; a += step) { player.hudHintElement.alpha = a; wait interval; } } else { // fade out step = (player.hudHintElement.alpha - alpha) / (length / interval); for (a = player.hudHintElement.alpha; a > alpha; a -= step) { player.hudHintElement.alpha = a; wait interval; } } player.hudHintElement.alpha = alpha; }