static void Postfix(ref PhotonPlayer newPhotonPlayer) { if (PhotonNetwork.isMasterClient && ModMessageHelper.Instance.GetPlayerMods(newPhotonPlayer).Contains(ModMessageHelper.Instance.GetModName("PacifistLabel"))) { ModMessage.SendRPC("Dragon.PacifistLabel", "Pacifist_Label.RecievePacifistRunInfo", newPhotonPlayer, new object[] { PLServer.Instance.PacifistRun.GetDecrypted() }); } }
static void Postfix(ref PhotonPlayer newPhotonPlayer) { if (PhotonNetwork.isMasterClient && ModMessageHelper.Instance.GetPlayerMods(newPhotonPlayer).Contains(ModMessageHelper.Instance.GetModName("InsaneFire"))) { ModMessage.SendRPC("Dragon.InsaneFire", "InsaneFire.O2Rate", newPhotonPlayer, new object[] { Global.O2Consumption }); } }
static void Postfix(ref PhotonPlayer newPhotonPlayer) { if (PhotonNetwork.isMasterClient && ModMessageHelper.Instance.GetPlayerMods(newPhotonPlayer).Contains(ModMessageHelper.Instance.GetModName("Max_Players"))) { ModMessage.SendRPC("Dragon.Max_Players", "Max_Players.SendRoleLeads", newPhotonPlayer, new object[] { Global.roleleads }); } }
static void Postfix()//keeps client synced with host if Pacifist run state has changed { if (PhotonNetwork.isMasterClient && CachedPacifistRun != PLServer.Instance.PacifistRun) {//checks whether host needs to update clients (they should have been initially synced by the login message) CachedPacifistRun = PLServer.Instance.PacifistRun; foreach (PLPlayer player in PLServer.Instance.AllPlayers) {//for every player in PLServer.AllPlayers, check they have the mod and are not the local player before sending ModMessage containing current pacifist state. PhotonPlayer photonplayer = player.GetPhotonPlayer(); if (!player.IsBot && ModMessageHelper.Instance.GetPlayerMods(photonplayer).Contains(ModMessageHelper.Instance.GetModName("PacifistLabel")) && photonplayer != PhotonNetwork.player) { ModMessage.SendRPC("Dragon.PacifistLabel", "Pacifist_Label.RecievePacifistRunInfo", photonplayer, new object[] { PLServer.Instance.PacifistRun.GetDecrypted() }); } } } }
public override void Execute(string arguments) { string[] args = new string[2]; args = arguments.Split(' '); int[] CommandArg = new int[2]; bool[] ArgConvertSuccess = new bool[2]; string LowerCaseArg = args[0].ToLower(); if (PhotonNetwork.isMasterClient) { if (args.Length >= 1 && !string.IsNullOrEmpty(LowerCaseArg)) { if (args.Length >= 2) { ArgConvertSuccess[0] = int.TryParse(args[1], out CommandArg[0]); if (args.Length >= 3) { ArgConvertSuccess[1] = int.TryParse(args[2], out CommandArg[1]); } } PLPlayer player = null; switch (LowerCaseArg) { default: Messaging.Notification("Not a valid subcommand. Subcommands: SetPlayerLimit, SetSlotLimit, kit, SetRoleLead ; The short versions of the commands are their capital letters, ie: SetPlayerLimit = spl"); break; case "spl": case "setplayerlimit": if (ArgConvertSuccess[0]) { if (CommandArg[0] > byte.MaxValue) { Messaging.Notification("Cannot input a value higher than 255"); break; } Global.MaxPlayers = (byte)CommandArg[0]; PLXMLOptionsIO.Instance.CurrentOptions.SetStringValue("MaxPlayerLimit", $"{Global.MaxPlayers}"); PhotonNetwork.room.MaxPlayers = CommandArg[0]; Messaging.Notification($"set room player limit to {CommandArg[0]}"); } else { Messaging.Notification("Use a number. example: /setplayerlimit 2"); } break; case "ssl": case "setslotlimit": if (ArgConvertSuccess[1]) { int classid = CommandArg[0]; if (!ArgConvertSuccess[0]) { classid = HelperMethods.GetClassIDFromClassName(args[1], out ArgConvertSuccess[0]); } if (ArgConvertSuccess[0]) { Global.rolelimits[classid] = CommandArg[1]; //Protect against rolelimits.sum being greater than 255 int num = Global.rolelimits.Sum(); if (num > 255) { Global.MaxPlayers = 255; } else { Global.MaxPlayers = (byte)num; } PhotonNetwork.room.MaxPlayers = Global.MaxPlayers; Messaging.Notification($"{PLPlayer.GetClassNameFromID(classid)} player limit set to {CommandArg[1]}. Player limit is now {Global.MaxPlayers}"); SetSavedPlayerLimits(); } } else { Global.Generateplayercount(); Messaging.Notification($"current count : Capacity: \nCap {Global.playercount[1]} : {Global.rolelimits[0]} Pil {Global.playercount[2]} : {Global.rolelimits[1]} \nSci {Global.playercount[3]} : {Global.rolelimits[2]} Wep {Global.playercount[4]} : {Global.rolelimits[3]} Eng {Global.playercount[5]} : {Global.rolelimits[4]}"); } break; case "kit": { player = PLServer.Instance.GetPlayerFromPlayerID(CommandArg[0]); if (!ArgConvertSuccess[0] && args.Length >= 2) { player = PLServer.Instance.GetPlayerFromPlayerID(HelperMethods.GetClassIDFromClassName(args[1], out ArgConvertSuccess[0])); } if (ArgConvertSuccess[0]) { int level = 0; if (ArgConvertSuccess[1]) { level = CommandArg[1]; } if (player != null) { player.MyInventory.UpdateItem(PLServer.Instance.PawnInvItemIDCounter++, 2, 0, level, 1); if (PLServer.Instance.CrewFactionID == 4) { player.MyInventory.UpdateItem(PLServer.Instance.PawnInvItemIDCounter++, 24, 0, level, 2); } else { player.MyInventory.UpdateItem(PLServer.Instance.PawnInvItemIDCounter++, 3, 0, level, 2); } player.MyInventory.UpdateItem(PLServer.Instance.PawnInvItemIDCounter++, 4, 0, level, 3); } } else { Messaging.Notification("Cannot find specified player. Try using a player id or class letter. Set item levels with a 2nd number. usage: /mp kit p 0"); } break; } case "kit1": { player = PLServer.Instance.GetPlayerFromPlayerID(CommandArg[0]); if (!ArgConvertSuccess[0] && args.Length >= 2) { player = PLServer.Instance.GetPlayerFromPlayerID(HelperMethods.GetClassIDFromClassName(args[1], out ArgConvertSuccess[0])); } if (ArgConvertSuccess[0]) { int level = 0; if (ArgConvertSuccess[1]) { level = CommandArg[1]; } if (player != null) { player.MyInventory.UpdateItem(PLServer.Instance.PawnInvItemIDCounter++, 10, 0, level, 1); player.MyInventory.UpdateItem(PLServer.Instance.PawnInvItemIDCounter++, 12, 0, level, 2); player.MyInventory.UpdateItem(PLServer.Instance.PawnInvItemIDCounter++, 16, 0, level, 3); if (PLServer.Instance.CrewFactionID == 4) { player.MyInventory.UpdateItem(PLServer.Instance.PawnInvItemIDCounter++, 24, 0, level, 4); } else { player.MyInventory.UpdateItem(PLServer.Instance.PawnInvItemIDCounter++, 3, 0, level, 4); } player.MyInventory.UpdateItem(PLServer.Instance.PawnInvItemIDCounter++, 4, 0, level, 5); } } else { Messaging.Notification("Cannot find specified player. Try using a player id or class letter. Set item levels with a 2nd number. usage: /mp kit p 0"); } break; } case "kit2": player = PLServer.Instance.GetPlayerFromPlayerID(CommandArg[0]); if (!ArgConvertSuccess[0] && args.Length >= 2) { player = PLServer.Instance.GetPlayerFromPlayerID(HelperMethods.GetClassIDFromClassName(args[1], out ArgConvertSuccess[0])); } if (ArgConvertSuccess[0]) { int level = 0; if (ArgConvertSuccess[1]) { level = CommandArg[1]; } if (player != null) { player.MyInventory.UpdateItem(PLServer.Instance.PawnInvItemIDCounter++, 9, 0, level, 1); player.MyInventory.UpdateItem(PLServer.Instance.PawnInvItemIDCounter++, 7, 0, level, 2); player.MyInventory.UpdateItem(PLServer.Instance.PawnInvItemIDCounter++, 26, 0, level, 3); if (PLServer.Instance.CrewFactionID == 4) { player.MyInventory.UpdateItem(PLServer.Instance.PawnInvItemIDCounter++, 24, 0, level, 4); } else { player.MyInventory.UpdateItem(PLServer.Instance.PawnInvItemIDCounter++, 3, 0, level, 4); } player.MyInventory.UpdateItem(PLServer.Instance.PawnInvItemIDCounter++, 4, 0, level, 5); } } else { Messaging.Notification("Cannot find specified player. Try using a player id or class letter. Set item levels with a 2nd number. usage: /mp kit p 0"); } break; case "kit3": player = PLServer.Instance.GetPlayerFromPlayerID(CommandArg[0]); if (!ArgConvertSuccess[0] && args.Length >= 2) { player = PLServer.Instance.GetPlayerFromPlayerID(HelperMethods.GetClassIDFromClassName(args[1], out ArgConvertSuccess[0])); } if (ArgConvertSuccess[0]) { int level = 0; if (ArgConvertSuccess[1]) { level = CommandArg[1]; } if (player != null) { player.MyInventory.UpdateItem(PLServer.Instance.PawnInvItemIDCounter++, 2, 0, level, 1); player.MyInventory.UpdateItem(PLServer.Instance.PawnInvItemIDCounter++, 19, 0, level, 2); player.MyInventory.UpdateItem(PLServer.Instance.PawnInvItemIDCounter++, 33, 0, level, 3); if (PLServer.Instance.CrewFactionID == 4) { player.MyInventory.UpdateItem(PLServer.Instance.PawnInvItemIDCounter++, 24, 0, level, 4); } else { player.MyInventory.UpdateItem(PLServer.Instance.PawnInvItemIDCounter++, 3, 0, level, 4); } player.MyInventory.UpdateItem(PLServer.Instance.PawnInvItemIDCounter++, 4, 0, level, 5); } } else { Messaging.Notification("Cannot find specified player. Try using a player id or class letter. Set item levels with a 2nd number. usage: /mp kit p 0"); } break; case "setrolelead": case "srl": if (ArgConvertSuccess[1]) { int classid = CommandArg[0]; if (!ArgConvertSuccess[0]) { classid = HelperMethods.GetClassIDFromClassName(args[1], out ArgConvertSuccess[0]); } if (ArgConvertSuccess[0]) { if (classid > -1 && classid < 5) { Global.roleleads[classid] = CommandArg[1]; foreach (PhotonPlayer photonPlayer in ModMessageHelper.Instance.PlayersWithMods.Keys) { if (ModMessageHelper.Instance.GetPlayerMods(photonPlayer).Contains(ModMessageHelper.Instance.GetModName("Max_Players"))) { ModMessage.SendRPC("Dragon.Max_Players", "Max_Players.SendRoleLeads", photonPlayer, new object[] { Global.roleleads }); } } Messaging.Notification($"Player of ID {CommandArg[1]} is now the role lead of {PLPlayer.GetClassNameFromID(classid)}"); } else //classid is not in bounds { Messaging.Notification("Received a number not equal to a number between 0-4"); } } else //Second arg conversion was successfull, first was not. { Messaging.Notification("Could not find classID, set it to the first letter of the player's class or their class ID (class names in displayed order 0-4)"); } } else //Second arg conversion was unsuccessfull { Messaging.Notification("Did not detect a second argument! Try using a number"); } break; } } else { Messaging.Notification("Use a Subcommand. Subcommands: SetPlayerLimit, SetSlotLimit, kit, SetRoleLead ; The short versions of the commands are their capital letters, ie: SetPlayerLimit = spl"); } } else { Messaging.Notification("Must be host to perform this action."); } }
public bool Execute(string arguments, int SenderID) { if (!PhotonNetwork.isMasterClient) { Messaging.Notification("Must be Host to use commands"); return(false); } string[] Args = arguments.Split(' '); bool ArgConvertSuccess = false; bool FloatConvertSuccess = false; int CommandArg = 0; float CommandFloat = 0f; if (Args.Length > 1) { ArgConvertSuccess = int.TryParse(Args[1], out CommandArg); FloatConvertSuccess = float.TryParse(Args[1], out CommandFloat); } switch (Args[0].ToLower()) { case "limit": if (ArgConvertSuccess) { Global.SavedFireCap = CommandArg; Global.FireCap = CommandArg; Global.SaveSettings(); Messaging.Notification($"Set fire limit to {CommandArg}"); } else { Messaging.Notification("Couldn't set fire limit, try using a number. ex: /if limit 30"); } break; case "o2rate": case "o2r": if (FloatConvertSuccess) { Global.O2Consumption = CommandFloat * .0005f; Global.SavedO2Consumption = Global.O2Consumption; Global.SaveSettings(); ModMessage.SendRPC("Dragon.InsaneFire", "InsaneFire.O2Rate", PhotonTargets.Others, new object[] { Global.O2Consumption }); //players who join after last message do not know new o2consumptionrate string o2percent = (CommandFloat * 100).ToString("000") + "%"; Messaging.Notification($"Set O2 consumption to {o2percent}"); } else { Messaging.Notification("Couldn't set o2 comsumption rate, try using a number. ex: /if o2rate .5"); } break; case "toggle": Global.PluginIsOn = !Global.PluginIsOn; if (Global.PluginIsOn) { Global.FireCap = Global.SavedFireCap; Global.O2Consumption = Global.SavedO2Consumption; } else { Global.FireCap = 20; Global.O2Consumption = 0.0005f; } foreach (PhotonPlayer player in ModMessageHelper.Instance.PlayersWithMods.Keys) //players who join after last message do not know new o2consumptionrate { if (ModMessageHelper.Instance.GetPlayerMods(player).Contains(ModMessageHelper.Instance.GetModName("InsaneFire"))) { ModMessage.SendRPC("Dragon.InsaneFire", "InsaneFire.O2Rate", player, new object[] { Global.O2Consumption }); } } Global.SaveSettings(); string message = Global.PluginIsOn ? "On" : "Off"; Messaging.Notification($"Plugin is now {message}"); break; case "dbg": Global.GetSettings(out bool b, out int i, out float f); Messaging.Notification($"on: {b} Firecap: {i} O2Cons: {f}\nCached: {Global.SavedFireCap} {Global.SavedO2Consumption}\nCurrent: {Global.PluginIsOn} {Global.FireCap} {Global.O2Consumption}"); break; default: Messaging.Notification("no Subcommand Detected. Subcommands: limit, o2Rate, toggle, dbg. capitalized letters can be initialized"); break; } return(false); }