Compare commits
No commits in common. "057800e99233805aa729c260f0c9feaa93b19b64" and "9b9fd4596d4fdae714545591ce6950b822776e97" have entirely different histories.
057800e992
...
9b9fd4596d
@ -4,7 +4,7 @@
|
||||
#Extends "Libs/Nadeo/TMNext/TrackMania/Modes/TMNextRoundsBase.Script.txt"
|
||||
|
||||
#Const CompatibleMapTypes "TrackMania\\TM_Race,TM_Race"
|
||||
#Const Version "2023-07-12"
|
||||
#Const Version "2023-07-10"
|
||||
#Const ScriptName "Modes/TM2020-Gamemodes/LastManStanding.Script.txt"
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
|
||||
@ -28,7 +28,7 @@
|
||||
#Setting S_RoundsPerMap 1 as _("Number of rounds per map") ///< Number of round to play on one map before going to the next one
|
||||
|
||||
|
||||
#Setting S_AFKIdleTime 120000 as "Time before being an AFK player will be kicked"
|
||||
#Setting S_AFKIdleTime 10000 as "Time before being an AFK player will be kicked"
|
||||
|
||||
#Setting S_IntroTime 5 as "Time of the map intro"
|
||||
#Setting S_TimeBeforeMalus 10 as "Time Before Malus"
|
||||
@ -164,12 +164,12 @@ UsePvECollisions = True;
|
||||
StateMgr::ForcePlayersStates([StateMgr::C_State_Waiting]);
|
||||
WarmUp::SetAvailability(True);
|
||||
CarRank::Reset();
|
||||
ResetNetworkVariables();
|
||||
***
|
||||
|
||||
***Match_InitMap***
|
||||
***
|
||||
declare Integer Map_ValidRoundsNb;
|
||||
declare Boolean RankInitialized = False;
|
||||
|
||||
declare Integer Map_TimeBeforeMalus;
|
||||
declare Integer Map_TimeBeforeNightmare;
|
||||
@ -189,7 +189,6 @@ declare Integer NextStepMalusTime = 0;
|
||||
declare Integer MalusIndex;
|
||||
declare Integer MalusTime;
|
||||
|
||||
declare netwrite Boolean Net_DisplayUI for Teams[0] = False;
|
||||
declare netwrite Integer Net_NBPlayers for Teams[0] = 0;
|
||||
declare netwrite Integer Net_PlayersNbAlive for Teams[0] = 0;
|
||||
declare netwrite Integer Net_NextMalus for Teams[0] = -1;
|
||||
@ -197,8 +196,6 @@ declare netwrite Integer Net_TimeBeforeMalus for Teams[0] = -1;
|
||||
declare netwrite Integer Net_RoundsPerMap for Teams[0] = 0;
|
||||
declare netwrite Integer Net_CurrentRoundNb for Teams[0] = 0;
|
||||
|
||||
ResetNetworkVariables();
|
||||
|
||||
// Map Intro
|
||||
declare Boolean MapIsCompatible;
|
||||
declare CMapLandmark[] Landmarks = Map::GetFinishesAndMultilaps();
|
||||
@ -213,7 +210,7 @@ if (!MapIsCompatible) {
|
||||
MB_Sleep(3000);
|
||||
MB_StopMap();
|
||||
} else if (S_IntroTime > 0) {
|
||||
declare netwrite Boolean Net_LMS_IsIntro for Teams[0] = False;
|
||||
declare netwrite Boolean Net_LMS_IsIntro for Teams[0];
|
||||
Net_LMS_IsIntro = True;
|
||||
StateMgr::ForcePlayersStates([StateMgr::C_State_Waiting]);
|
||||
if (Map.HasCustomIntro) {
|
||||
@ -242,20 +239,12 @@ Race::SetRespawnBehaviour(Race::C_RespawnBehaviour_AlwaysGiveUp);
|
||||
CarRank::Reset();
|
||||
***
|
||||
|
||||
***Match_InitRound***
|
||||
***
|
||||
declare Boolean ThrottleUpdate;
|
||||
***
|
||||
|
||||
***Match_StartRound***
|
||||
***
|
||||
Scores::Clear();
|
||||
|
||||
declare netwrite Integer Net_LMS_AFKIdleTime for Teams[0] = 120000;
|
||||
Net_LMS_AFKIdleTime = S_AFKIdleTime;
|
||||
|
||||
// WorkAround for longloading
|
||||
declare Integer StartMapTime = Now;
|
||||
declare StartMapTime = Now;
|
||||
while (Players.count < 2 && Now < (StartMapTime + 3000)) {
|
||||
MB_Yield();
|
||||
}
|
||||
@ -270,7 +259,6 @@ Map_MalusDuration = S_MalusDuration;
|
||||
Map_RoundsPerMap = S_RoundsPerMap;
|
||||
UpdateScoresTableFooter();
|
||||
MalusTime = GetTimeBeforeMalus(StartTime, S_TimeBeforeMalus, S_TimeBeforeNightmare);
|
||||
Net_DisplayUI = True;
|
||||
Net_TimeBeforeMalus = MalusTime;
|
||||
Net_NextMalus = -1;
|
||||
Net_RoundsPerMap = Map_RoundsPerMap;
|
||||
@ -287,23 +275,22 @@ declare Integer LandmarkIndex for This = 0;
|
||||
AccountIdsOfPlayers = [];
|
||||
|
||||
// Suffle Players list to randomise spawn
|
||||
declare CSmPlayer[Integer] ShuffledPlayers;
|
||||
declare CSmPlayer[] ShuffledPlayers = Players;
|
||||
declare Integer i=0;
|
||||
while(i<ShuffledPlayers.count) { // this should be enough, you can use arbitrary values, should the need arise
|
||||
// find a pair (a,b) of valid indices to swap
|
||||
declare a=ML::Rand(0, ShuffledPlayers.count-1);
|
||||
declare b=ML::Rand(0, ShuffledPlayers.count-1);
|
||||
|
||||
foreach (Player in Players) {
|
||||
declare Integer RandomIndex = 0;
|
||||
while (RandomIndex == 0 || ShuffledPlayers.existskey(RandomIndex)) {
|
||||
RandomIndex = ML::Rand(1, 10000);
|
||||
}
|
||||
ShuffledPlayers[RandomIndex] = Player;
|
||||
// now swap them
|
||||
declare tmp=ShuffledPlayers[b];
|
||||
ShuffledPlayers[b]=ShuffledPlayers[a];
|
||||
ShuffledPlayers[a]=tmp;
|
||||
|
||||
i=i+1;
|
||||
}
|
||||
|
||||
ShuffledPlayers = ShuffledPlayers.sortkey();
|
||||
|
||||
Net_NBPlayers = ShuffledPlayers.count;
|
||||
Net_PlayersNbAlive = Net_NBPlayers;
|
||||
|
||||
foreach (Player in ShuffledPlayers) {
|
||||
if (Player == Null) continue;
|
||||
PlayerLM = Null;
|
||||
while (PlayerLM == Null) {
|
||||
if (LandmarkIndex > Landmarks.count - 1 ) {
|
||||
@ -315,45 +302,102 @@ foreach (Player in ShuffledPlayers) {
|
||||
LandmarkIndex = LandmarkIndex + 1 ;
|
||||
}
|
||||
Race::Start(Player, PlayerLM , StartTime);
|
||||
CarRank::SetRank(Player, Net_NBPlayers);
|
||||
AccountIdsOfPlayers.add(Player.User.WebServicesUserId);
|
||||
MalusQueue[Player.User.Login] = GetNewMalus(C_Malus_Reset, 1500);
|
||||
}
|
||||
|
||||
UIModules_ScoresTable::DisplayOnly(AccountIdsOfPlayers);
|
||||
Net_NBPlayers = AccountIdsOfPlayers.count;
|
||||
|
||||
UpdateCustomRanking(Null, -1);
|
||||
StateMgr::ForcePlayersStates([StateMgr::C_State_Playing]);
|
||||
CarRank::Update(CarRank::C_SortCriteria_BestRace);
|
||||
Race::EnableIntroDuringMatch(False);
|
||||
UIManager.UIAll.SendChat("$<$ff3$> Stay the most time on the structure. $<$ff9GL HF!$>");
|
||||
|
||||
***
|
||||
|
||||
/***Match_InitPlayLoop***
|
||||
***
|
||||
MalusQueue = [];
|
||||
***/
|
||||
|
||||
***Match_PlayLoop***
|
||||
***
|
||||
// Update CarRank & UI Interface
|
||||
if (!RankInitialized) {
|
||||
RankInitialized = True;
|
||||
Net_PlayersNbAlive = PlayersNbAlive;
|
||||
Net_NBPlayers = AccountIdsOfPlayers.count;
|
||||
foreach (Player in Players) {
|
||||
CarRank::SetRank(Player, PlayersNbAlive);
|
||||
}
|
||||
}
|
||||
|
||||
// Spawn players who have longloading
|
||||
if (Now < StartTime + 3000) {
|
||||
declare Boolean PlayerSpawned = False;
|
||||
declare CMapLandmark[] Landmarks = Map::GetFinishesAndMultilaps();
|
||||
declare CMapLandmark PlayerLM = Null;
|
||||
if (PlayersNbDead >= 1) {
|
||||
foreach (Player in Players) {
|
||||
if (Player.SpawnStatus == CSmPlayer::ESpawnStatus::NotSpawned && !AccountIdsOfPlayers.exists(Player.User.WebServicesUserId)) {
|
||||
PlayerSpawned = True;
|
||||
PlayerLM = Null;
|
||||
while (PlayerLM == Null) {
|
||||
if (LandmarkIndex > Landmarks.count - 1 ) {
|
||||
LandmarkIndex = 0;
|
||||
}
|
||||
if (Map::IsMultilap(Landmarks[LandmarkIndex])) {
|
||||
PlayerLM = Landmarks[LandmarkIndex];
|
||||
}
|
||||
LandmarkIndex = LandmarkIndex + 1 ;
|
||||
}
|
||||
Race::Start(Player, PlayerLM , StartTime);
|
||||
AccountIdsOfPlayers.add(Player.User.WebServicesUserId);
|
||||
|
||||
MalusQueue[Player.User.Login] = GetNewMalus(C_Malus_Reset);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (PlayerSpawned) {
|
||||
PlayerSpawned = False;
|
||||
Net_NBPlayers = AccountIdsOfPlayers.count;
|
||||
Net_PlayersNbAlive = PlayersNbAlive;
|
||||
UpdateCustomRanking(Null, -1);
|
||||
foreach (Player in Players) {
|
||||
CarRank::SetRank(Player, PlayersNbAlive);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Manage race events
|
||||
declare Events::K_RaceEvent[] RacePendingEvents = Race::GetPendingEvents();
|
||||
declare RacePendingEvents = Race::GetPendingEvents();
|
||||
foreach (Event in RacePendingEvents) {
|
||||
Race::ValidEvent(Event);
|
||||
|
||||
if (Event.Player == Null) continue;
|
||||
|
||||
// Waypoint
|
||||
switch (Event.Type) {
|
||||
case Events::C_Type_Waypoint: {
|
||||
ThrottleUpdate = True;
|
||||
|
||||
Scores::UpdatePlayerBestRaceIfBetter(Event.Player);
|
||||
if (Event.Type == Events::C_Type_Waypoint) {
|
||||
if (Event.IsEndLap) {
|
||||
Race::StopSkipOutro(Event.Player);
|
||||
UpdateCustomRanking(Event.Player.User, False);
|
||||
foreach (Player in Players) {
|
||||
CarRank::SetRank(Player, PlayersNbAlive);
|
||||
Net_PlayersNbAlive = PlayersNbAlive;
|
||||
}
|
||||
UpdateCustomRanking(Event.Player, Event.Type);
|
||||
}
|
||||
case Events::C_Type_GiveUp: {
|
||||
ThrottleUpdate = True;
|
||||
UpdateCustomRanking(Event.Player.User, True);
|
||||
} else if (Event.Type == Events::C_Type_GiveUp) {
|
||||
foreach (Player in Players) {
|
||||
CarRank::SetRank(Player, PlayersNbAlive);
|
||||
Net_PlayersNbAlive = PlayersNbAlive;
|
||||
}
|
||||
case Events::C_Type_Eliminated: {
|
||||
ThrottleUpdate = True;
|
||||
UpdateCustomRanking(Event.Player.User, True);
|
||||
UpdateCustomRanking(Event.Player, Event.Type);
|
||||
} else if (Event.Type == Events::C_Type_Eliminated) {
|
||||
Race::StopSkipOutro(Event.Player);
|
||||
foreach (Player in Players) {
|
||||
CarRank::SetRank(Player, PlayersNbAlive);
|
||||
Net_PlayersNbAlive = PlayersNbAlive;
|
||||
}
|
||||
UpdateCustomRanking(Event.Player, Event.Type);
|
||||
}
|
||||
}
|
||||
|
||||
@ -361,13 +405,6 @@ foreach (Event in RacePendingEvents) {
|
||||
foreach (Event in PendingEvents) {
|
||||
if (Event.HasBeenPassed || Event.HasBeenDiscarded) continue;
|
||||
Events::Invalid(Event);
|
||||
|
||||
if (Event.Type == CSmModeEvent::EType::OnPlayerRemoved) {
|
||||
if (Event.User == Null ) continue;
|
||||
if (!AccountIdsOfPlayers.exists(Event.User.WebServicesUserId)) continue;
|
||||
ThrottleUpdate = True;
|
||||
UpdateCustomRanking(Event.User, True);
|
||||
}
|
||||
}
|
||||
|
||||
if (PlayersNbAlive <= 1 && AccountIdsOfPlayers.count >= 2) { //TODO just respawn in case of 1 player
|
||||
@ -375,18 +412,6 @@ if (PlayersNbAlive <= 1 && AccountIdsOfPlayers.count >= 2) { //TODO just respawn
|
||||
MB_StopRound();
|
||||
}
|
||||
|
||||
if (ThrottleUpdate) {
|
||||
ThrottleUpdate = False;
|
||||
Net_PlayersNbAlive = PlayersNbAlive;
|
||||
declare Integer Points = Net_NBPlayers - Net_PlayersNbAlive;
|
||||
foreach (Player in Players) {
|
||||
CarRank::SetRank(Player, PlayersNbAlive);
|
||||
if (Player.SpawnStatus == CSmPlayer::ESpawnStatus::Spawned) {
|
||||
Scores::SetPlayerRoundPoints(Player.Score, Points);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Update the map duration setting
|
||||
if (Map_TimeBeforeMalus != S_TimeBeforeMalus || Map_TimeBeforeMalus != S_TimeBeforeNightmare || Map_MalusEveryNSecs != S_MalusEveryNSecs || Map_NextMalusPreparationTime != S_NextMalusPreparationTime || Map_MalusDuration != S_MalusDuration || Map_RoundsPerMap != S_RoundsPerMap) {
|
||||
@ -451,12 +476,7 @@ if (Players.count > 0 && S_MalusDuration > 0 && MalusTime != -1 && Now > MalusTi
|
||||
Net_NextMalus = 0;
|
||||
Net_TimeBeforeMalus = NextStepMalusTime;
|
||||
} else if (!PendingMalus && ActiveMalus) {
|
||||
if (MalusIndex == 99) {
|
||||
foreach (Player in Players) {
|
||||
MalusQueue[Player.User.Login] = GetNewMalus(C_Malus_Nightmare);
|
||||
}
|
||||
NextStepMalusTime = Now + (S_MalusDuration*1000);
|
||||
} else {
|
||||
if (MalusIndex != 99) {
|
||||
foreach (Player in Players) {
|
||||
MalusQueue[Player.User.Login] = GetNewMalus(C_Malus_Reset);
|
||||
}
|
||||
@ -471,6 +491,11 @@ if (Players.count > 0 && S_MalusDuration > 0 && MalusTime != -1 && Now > MalusTi
|
||||
// Players UI update
|
||||
Net_NextMalus = -1;
|
||||
Net_TimeBeforeMalus = NextStepMalusTime;
|
||||
} else {
|
||||
foreach (Player in Players) {
|
||||
MalusQueue[Player.User.Login] = GetNewMalus(C_Malus_Nightmare);
|
||||
}
|
||||
NextStepMalusTime = Now + (S_MalusDuration*1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -493,9 +518,9 @@ foreach (Login => Malus in MalusQueue) {
|
||||
***
|
||||
PendingMalus = False;
|
||||
ActiveMalus = False;
|
||||
Net_DisplayUI = False;
|
||||
Net_TimeBeforeMalus = -1;
|
||||
Net_NextMalus = -1;
|
||||
RankInitialized = False;
|
||||
CustomTimes.clear();
|
||||
|
||||
Race::StopSkipOutroAll();
|
||||
@ -530,10 +555,11 @@ if (Round_ForceEndRound || Round_SkipPauseRound) {
|
||||
UIManager.UIAll.BigMessageSound = CUIConfig::EUISound::EndRound;
|
||||
UIManager.UIAll.BigMessageSoundVariant = 0;
|
||||
|
||||
if (WinnerScore == Null) {
|
||||
UIModules_BigMessage::SetMessage(_("|Match|Draw"));
|
||||
declare Text Message = _("|Match|Draw");
|
||||
if (WinnerScore != Null) {
|
||||
UIModules_BigMessage::SetMessage("$<%1$> wins the match!", WinnerScore.User.WebServicesUserId);
|
||||
} else {
|
||||
UIModules_BigMessage::SetMessage(_("$<%1$> wins the match!"), WinnerScore.User.WebServicesUserId);
|
||||
UIModules_BigMessage::SetMessage(_("|Match|Draw"));
|
||||
}
|
||||
|
||||
Scores::EndRound();
|
||||
@ -555,23 +581,6 @@ if (Round_ForceEndRound || Round_SkipPauseRound) {
|
||||
// Functions
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
|
||||
|
||||
Void ResetNetworkVariables() {
|
||||
declare netwrite Boolean Net_DisplayUI for Teams[0] = False;
|
||||
Net_DisplayUI = False;
|
||||
declare netwrite Integer Net_NBPlayers for Teams[0] = 0;
|
||||
Net_NBPlayers = 0;
|
||||
declare netwrite Integer Net_PlayersNbAlive for Teams[0] = 0;
|
||||
Net_PlayersNbAlive = 0;
|
||||
declare netwrite Integer Net_NextMalus for Teams[0] = -1;
|
||||
Net_NextMalus = 0;
|
||||
declare netwrite Integer Net_TimeBeforeMalus for Teams[0] = -1;
|
||||
Net_TimeBeforeMalus = 0;
|
||||
declare netwrite Integer Net_RoundsPerMap for Teams[0] = 0;
|
||||
Net_RoundsPerMap = 0;
|
||||
declare netwrite Integer Net_CurrentRoundNb for Teams[0] = 0;
|
||||
Net_CurrentRoundNb = 0;
|
||||
}
|
||||
|
||||
/** Get the Time Before the first Malus or NightMare Mode
|
||||
*
|
||||
* @param _StartTime The starting time of the map
|
||||
@ -595,18 +604,31 @@ Void ResetNetworkVariables() {
|
||||
|
||||
/** Update the Scores Table with hidden custom points
|
||||
*
|
||||
* @param _User The User who is eliminated
|
||||
* @param _OverrideTime Compute time because it not ended the Map
|
||||
* @param _EliminatedPlayer The Player who is eliminated
|
||||
* @param _EventType Type of event that led to the update (EndRace or GiveUp)
|
||||
*/
|
||||
Void UpdateCustomRanking(CUser _User, Boolean _OverrideTime) {
|
||||
if (_User == Null) return;
|
||||
Void UpdateCustomRanking(CSmPlayer _EliminatedPlayer, Integer _EventType) {
|
||||
declare Integer[Text] CustomTimes for This;
|
||||
declare Text[] AccountIdsOfPlayers for This;
|
||||
foreach (Score in Scores) {
|
||||
if (Score == Null) continue;
|
||||
declare CSmPlayer Player = GetPlayer(Score.User.Login);
|
||||
if (Player == Null) continue;
|
||||
if (Player.SpawnStatus == CSmPlayer::ESpawnStatus::NotSpawned) {
|
||||
|
||||
if (_OverrideTime) {
|
||||
declare Integer[Text] CustomTimes for This = [];
|
||||
CustomTimes[_User.WebServicesUserId] = Now - StartTime;
|
||||
UIModules_ScoresTable::SetCustomTimes(CustomTimes);
|
||||
Scores::UpdatePlayerBestRaceIfBetter(Player);
|
||||
if (_EliminatedPlayer != Null && _EliminatedPlayer == Player) {
|
||||
if (_EventType == Events::C_Type_GiveUp || _EventType == Events::C_Type_Eliminated) {
|
||||
CustomTimes[Score.User.WebServicesUserId] = Now - StartTime;
|
||||
}
|
||||
UIManager.UIAll.SendChat("""$<$ff3$> Player $<$ff9{{{Player.User.Name}}}$> is eliminated""");
|
||||
}
|
||||
} else {
|
||||
Scores::SetPlayerRoundPoints(Score,PlayersNbDead);
|
||||
}
|
||||
}
|
||||
UIManager.UIAll.SendChat("""$<$ff3$> Player $<$ff9{{{_User.Name}}}$> is eliminated""");
|
||||
UIModules_ScoresTable::DisplayOnly(AccountIdsOfPlayers);
|
||||
UIModules_ScoresTable::SetCustomTimes(CustomTimes);
|
||||
}
|
||||
|
||||
/** Update the scores table footer text
|
||||
@ -618,7 +640,7 @@ Void ResetNetworkVariables() {
|
||||
Footer ^= "Malus disabled";
|
||||
} else {
|
||||
declare Text[] Parts;
|
||||
declare Text Message = "";
|
||||
declare Message = "";
|
||||
if (S_TimeBeforeMalus >= 0) {
|
||||
if (Parts.count > 0) Message ^= "\n";
|
||||
Message ^= """%{{{Parts.count + 1}}}{{{TL::TimeToText(S_TimeBeforeMalus*1000)}}}""";
|
||||
@ -732,7 +754,7 @@ Boolean SetMalus(CSmPlayer _Player, Integer _Type) {
|
||||
* @param _Player Malus Index
|
||||
*/
|
||||
Void SetML() {
|
||||
declare Real TotalWidth = 44.5;
|
||||
declare TotalWidth = 44.5;
|
||||
|
||||
declare Text MLText = """
|
||||
<manialink name="LMS_InfoPanel" version="3">
|
||||
@ -766,7 +788,6 @@ Void SetML() {
|
||||
{{{C_Malus_GravityCoef25}}} => "25% Gravity", {{{C_Malus_Nightmare}}} => "NightMare"]
|
||||
|
||||
main() {
|
||||
declare netread Boolean Net_DisplayUI for Teams[0];
|
||||
declare netread Integer Net_NBPlayers for Teams[0];
|
||||
declare netread Integer Net_PlayersNbAlive for Teams[0];
|
||||
declare netread Integer Net_NextMalus for Teams[0];
|
||||
@ -774,7 +795,6 @@ Void SetML() {
|
||||
declare netread Integer Net_RoundsPerMap for Teams[0];
|
||||
declare netread Integer Net_CurrentRoundNb for Teams[0];
|
||||
|
||||
declare Boolean Last_DisplayUI;
|
||||
declare Integer Last_PlayersNbAlive;
|
||||
declare Integer Last_NextMalus;
|
||||
declare Integer Last_TimeBeforeMalus;
|
||||
@ -783,28 +803,15 @@ Void SetML() {
|
||||
|
||||
declare Boolean NeedUpdateChrono = False;
|
||||
|
||||
declare CMlFrame Frame_Global <=> (Page.GetFirstChild("frame-global") as CMlFrame);
|
||||
declare CMlLabel Label_PlayersAlive <=> (Frame_Global.GetFirstChild("label-playersalive") as CMlLabel);
|
||||
declare CMlLabel Label_NextMalus <=> (Frame_Global.GetFirstChild("label-nextmalus") as CMlLabel);
|
||||
declare CMlLabel Label_TimeBeforeMalus <=> (Frame_Global.GetFirstChild("label-timebeforemalus") as CMlLabel);
|
||||
declare CMlLabel Label_Info_RoundsPerMap <=> (Frame_Global.GetFirstChild("label-info-roundspermap") as CMlLabel);
|
||||
declare CMlLabel Label_RoundsPerMap <=> (Frame_Global.GetFirstChild("label-roundspermap") as CMlLabel);
|
||||
declare Label_PlayersAlive <=> (Page.GetFirstChild("label-playersalive") as CMlLabel);
|
||||
declare Label_NextMalus <=> (Page.GetFirstChild("label-nextmalus") as CMlLabel);
|
||||
declare Label_TimeBeforeMalus <=> (Page.GetFirstChild("label-timebeforemalus") as CMlLabel);
|
||||
declare Label_Info_RoundsPerMap <=> (Page.GetFirstChild("label-info-roundspermap") as CMlLabel);
|
||||
declare Label_RoundsPerMap <=> (Page.GetFirstChild("label-roundspermap") as CMlLabel);
|
||||
|
||||
while(True) {
|
||||
yield;
|
||||
|
||||
if (Last_DisplayUI != Net_DisplayUI) {
|
||||
Last_DisplayUI = Net_DisplayUI;
|
||||
|
||||
AnimMgr.Flush(Frame_Global);
|
||||
if (Last_DisplayUI) {
|
||||
Frame_Global.Visible = True;
|
||||
AnimMgr.Add(Frame_Global, "<a pos=\"-160 0\"/>", 300, CAnimManager::EAnimManagerEasing::Linear);
|
||||
} else {
|
||||
AnimMgr.Add(Frame_Global, "<a hidden=1 pos=\"-225 0\"/>", 300, CAnimManager::EAnimManagerEasing::Linear);
|
||||
}
|
||||
}
|
||||
|
||||
if (Last_CurrentRoundNb != Net_CurrentRoundNb) {
|
||||
Last_CurrentRoundNb = Net_CurrentRoundNb;
|
||||
if (Last_RoundsPerMap > 0) {
|
||||
@ -856,7 +863,7 @@ Void SetML() {
|
||||
<style class="text-ingame-number" textfont="GameFontBlack" textcolor="ffffff" textsize="1.25" valign="center2" textprefix="$i"/>
|
||||
</stylesheet>
|
||||
|
||||
<frame z-index="-2" id="frame-global" size="{{{TotalWidth + 20}}} 180" pos="-225 0" valign="center" hidden=1>
|
||||
<frame z-index="-2" id="frame-global" size="{{{TotalWidth + 20}}} 180" pos="-160 0" valign="center">
|
||||
<quad id="quad-info-bg" pos="0 7.75" size="{{{TotalWidth + 4}}} 21" valign="center" z-index="-3" bgcolor="000" opacity="0.5"/>
|
||||
<label id="label-info-roundspermap" pos="1 15" size="{{{TotalWidth/1.75}}} 10" class="text-ingame-text" text="Rounds" halign="left"/>
|
||||
<label pos="1 10" size="{{{TotalWidth/1.75}}} 10" class="text-ingame-text" text="Players Alive" halign="left" />
|
||||
@ -922,62 +929,6 @@ Void SetML() {
|
||||
Layers::Create("LMS_MapInfo", MLText);
|
||||
Layers::SetType("LMS_MapInfo", CUILayer::EUILayerType::Normal);
|
||||
Layers::Attach("LMS_MapInfo");
|
||||
|
||||
MLText = """
|
||||
<manialink name="LMS_AFKManager" version="3">
|
||||
<script><!--
|
||||
#Include "MathLib" as ML
|
||||
|
||||
main() {
|
||||
declare CMlFrame Frame_Global = (Page.GetFirstChild("frame-global") as CMlFrame);
|
||||
|
||||
wait(InputPlayer != Null);
|
||||
|
||||
declare netread Integer Net_LMS_AFKIdleTime for Teams[0] = 120000;
|
||||
declare Integer Last_AFKIdleTime;
|
||||
declare Integer Last_AFKDisplayTime;
|
||||
|
||||
declare Integer Last_NextCheck;
|
||||
|
||||
while(True) {
|
||||
yield;
|
||||
|
||||
if (Now > Last_NextCheck) {
|
||||
Last_NextCheck = Now + 500;
|
||||
|
||||
if (Last_AFKIdleTime != Net_LMS_AFKIdleTime) {
|
||||
Last_AFKIdleTime = Net_LMS_AFKIdleTime;
|
||||
Last_AFKDisplayTime = Last_AFKIdleTime - ML::Clamp(ML::FloorInteger(Net_LMS_AFKIdleTime * 0.33), 3000, 20000);
|
||||
}
|
||||
|
||||
// Check if player is AFK or not
|
||||
if (Last_AFKIdleTime > 0 && Input.TimeSinceLatestActivity > Last_AFKIdleTime) {
|
||||
log("Player is AFK");
|
||||
Playground.QuitServer(False);
|
||||
} else if (Last_AFKIdleTime > 0 && Input.TimeSinceLatestActivity > Last_AFKDisplayTime) {
|
||||
Frame_Global.Visible = True;
|
||||
} else {
|
||||
Frame_Global.Visible = False;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
--></script>
|
||||
<stylesheet>
|
||||
<style class="text" textfont="GameFontBlack" textcolor="ffffffff" textsize="8" valign="center2" halign="center"/>
|
||||
</stylesheet>
|
||||
|
||||
<frame id="frame-global" pos="0 40" hidden="1">
|
||||
<quad size="150 35" halign="center" z-index="-1" bgcolor="000" opacity="0.7"/>
|
||||
<label class="text" pos="0 -8" size="140 10" text="AFK Warning"/>
|
||||
<label class="text" pos="0 -21.5" size="140 20" autonewline=1 textsize="4" text="Move your mouse or press a key on your keyboard or gamepad to prevent to be kicked"/>
|
||||
</frame>
|
||||
|
||||
</manialink>
|
||||
""";
|
||||
Layers::Create("LMS_AFKManager", MLText);
|
||||
Layers::SetType("LMS_AFKManager", CUILayer::EUILayerType::Normal);
|
||||
Layers::Attach("LMS_AFKManager");
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user