示例#1
0
	public override void onPlayerJoin(PlayerEvent ev)

	{

	    this.motd(ev.getPlayer());

	    if (kickorban == "kick" && !ev.getPlayer().hasPermissions("terracmd.antihack.bypass"))

	    {

		if (ev.getPlayer().statLifeMax > 400 | ev.getPlayer().statManaMax > 200)

		{

		    NetMessage.SendData(2, ev.getPlayer().whoAmi, -1, "You were kicked for having hacked stats!", 0, 0f, 0f, 0f);

		    Console.WriteLine(ev.getPlayer().name + " was kicked for hacking their health or mana!");

		}

	    }

	}
示例#2
0
 public void Spawn()
 {
     PlayerEvent playerEvent = new PlayerEvent(this);
     PluginManager.callHook(Hook.PLAYER_SPAWN, playerEvent);
     if (playerEvent.getState())
     {
         if (this.whoAmi == Main.myPlayer)
         {
             this.FindSpawn();
             if (!Player.CheckSpawn(this.SpawnX, this.SpawnY))
             {
                 this.SpawnX = -1;
                 this.SpawnY = -1;
             }
         }
         if (Main.netMode == 1 && this.whoAmi == Main.myPlayer)
         {
             NetMessage.SendData(12, -1, -1, "", Main.myPlayer, 0f, 0f, 0f);
             Main.gameMenu = false;
         }
         this.headPosition = default(Vector2);
         this.bodyPosition = default(Vector2);
         this.legPosition = default(Vector2);
         this.headRotation = 0f;
         this.bodyRotation = 0f;
         this.legRotation = 0f;
         if (this.statLife <= 0)
         {
             this.statLife = 100;
             this.breath = this.breathMax;
             if (this.spawnMax)
             {
                 this.statLife = this.statLifeMax;
                 this.statMana = this.statManaMax;
             }
         }
         this.immune = true;
         this.dead = false;
         this.immuneTime = 0;
         this.active = true;
         if (this.SpawnX >= 0 && this.SpawnY >= 0)
         {
             this.position.X = (float)(this.SpawnX * 16 + 8 - this.width / 2);
             this.position.Y = (float)(this.SpawnY * 16 - this.height);
         }
         else
         {
             this.position.X = (float)(Main.spawnTileX * 16 + 8 - this.width / 2);
             this.position.Y = (float)(Main.spawnTileY * 16 - this.height);
             for (int i = Main.spawnTileX - 1; i < Main.spawnTileX + 2; i++)
             {
                 for (int j = Main.spawnTileY - 3; j < Main.spawnTileY; j++)
                 {
                     if (Main.tileSolid[(int)Main.tile[i, j].type] && !Main.tileSolidTop[(int)Main.tile[i, j].type])
                     {
                         if (Main.tile[i, j].liquid > 0)
                         {
                             Main.tile[i, j].lava = false;
                             Main.tile[i, j].liquid = 0;
                             WorldGen.SquareTileFrame(i, j, true);
                         }
                         WorldGen.KillTile(i, j, false, false, false);
                     }
                 }
             }
         }
         this.wet = Collision.WetCollision(this.position, this.width, this.height);
         this.wetCount = 0;
         this.lavaWet = false;
         this.fallStart = (int)(this.position.Y / 16f);
         this.velocity.X = 0f;
         this.velocity.Y = 0f;
         this.talkNPC = -1;
         if (this.pvpDeath)
         {
             this.pvpDeath = false;
             this.immuneTime = 300;
             this.statLife = this.statLifeMax;
         }
         if (this.whoAmi == Main.myPlayer)
         {
             Lighting.lightCounter = Lighting.lightSkip + 1;
             Main.screenPosition.X = this.position.X + (float)(this.width / 2) - (float)(Main.screenWidth / 2);
             Main.screenPosition.Y = this.position.Y + (float)(this.height / 2) - (float)(Main.screenHeight / 2);
         }
     }
 }
