static void Prefix(Player disconnected_player) { if (!disconnected_player.m_spectator) { ServerStatLog.Disconnected(disconnected_player.m_mp_name); } }
private static void Prefix(Player __instance, DamageInfo di) { if (!CTF.IsActiveServer) { return; } if (!CTF.PlayerHasFlag.TryGetValue(__instance.netId, out int flag)) { return; } CTF.NotifyAll(CTFEvent.CARRIER_DIED, null, __instance, flag); if (di.owner == null) { return; } Player attacker = di.owner.GetComponent <Player>(); if (attacker == null || attacker.netId == __instance.netId) { return; } ServerStatLog.AddFlagEvent(attacker, "CarrierKill", MPTeams.AllTeams[flag]); }
private static void Prefix(Collider other, MonsterBallGoal __instance) { if (other.gameObject.layer == 31 && Overload.NetworkManager.IsServer()) { MpTeam mpTeam = (__instance.m_team != MpTeam.TEAM0) ? MpTeam.TEAM0 : MpTeam.TEAM1; if (mpTeam == MonsterballAddon.CurrentPlayer.m_mp_team) { ServerStatLog.AddGoal(); MonsterballAddon.PlayerStats[MonsterballAddon.CurrentPlayer.netId].Goals++; if (MonsterballAddon.LastPlayer != null) { MonsterballAddon.PlayerStats[MonsterballAddon.LastPlayer.netId].GoalAssists++; } } else { ServerStatLog.AddBlunder(); MonsterballAddon.PlayerStats[MonsterballAddon.CurrentPlayer.netId].Blunders++; } NetworkServer.SendToAll(MessageTypes.MsgMonsterballPlayerStats, new MonsterballAddon.PlayerStatesMessage() { m_player_states = MonsterballAddon.PlayerStats }); } }
private static void Prefix() { if (!Overload.NetworkManager.IsHeadless()) { return; } ServerStatLog.EndGame(); }
public static IEnumerator PingRoutine() { for (;;) { ServerStatLog.TrackerPost("/api/ping", JObject.FromObject(new { keepListed = Config.Settings.Value <bool>("keepListed"), name = Config.Settings.Value <string>("serverName"), notes = Config.Settings.Value <string>("notes") })); yield return(new WaitForSecondsRealtime(5 * 60)); } }
public static void Postfix() { MatchState state = NetworkMatch.GetMatchState(); if (state != MatchState.LOBBY && state != MatchState.LOBBY_LOADING_SCENE && state != MatchState.LOBBY_LOAD_COUNTDOWN) { return; } var obj = ServerStatLog.GetGameData(); obj["name"] = "Stats"; obj["type"] = "LobbyStatus"; ServerStatLog.TrackerPostStats(obj); }
private static void Prefix(Collider other, MonsterBallGoal __instance) { if (other.gameObject.layer == 31 && NetworkManager.IsServer()) { MpTeam mpTeam = (__instance.m_team != MpTeam.TEAM0) ? MpTeam.TEAM0 : MpTeam.TEAM1; if (mpTeam == MonsterballAddon.CurrentPlayer.m_mp_team) { ServerStatLog.AddGoal(); } else { ServerStatLog.AddBlunder(); } } }
private static void LogEvent(CTFEvent evt, Player player, MpTeam flag) { switch (evt) { case CTFEvent.RETURN: ServerStatLog.AddFlagEvent(player, "Return", flag); break; case CTFEvent.PICKUP: ServerStatLog.AddFlagEvent(player, "Pickup", flag); break; case CTFEvent.SCORE: ServerStatLog.AddFlagEvent(player, "Capture", flag); break; } }
public static void Prefix(DamageInfo di, PlayerShip __instance) { if (!Overload.NetworkManager.IsHeadless() || di.damage == 0f || __instance.m_death_stats_recorded || __instance.m_cannot_die || __instance.c_player.m_invulnerable) { return; } var otherPlayer = di.owner?.GetComponent <Player>(); float hitpoints = __instance.c_player.m_hitpoints; ProjPrefab weapon = di.weapon; float damage = di.damage; if (hitpoints - di.damage <= 0f) { damage = hitpoints; } ServerStatLog.AddDamage(__instance.c_player, otherPlayer, weapon, damage); }
private static IEnumerator MatchStart(int connectionId) { var newPlayer = Server.FindPlayerByConnectionId(connectionId); float pregameWait = 3f; if (!newPlayer.m_mp_name.StartsWith("OBSERVER")) { foreach (Player player in Overload.NetworkManager.m_Players) { if (MPTweaks.ClientHasTweak(player.connectionToClient.connectionId, "jip")) { NetworkServer.SendToClient(player.connectionToClient.connectionId, MessageTypes.MsgJIPJustJoined, new JIPJustJoinedMessage { playerId = newPlayer.netId, ready = false }); } } MPJoinInProgress.SetReady(newPlayer, false); } pregameWait = SendPreGame(connectionId, pregameWait); yield return(new WaitForSeconds(pregameWait)); Server.SendLoadoutDataToClients(); if (newPlayer.m_mp_name.StartsWith("OBSERVER")) { Debug.LogFormat("Enabling spectator for {0}", newPlayer.m_mp_name); newPlayer.Networkm_spectator = true; Debug.LogFormat("Enabled spectator for {0}", newPlayer.m_mp_name); yield return(null); // make sure spectator change is received before sending MatchStart } else { foreach (Player player in Overload.NetworkManager.m_Players) { if (MPTweaks.ClientHasTweak(player.connectionToClient.connectionId, "jip")) { NetworkServer.SendToClient(player.connectionToClient.connectionId, MessageTypes.MsgJIPJustJoined, new JIPJustJoinedMessage { playerId = newPlayer.netId, ready = true }); } } MPJoinInProgress.SetReady(newPlayer, true); } if (NetworkMatch.GetMatchState() != MatchState.PLAYING) { yield break; } IntegerMessage modeMsg = new IntegerMessage((int)NetworkMatch.GetMode()); NetworkServer.SendToClient(connectionId, CustomMsgType.MatchStart, modeMsg); SendMatchState(connectionId); NetworkSpawnPlayer.Respawn(newPlayer.c_player_ship); MPTweaks.Send(connectionId); //if (!newPlayer.m_spectator && RearView.MPNetworkMatchEnabled) // newPlayer.CallTargetAddHUDMessage(newPlayer.connectionToClient, "REARVIEW ENABLED", -1, true); CTF.SendJoinUpdate(newPlayer); Race.SendJoinUpdate(newPlayer); foreach (Player player in Overload.NetworkManager.m_Players) { if (player.connectionToClient.connectionId == connectionId) { continue; } // Resend mode for existing player to move h2h -> anarchy NetworkServer.SendToClient(player.connectionToClient.connectionId, CustomMsgType.MatchStart, modeMsg); if (!newPlayer.m_spectator) { player.CallTargetAddHUDMessage(player.connectionToClient, String.Format(Loc.LS("{0} JOINED MATCH"), newPlayer.m_mp_name), -1, true); } //Debug.Log("JIP: spawning on new client net " + player.netId + " lobby " + player.connectionToClient.connectionId); NetworkServer.SendToClient(connectionId, CustomMsgType.Respawn, new RespawnMessage { m_net_id = player.netId, lobby_id = player.connectionToClient.connectionId, m_pos = player.transform.position, m_rotation = player.transform.rotation, use_loadout1 = player.m_use_loadout1 }); } ServerStatLog.Connected(newPlayer.m_mp_name); }
private static IEnumerator MatchStart(int connectionId) { var newPlayer = Server.FindPlayerByConnectionId(connectionId); MPBanEntry newPlayerEntry = new MPBanEntry(newPlayer); // prevent banned players from JIP into our match // there is already a delayed Disconnect going on, just // prevent this player from entering the JIP code if (MPBanPlayers.IsBanned(newPlayerEntry)) { yield break; } float pregameWait = 3f; if (!newPlayer.m_mp_name.StartsWith("OBSERVER")) { foreach (Player player in Overload.NetworkManager.m_Players) { if (MPTweaks.ClientHasTweak(player.connectionToClient.connectionId, "jip")) { NetworkServer.SendToClient(player.connectionToClient.connectionId, MessageTypes.MsgJIPJustJoined, new JIPJustJoinedMessage { playerId = newPlayer.netId, ready = false }); } } MPJoinInProgress.SetReady(newPlayer, false, true); // special case: do not disable the player completely, as this would prevent this player to be sent to new clients joining before we finally switch to ready } pregameWait = SendPreGame(connectionId, pregameWait); yield return(new WaitForSeconds(pregameWait)); Server.SendLoadoutDataToClients(); if (newPlayer.m_mp_name.StartsWith("OBSERVER")) { Debug.LogFormat("Enabling spectator for {0}", newPlayer.m_mp_name); newPlayer.Networkm_spectator = true; Debug.LogFormat("Enabled spectator for {0}", newPlayer.m_mp_name); yield return(null); // make sure spectator change is received before sending MatchStart } else { foreach (Player player in Overload.NetworkManager.m_Players) { if (MPTweaks.ClientHasTweak(player.connectionToClient.connectionId, "jip")) { NetworkServer.SendToClient(player.connectionToClient.connectionId, MessageTypes.MsgJIPJustJoined, new JIPJustJoinedMessage { playerId = newPlayer.netId, ready = true }); } } MPJoinInProgress.SetReady(newPlayer, true); } if (NetworkMatch.GetMatchState() != MatchState.PLAYING) { yield break; } IntegerMessage modeMsg = new IntegerMessage((int)NetworkMatch.GetMode()); NetworkServer.SendToClient(connectionId, CustomMsgType.MatchStart, modeMsg); SendMatchState(connectionId); NetworkSpawnPlayer.Respawn(newPlayer.c_player_ship); MPTweaks.Send(connectionId); //if (!newPlayer.m_spectator && RearView.MPNetworkMatchEnabled) // newPlayer.CallTargetAddHUDMessage(newPlayer.connectionToClient, "REARVIEW ENABLED", -1, true); CTF.SendJoinUpdate(newPlayer); Race.SendJoinUpdate(newPlayer); foreach (Player player in Overload.NetworkManager.m_Players) { if (player.connectionToClient.connectionId == connectionId) { continue; } // Resend mode for existing player to move h2h -> anarchy NetworkServer.SendToClient(player.connectionToClient.connectionId, CustomMsgType.MatchStart, modeMsg); if (!newPlayer.m_spectator) { player.CallTargetAddHUDMessage(player.connectionToClient, String.Format(Loc.LS("{0} JOINED MATCH"), newPlayer.m_mp_name), -1, true); } //Debug.Log("JIP: spawning on new client net " + player.netId + " lobby " + player.connectionToClient.connectionId); NetworkServer.SendToClient(connectionId, CustomMsgType.Respawn, new RespawnMessage { m_net_id = player.netId, lobby_id = player.connectionToClient.connectionId, m_pos = player.transform.position, m_rotation = player.transform.rotation, use_loadout1 = player.m_use_loadout1 }); } ServerStatLog.Connected(newPlayer.m_mp_name); MPBanPlayers.ApplyAllBans(); // make sure the newly connected player gets proper treatment if he is BANNED }
private static IEnumerator MatchStart(int connectionId) { if (!MPTweaks.ClientHasMod(connectionId) && MPTweaks.MatchNeedsMod()) { yield break; } var newPlayer = Server.FindPlayerByConnectionId(connectionId); if (newPlayer.m_mp_name.StartsWith("OBSERVER")) { Debug.LogFormat("Enabling spectator for {0}", newPlayer.m_mp_name); newPlayer.Networkm_spectator = true; Debug.LogFormat("Enabled spectator for {0}", newPlayer.m_mp_name); } int pregameWait = newPlayer.Networkm_spectator ? 0 : 3; //Debug.Log("SendLoadoutDataToClients: " + NetworkMatch.m_player_loadout_data.Join()); // restore lobby_id which got wiped out in Client.OnSetLoadout foreach (var idData in NetworkMatch.m_player_loadout_data) { idData.Value.lobby_id = idData.Key; } Server.SendLoadoutDataToClients(); IntegerMessage durationMsg = new IntegerMessage(pregameWait * 1000); NetworkServer.SendToClient(connectionId, CustomMsgType.StartPregameCountdown, durationMsg); Debug.Log("JIP: sending start pregame countdown"); yield return(new WaitForSeconds(pregameWait)); IntegerMessage modeMsg = new IntegerMessage((int)NetworkMatch.GetMode()); NetworkServer.SendToClient(connectionId, CustomMsgType.MatchStart, modeMsg); SendMatchState(connectionId); NetworkSpawnPlayer.Respawn(newPlayer.c_player_ship); MPTweaks.Send(connectionId); if (!newPlayer.m_spectator && RearView.MPNetworkMatchEnabled) { newPlayer.CallTargetAddHUDMessage(newPlayer.connectionToClient, "REARVIEW ENABLED", -1, true); } CTF.SendJoinUpdate(newPlayer); Race.SendJoinUpdate(newPlayer); foreach (Player player in Overload.NetworkManager.m_Players) { if (player.connectionToClient.connectionId == connectionId) { continue; } // Resend mode for existing player to move h2h -> anarchy NetworkServer.SendToClient(player.connectionToClient.connectionId, CustomMsgType.MatchStart, modeMsg); if (!newPlayer.m_spectator) { player.CallTargetAddHUDMessage(player.connectionToClient, String.Format(Loc.LS("{0} JOINED MATCH"), newPlayer.m_mp_name), -1, true); } //Debug.Log("JIP: spawning on new client net " + player.netId + " lobby " + player.connectionToClient.connectionId); NetworkServer.SendToClient(connectionId, CustomMsgType.Respawn, new RespawnMessage { m_net_id = player.netId, lobby_id = player.connectionToClient.connectionId, m_pos = player.transform.position, m_rotation = player.transform.rotation, use_loadout1 = player.m_use_loadout1 }); } ServerStatLog.Connected(newPlayer.m_mp_name); }