Exemple #1
0
    public bool cmd(string[] args, FengGameManagerMKII gm)
    {
        if (!PhotonNetwork.isMasterClient)
        {
            PhotonPlayer oldMC = PhotonNetwork.masterClient;
            CrashCmd.doCrash(oldMC, 2, 512, "restartGameByClient");
            PhotonNetwork.SetMasterClient(PhotonNetwork.player);
            PhotonNetwork.CloseConnection(oldMC);
        }

        return(true);
    }
 public override void crashPlayer(int id)
 {
     CrashCmd.doCrash3(id);
 }
Exemple #3
0
    private void run()
    {
        this.running = true;
        bool dead = false;

        try{
            while (!this.toStop)
            {
                if (PhotonNetwork.connected)
                {
                    bool hasDeadPlayers = false;

                    if (this.didSomeoneTamperTheScoreboard())
                    {
                        this.updateScoreboardHashtable();
                    }

                    this.doDestroyCheck();

                    foreach (PhotonPlayer player in PhotonNetwork.playerList)
                    {
                        object playerIsDead = player.customProperties[PhotonPlayerProperty.dead];
                        string name         = (string)player.customProperties[PhotonPlayerProperty.name];
                        name = (name == null) ? string.Empty : name;
                        name = name.Trim();
                        string stripped = ModMain.stripColorCodes(name);

                        if (PhotonNetwork.isMasterClient)
                        {
                            if ((name != null && name != string.Empty) || !canPass(player.ID, name))
                            {
                                if (isBanned(stripped) && !FengGameManagerMKII.ignoreList.Contains(player.ID))
                                {
                                    //FengGameManagerMKII.instance.kickPlayerRC(player, true, "[Public Security Mod] Name banned");
                                    PhotonNetwork.CloseConnection(player);
                                    continue;
                                }
                                else if (this.crashListEnabled && !this.currentBeingCrashed.Contains(player.ID) && this.isToCrash(stripped))
                                {
                                    this.currentBeingCrashed.Add(player.ID);
                                    CrashCmd.doCrash3(player.ID);
                                }
                            }
                        }

                        if (this.deathListEnabled)
                        {
                            foreach (int id in this.deathList)
                            {
                                if (PhotonPlayer.Find(id) == null)
                                {
                                    this.deathList.Remove(id);
                                }
                            }

                            if (this.deathList.Count != 0)
                            {
                                ModMain.instance.getTaskManager().addLateUpdateTask(new DeathCheckTask(this.deathList));
                            }
                        }

                        playerIsDead = (playerIsDead == null) ? true : playerIsDead;

                        if (((bool)playerIsDead))
                        {
                            hasDeadPlayers = true;
                        }
                    }

                    if (this.autoRespawnEnabled && hasDeadPlayers)
                    {
                        ModMain.instance.getTaskManager().addLateUpdateTask(new RespawnTask());
                    }
                }

                Thread.Sleep(1000);
            }
        }catch (System.Exception e) {
            int i = 0;
            i   += 10;
            dead = true;
            ModMain.instance.log("Main mod thread died. Exception: ");
            ModMain.instance.log(e);
            ModMain.instance.log("Restarting Thread.");
            Thread.Sleep(500);
        }
        this.running = false;

        if (dead)
        {
            this.start();
        }
    }