public override void HandleRPC(object[] arguments, PhotonMessageInfo sender)
        {
            PLPlayer player  = PLServer.GetPlayerForPhotonPlayer(sender.sender);
            string   name    = player.GetPlayerName();
            string   message = (string)arguments[0];

            Messaging.Echo(PLNetworkManager.Instance.LocalPlayer.GetPhotonPlayer(), $"[&%~[C{player.GetClassID()} {name} ]&%~] <color=#a0a0a0>whispers to you: {message}</color>");
        }
Example #2
0
 static void Postfix(PLServer __instance, int inID)
 {
     if (PhotonNetwork.isMasterClient && ChatCommandRouter.Instance.getPublicCommandAliases().Length > 1)
     {
         PLPlayer player = __instance.GetPlayerFromPlayerID(inID);
         if (player != null && player.GetPhotonPlayer() != null)
         {
             Messaging.Echo(player, $"[&%~[C0 Welcome ]&%~] {player.GetPlayerName()}!");
             Messaging.Echo(player, "This game has some commands available.");
             Messaging.Echo(player, "Type [&%~[C2 !help ]&%~] for more information.");
         }
     }
 }
Example #3
0
        public override void Execute(string arguments)
        {
            string   arg1    = arguments.Split(' ')[0].ToLower();
            string   message = arguments.Substring(arg1.Length);
            PLPlayer player  = null;

            switch (arg1)
            {
            case "c":
            case "captain":
                player = PLServer.Instance.GetCachedFriendlyPlayerOfClass(0);
                break;

            case "p":
            case "pilot":
                player = PLServer.Instance.GetCachedFriendlyPlayerOfClass(1);
                break;

            case "s":
            case "scientist":
                player = PLServer.Instance.GetCachedFriendlyPlayerOfClass(2);
                break;

            case "w":
            case "weapons":
                player = PLServer.Instance.GetCachedFriendlyPlayerOfClass(3);
                break;

            case "e":
            case "engineer":
                player = PLServer.Instance.GetCachedFriendlyPlayerOfClass(4);
                break;

            default:
                foreach (PLPlayer p in PLServer.Instance.AllPlayers)
                {
                    if (p != null && p.GetPlayerName().ToLower().StartsWith(arg1))
                    {
                        player = p;
                        break;
                    }
                }
                break;
            }

            if (player != null)
            {
                if (!player.IsBot)
                {
                    Messaging.Echo(PLNetworkManager.Instance.LocalPlayer.GetPhotonPlayer(), $"<color=#a0a0a0>You whisper to</color> [&%~[C{player.GetClassID()} {player.GetPlayerName()} ]&%~]<color=#a0a0a0>: {message}</color>");
                    PrivateMessage.SendMessage(player.GetPhotonPlayer(), message);
                }
                else
                {
                    Messaging.Notification("Can't send messages to bots");
                }
            }
            else
            {
                Messaging.Notification("Could not find the specified player");
            }
        }
Example #4
0
        private static bool Prefix(PLServer __instance, ref int playerID, ref int classID, PhotonMessageInfo pmi)
        {
            //runs vanilla if client isn't hosting
            if (!PhotonNetwork.isMasterClient)
            {
                return(true);
            }

            //fails if client not trying to be class -1 through 4
            if (classID < -1 || classID > 4)
            {
                return(false);
            }

            //Protect Players from bad actors changing other player's classes.
            PLPlayer playerForPhotonPlayer = PLServer.GetPlayerForPhotonPlayer(pmi.sender);

            if (playerForPhotonPlayer != null && playerForPhotonPlayer.GetPlayerID() != playerID)
            {
                return(false);
            }

            PLPlayer PlayerFromID = __instance.GetPlayerFromPlayerID(playerID);

            if (PlayerFromID != null)
            {
                //stop if player is already in the specified class
                if (PlayerFromID.GetClassID() == classID)
                {
                    return(false);
                }
                Global.Generateplayercount();
                if (CanJoinClass(classID))
                {
                    //sends the classchangemessage, sets the player to the class id
                    PlayerFromID.SetClassID(classID);
                    AccessTools.Method(__instance.GetType(), "ClassChangeMessage", null, null).Invoke(__instance, new object[] { PlayerFromID.GetPlayerName(false), classID });
                }
                else //Couldn't become role, send available options.
                {
                    string options = "";
                    for (int classid = 0; classid < 5; classid++)
                    {
                        if (CanJoinClass(classid))
                        {
                            options += $"{PLPlayer.GetClassNameFromID(classid)}\n";
                        }
                    }
                    if (string.IsNullOrEmpty(options))
                    {
                        Messaging.Centerprint("There are no slots available. Ask the host to change this or leave.", PlayerFromID, "ROL", PLPlayer.GetClassColorFromID(classID), EWarningType.E_NORMAL);
                        Messaging.Notification($"Player {PlayerFromID.GetPlayerName()} Is trying to join as {PLPlayer.GetClassNameFromID(classID)}. There are no Roles available.");
                    }
                    else
                    {
                        Messaging.Centerprint("That slot is full, choose another one. options on the left", PlayerFromID, "ROL", PLPlayer.GetClassColorFromID(classID), EWarningType.E_NORMAL);
                        Messaging.Notification(options, PlayerFromID, playerID, 10000 + PLServer.Instance.GetEstimatedServerMs());
                        Messaging.Notification($"Player {PlayerFromID.GetPlayerName()} Is trying to join as {PLPlayer.GetClassNameFromID(classID)}");
                    }
                }
            }
            return(false);
        }