示例#3
0
 public static void syncPlayers()
 {
     bool flag = false;
     for (int i = 0; i < 255; i++)
     {
         int num = 0;
         if (Main.player[i].active)
         {
             num = 1;
         }
         if (Netplay.serverSock[i].state == 10)
         {
             if (Main.autoShutdown && !flag)
             {
                 string text = Netplay.serverSock[i].tcpClient.Client.RemoteEndPoint.ToString();
                 string a = text;
                 for (int j = 0; j < text.Length; j++)
                 {
                     if (text.Substring(j, 1) == ":")
                     {
                         a = text.Substring(0, j);
                     }
                 }
                 if (a == "127.0.0.1")
                 {
                     flag = true;
                 }
             }
             NetMessage.SendData(14, -1, i, "", i, (float)num, 0f, 0f);
             NetMessage.SendData(13, -1, i, "", i, 0f, 0f, 0f);
             NetMessage.SendData(16, -1, i, "", i, 0f, 0f, 0f);
             NetMessage.SendData(30, -1, i, "", i, 0f, 0f, 0f);
             NetMessage.SendData(45, -1, i, "", i, 0f, 0f, 0f);
             NetMessage.SendData(42, -1, i, "", i, 0f, 0f, 0f);
             NetMessage.SendData(4, -1, i, Main.player[i].name, i, 0f, 0f, 0f);
             for (int j = 0; j < 44; j++)
             {
                 NetMessage.SendData(5, -1, i, Main.player[i].inventory[j].name, i, (float)j, 0f, 0f);
             }
             NetMessage.SendData(5, -1, i, Main.player[i].armor[0].name, i, 44f, 0f, 0f);
             NetMessage.SendData(5, -1, i, Main.player[i].armor[1].name, i, 45f, 0f, 0f);
             NetMessage.SendData(5, -1, i, Main.player[i].armor[2].name, i, 46f, 0f, 0f);
             NetMessage.SendData(5, -1, i, Main.player[i].armor[3].name, i, 47f, 0f, 0f);
             NetMessage.SendData(5, -1, i, Main.player[i].armor[4].name, i, 48f, 0f, 0f);
             NetMessage.SendData(5, -1, i, Main.player[i].armor[5].name, i, 49f, 0f, 0f);
             NetMessage.SendData(5, -1, i, Main.player[i].armor[6].name, i, 50f, 0f, 0f);
             NetMessage.SendData(5, -1, i, Main.player[i].armor[7].name, i, 51f, 0f, 0f);
             if (!Netplay.serverSock[i].announced)
             {
                 PlayerEvent playerEvent = new PlayerEvent(Main.player[i]);
                 PluginManager.callHook(Hook.PLAYER_JOIN, playerEvent);
                 if (!playerEvent.getState())
                 {
                     NetMessage.SendData(2, i, -1, "Disconnected.", 0, 0f, 0f, 0f);
                     return;
                 }
                 Netplay.serverSock[i].announced = true;
                 NetMessage.SendData(25, -1, i, Main.player[i].name + " has joined.", 255, 255f, 240f, 20f);
                 if (Main.dedServ)
                 {
                     System.Console.WriteLine(Main.player[i].name + " has joined.");
                 }
             }
         }
         else
         {
             NetMessage.SendData(14, -1, i, "", i, (float)num, 0f, 0f);
             if (Netplay.serverSock[i].announced)
             {
                 Netplay.serverSock[i].announced = false;
                 NetMessage.SendData(25, -1, i, Netplay.serverSock[i].oldName + " has left.", 255, 255f, 240f, 20f);
                 if (Main.dedServ)
                 {
                     System.Console.WriteLine(Netplay.serverSock[i].oldName + " has left.");
                 }
             }
         }
     }
     if (Main.autoShutdown && !flag)
     {
         WorldGen.saveWorld(false);
         Netplay.disconnect = true;
         return;
     }
 }
示例#4
0
 public void KillMe(double dmg, int hitDirection, bool pvp = false)
 {
     if ((!Main.godMode || Main.myPlayer != this.whoAmi) && !this.dead)
     {
         if (pvp)
         {
             this.pvpDeath = true;
         }
         PlayerEvent playerEvent = new PlayerEvent(this);
         PluginManager.callHook(Hook.PLAYER_DEATH, playerEvent);
         if (!playerEvent.getState())
         {
             this.pvpDeath = false;
             this.statLife++;
         }
         else
         {
             this.headVelocity.Y = (float)Main.rand.Next(-40, -10) * 0.1f;
             this.bodyVelocity.Y = (float)Main.rand.Next(-40, -10) * 0.1f;
             this.legVelocity.Y = (float)Main.rand.Next(-40, -10) * 0.1f;
             this.headVelocity.X = (float)Main.rand.Next(-20, 21) * 0.1f + (float)(2 * hitDirection);
             this.bodyVelocity.X = (float)Main.rand.Next(-20, 21) * 0.1f + (float)(2 * hitDirection);
             this.legVelocity.X = (float)Main.rand.Next(-20, 21) * 0.1f + (float)(2 * hitDirection);
             int num = 0;
             while ((double)num < 20.0 + dmg / (double)this.statLifeMax * 100.0)
             {
                 if (this.boneArmor)
                 {
                     Color color = default(Color);
                 }
                 else
                 {
                     Color color = default(Color);
                 }
                 num++;
             }
             this.dead = true;
             this.respawnTimer = 600;
             this.immuneAlpha = 0;
             if (Main.netMode == 2)
             {
                 NetMessage.SendData(25, -1, -1, this.name + " was slain...", 255, 225f, 25f, 25f);
             }
             if (this.whoAmi == Main.myPlayer)
             {
                 WorldGen.saveToonWhilePlaying();
             }
             if (Main.netMode == 1 && this.whoAmi == Main.myPlayer)
             {
                 int num2 = 0;
                 if (pvp)
                 {
                     num2 = 1;
                 }
                 NetMessage.SendData(44, -1, -1, "", this.whoAmi, (float)hitDirection, (float)((int)dmg), (float)num2);
             }
             if (!pvp && this.whoAmi == Main.myPlayer)
             {
                 this.DropItems();
             }
         }
     }
 }
示例#5
0
 public virtual void onPlayerSpawn(PlayerEvent ev)
 {
 }
示例#6
0
 public virtual void onPlayerJoin(PlayerEvent ev)
 {
 }
示例#7
0
 public virtual void onPlayerDeath(PlayerEvent ev)
 {
 }
示例#8
0
文件: RegionProtect.cs 项目: bbf/TOSP
        public override void onPlayerJoin(PlayerEvent ev)
        {
            Player player = ev.getPlayer();
            CancelPlayerState(player);

            ProtectedRegion region = GetRegion(player.name);
            if (region == null || player.hasPermissions(PERMISSION_USE))
            {
                WisperPlayer(player, "This server offers region protection. After logging in type: /region help");
            }
        }