Exemple #1
0
 public static void placeBlock(Level l, Player p, ushort x, ushort y, ushort z, byte type)
 {
     if (p == null)
         l.Blockchange(x, y, z, type);
     else
         l.Blockchange(p, x, y, z, type);
 }
Exemple #2
0
 public player(Player pl)
 {
     p = pl;
     OldColor = pl.color;
     OldTitle = pl.title;
     OldTitleColor = pl.titlecolor;
 }
Exemple #3
0
 /// <summary>
 /// Checks to see if the player is on this team
 /// </summary>
 /// <param name="p">The player</param>
 /// <returns>If true, then that player is on the team. Otherwise that player isnt</returns>
 public bool isOnTeam(Player p)
 {
     if (members.IndexOf(p) != -1)
         return true;
     else
         return false;
 }
Exemple #4
0
		public override void Use(Player p, string message)
		{
			if (message == "") { Help(p); return; }

			int pos = message.IndexOf(' ');
			Player who = Player.Find(message.Split(' ')[0]);
			if (who == null) { Player.SendMessage(p, "Could not find player."); return; }
			if (p != null && who.group.Permission > p.group.Permission)
			{
				Player.SendMessage(p, "Cannot change the nick of someone of greater rank");
				return;
			}
			string query;
			string newName = "";
			if (message.Split(' ').Length > 1) newName = message.Substring(pos + 1);
			else
			{
				who.DisplayName = who.name;
				Player.GlobalChat(who, who.color + who.prefix + who.DisplayName + "&g has reverted their nick to their original name.", false);
				Player.GlobalDie(p, false);
				Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false);
				return;
			}

			if (newName.Length > 60) { Player.SendMessage(p, "Nick must be under 60 letters."); return; }

			if (newName != "") Player.GlobalChat(who, who.color + who.DisplayName + "&g has changed their nick to " + newName + "&g.", false);
			who.DisplayName = newName;
			Player.GlobalDie(who, false);
			Player.GlobalSpawn(who, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1], false);
            PlayerDB.Save(who);
		}
Exemple #5
0
        public static ushort writeLetter(Level l, Player p, char c, ushort x, ushort y, ushort z, byte b, int direction)
        {
            if( (int)c >= 256 || letters[(int)c] == null ) {
                Player.SendMessage(p, "\"" + c + "\" is currently not supported. Space left");
                if (direction == 0) x += 4; else if (direction == 1) x -= 4;
                else if (direction == 2) z += 4; else z -= 4;
            } else {
                byte[] flags = letters[(int)c];
                for( int i = 0; i < flags.Length; i++ ) {
                    byte yUsed = flags[i];
                    for (int j = 0; j < 8; j++) {
                        if ((yUsed & (1 << j)) == 0) continue;
                        
                        placeBlock(l, p, x, (ushort)(y + j), z, b);
                    }
                    
                    if (direction == 0) x++; else if (direction == 1) x--; 
                    else if (direction == 2) z++; else z--;
                }
            }

            if (direction == 0) return (ushort)(x + 1);
            else if (direction == 1) return (ushort)(x - 1);
            else if (direction == 2) return (ushort)(z + 1);
            else return (ushort)(z - 1);
        }
Exemple #6
0
		public static bool Load( Player p ) {
			if ( File.Exists( "players/" + p.name + "DB.txt" ) ) {
				foreach ( string line in File.ReadAllLines( "players/" + p.name + "DB.txt" ) ) {
					if ( !string.IsNullOrEmpty( line ) && !line.StartsWith( "#" ) ) {
						string key = line.Split( '=' )[0].Trim();
						string value = line.Split( '=' )[1].Trim();
						string section = "nowhere yet...";

						try {
							switch ( key.ToLower() ) {
								case "nick":
								p.DisplayName = value;
								section = key;
								break;
							}
						} catch(Exception e) {
							Server.s.Log( "Loading " + p.name + "'s EXP database failed at section: " + section );
							Server.ErrorLog( e );
						}

						p.timeLogged = DateTime.Now;
					}
				}

				p.SetPrefix();
				return true;
			} else {
				Save( p );
				return false;
			}
		}
Exemple #7
0
		public static void Save( Player p ) {
			StreamWriter sw = new StreamWriter( File.Create( "players/" + p.name + "DB.txt" ) );
			sw.WriteLine ("Nick = " + p.DisplayName );
			sw.Flush();
			sw.Close();
			sw.Dispose();
		}
 /// <summary>
 /// Register this event
 /// </summary>
 /// <param name="method">This is the delegate that will get called when this event occurs</param>
 /// <param name="priority">The priority (imporantce) of this call</param>
 /// <param name="plugin">The plugin object that is registering the event</param>
 /// <param name="bypass">Register more than one of the same event</param>
 public static void Register(Player.OnPlayerChat method, Priority priority, Plugin plugin, bool bypass = false)
 {
     if (Find(plugin) != null)
         if (!bypass)
         throw new Exception("The user tried to register 2 of the same event!");
     events.Add(new OnPlayerChatEvent(method, priority, plugin));
     Organize();
 }
Exemple #9
0
 public static void Addblock(Player p, ushort x, ushort y, ushort z, byte type, byte extType = 0) {
 	int index = p.level.PosToInt(x, y, z);
 	if (index < 0) return;
 	block item;
 	
 	item.p = p; item.index = index;
 	item.type = type; item.extType = extType;
     p.level.blockqueue.Add(item);
 }
Exemple #10
0
 public override void Perform(ushort x1, ushort y1, ushort z1, ushort x2,
                              ushort y2, ushort z2, Player p, Level lvl, Brush brush) {
     for (ushort y = y1; y <= y2; y++)
         for (ushort z = z1; z <= z2; z++)
             for (ushort x = x1; x <= x2; x++)
     {
         PlaceBlock(p, lvl, x, y, z, brush);
     }
 }
Exemple #11
0
 public static void Create(string waypoint, Player p) {
     Waypoint wp = new Waypoint();
     wp.x = p.pos[0]; wp.y = p.pos[1]; wp.z = p.pos[2];
     wp.rotx = p.rot[0]; wp.roty = p.rot[1];
     wp.name = waypoint;
     wp.lvlname = p.level.name;
     p.Waypoints.Add(wp);
     Save();
 }
Exemple #12
0
 public bool CanDraw(ushort x1, ushort y1, ushort z1, ushort x2, ushort y2, ushort z2,
                     Player p, out int affected) {
     affected = GetBlocksAffected(p.level, x1, y1, z1, x2, y2, z2);
     if (affected > p.group.maxBlocks) {
         Player.SendMessage(p, "You tried to draw " + affected + " blocks.");
         Player.SendMessage(p, "You cannot draw more than " + p.group.maxBlocks + ".");
         return false;
     }
     return true;
 }
Exemple #13
0
 public static void GlobalChatWorld(Player from, string message, bool showname) {
     if ( showname ) {
         message = "<World>" + from.color + from.voicestring + from.color + from.prefix + from.name + ": &f" + message;
     }
     Player.players.ForEach(
         delegate(Player p) {
             if ( p.level.worldChat && p.Chatroom == null )
                 SendGlobalMessage(p, from, message);
         });
 }
 public static void Call(Player p, byte[] rot)
 {
     events.ForEach(delegate(PlayerRotateEvent p1)
     {
         try
         {
             p1.method(p, rot);
         }
         catch (Exception e) { Server.s.Log("The plugin " + p1.plugin.name + " errored when calling the PlayerRotate Event!"); Server.ErrorLog(e); }
     });
 }
 public static void Call(Player p, Group newrank)
 {
     events.ForEach(delegate(OnPlayerRankSetEvent p1)
     {
         try
         {
             p1.method(p, newrank);
         }
         catch (Exception e) { Server.s.Log("The plugin " + p1.plugin.name + " errored when calling the LevelUnload Event!"); Server.ErrorLog(e); }
     });
 }
Exemple #16
0
 public override void Perform(ushort x1, ushort y1, ushort z1, ushort x2,
                              ushort y2, ushort z2, Player p, Level lvl, Brush brush) {
     while (true) {
         baseOp.Perform(x1, y1, z1, x2, y1, z2, p, lvl, brush);
         if (y1 >= lvl.Height || Math.Abs(x2 - x1) <= 1 || Math.Abs(z2 - z1) <= 1)
             break;                
         x1++; x2--;
         z1++; z2--;
         y1 = (ushort)(y1 + yDir);
     }
 }
 public static void Call(Player p, string mysqlcommand)
 {
     events.ForEach(delegate(OnMySQLSaveEvent p1)
     {
         try
         {
             p1.method(p, mysqlcommand);
         }
         catch (Exception e) { Server.s.Log("The plugin " + p1.plugin.name + " errored when calling the MySQLSave Event!"); Server.ErrorLog(e); }
     });
 }
Exemple #18
0
 public override void Use(Player p, string message)
 {
     Player who = Player.Find(message);
     if (who == null || who.hidden) { Player.SendMessage(p, "Could not find specified player!"); return; }
     else
     {
         string msg = String.Format("the {0}Console [&a{1}{0}]", Server.DefaultColor, Server.ZallState);
         string giver = (p == null) ? msg : p.color + p.DisplayName;
         Player.GlobalMessage(who.color + who.DisplayName + Server.DefaultColor + " was hugged by " + giver);
     }
 }
 public static void Call(Player p, string message)
 {
     events.ForEach(delegate(OnPlayerChatEvent p1)
     {
         try
         {
             p1.method(p, message);
         }
         catch (Exception e) { Server.s.Log("The plugin " + p1.plugin.name + " errored when calling the PlayerChat Event!"); Server.ErrorLog(e); }
     });
 }
 public static void Call(Player p, ushort x, ushort y, ushort z, byte type)
 {
     events.ForEach(delegate(OnBlockChangeEvent p1)
     {
         try
         {
             p1.method(p, x, y, z, type);
         }
         catch (Exception e) { Server.s.Log("The plugin " + p1.plugin.name + " errored when calling the PlayerBlockChange Event!"); Server.ErrorLog(e); }
     });
 }
Exemple #21
0
 public static void GlobalChatRoom(Player from, string message, bool showname) {
     string oldmessage = message;
     if ( showname ) {
         message = "<GlobalChatRoom> " + from.color + from.voicestring + from.color + from.prefix + from.name + ": &f" + message;
     }
     Player.players.ForEach(
         delegate(Player p) {
             if ( p.Chatroom != null )
                 SendGlobalMessage(p, from, message);
         });
     Server.s.Log(oldmessage + "<GlobalChatRoom>" + from.prefix + from.name + message);
 }
Exemple #22
0
 public static Waypoint Find(string name, Player p) {
     Waypoint wpfound = null;
     bool found = false;
     foreach ( Waypoint wp in p.Waypoints ) {
         if ( wp.name.ToLower() == name.ToLower() ) {
             wpfound = wp;
             found = true;
         }
     }
     if ( found ) { return wpfound; }
     else { return null; }
 }
Exemple #23
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                message = "normal";
            }

            Player targetPlayer;
            string model;

            if (message.Split(' ').Length > 1)
            {
                targetPlayer = Player.Find(message.Split(' ')[0].Trim());
                if (targetPlayer == null)
                {
                    Player.SendMessage(p, "Player \"" + message.Split(' ')[0].Trim() + "\" does not exist");
                    return;
                }
                model = message.Split(' ')[1].Trim();
                targetPlayer.model = model;
            }
            else
            {
                if (p == null)
                {
                    Player.SendMessage(null, "Console can't use this command on itself.");
                    return;
                }
                targetPlayer = p;
                model = message;
                p.model = model;
            }

            foreach (Player pl in Player.players)
            {
                if (pl.level == targetPlayer.level && pl.HasCpeExt(CpeExt.ChangeModel))
                {
                    pl.SendChangeModel(targetPlayer.id, message);
                }
            }

            if (p == null)
            {
                targetPlayer.SendMessage("You're now a &c" + model);
            }
            else
            {
                Command.all.Find("aka").Use(targetPlayer, "");
                Player.GlobalMessage(targetPlayer.color + targetPlayer.DisplayName + "'s" + Server.DefaultColor + " model was changed to a &c" + model);
            }
        }
Exemple #24
0
 public void RemoveMember(Player p)
 {
     if (p.team == this)
     {
         p.team = null;
         Player.GlobalDie(p, false);
         //p.color = p.CTFtempcolor;
         //p.prefix = p.CTFtempprefix;
         //p.carryingFlag = false;
         p.hasflag = null;
         players.Remove(p);
         mapOn.ChatLevel(p.color + p.prefix + p.name + Server.DefaultColor + " has left the " + teamstring + ".");
         Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false);
     }
 }
Exemple #25
0
 public static void Goto(string waypoint, Player p) {
     if ( !Exists(waypoint, p) ) return;
     Waypoint wp = Find(waypoint, p);
     Level lvl = Level.Find(wp.lvlname);
     if ( wp == null ) return;
     if ( lvl != null ) {
         if ( p.level != lvl ) {
             Command.all.Find("goto").Use(p, lvl.name);
             while ( p.Loading ) { Thread.Sleep(250); }
         }
         unchecked { p.SendPos((byte)-1, wp.x, wp.y, wp.z, wp.rotx, wp.roty); }
         Player.SendMessage(p, "Sent you to waypoint");
     }
     else { Player.SendMessage(p, "The map that that waypoint is on isn't loaded right now (" + wp.lvlname + ")"); return; }
 }
Exemple #26
0
 public static void Update(string waypoint, Player p) {
     Waypoint wp = Find(waypoint, p);
     p.Waypoints.Remove(wp);
     {
         wp.x = p.pos[0];
         wp.y = p.pos[1];
         wp.z = p.pos[2];
         wp.rotx = p.rot[0];
         wp.roty = p.rot[1];
         wp.name = waypoint;
         wp.lvlname = p.level.name;
     }
     p.Waypoints.Add(wp);
     Save();
 }
Exemple #27
0
 public override void Perform(ushort x1, ushort y1, ushort z1, ushort x2,
                              ushort y2, ushort z2, Player p, Level lvl, Brush brush) {
     /* Courtesy of fCraft's awesome Open-Source'ness :D */
     double cx = (x1 + x2) / 2.0, cy = (y1 + y2) / 2.0, cz = (z1 + z2) / 2.0;
     double rx = (x2 - x1) / 2.0 + 0.25, ry = (y2 - y1) / 2.0 + 0.25, rz = (z2 - z1) / 2.0 + 0.25;
     double rx2 = 1 / (rx * rx), ry2 = 1 / (ry * ry), rz2 = 1 / (rz * rz);
     
     for (ushort yy = y1; yy <= y2; yy++)
         for (ushort zz = z1; zz <= z2; zz++)
             for (ushort xx = x1; xx <= x2; xx++)
     {
         double dx = xx - cx, dy = yy - cy, dz = zz - cz;
         if ((dx * dx) * rx2 + (dy * dy) * ry2 + (dz * dz) * rz2 <= 1)
             PlaceBlock(p, lvl, xx, yy, zz, brush);
     }
 }
Exemple #28
0
 protected void PlaceBlock(Player p, Level lvl, ushort x, ushort y, ushort z, byte type, byte extType) {
     switch (method) {
         case MethodBlockQueue:
             BlockQueue.Addblock(p, x, y, z, type, extType);
             break;
         case MethodBlockChange:
             p.level.Blockchange(p, x, y, z, type, extType);
             break;
         case MethodSetTile:
             byte old = lvl.GetTile(x, y, z);
             if (old == Block.Zero || !lvl.CheckAffectPermissions(p, x, y, z, old, type))
             	return;
             p.level.SetTile(x, y, z, type, p, extType);
             break;
     }
 }
Exemple #29
0
 public override void Perform(ushort x1, ushort y1, ushort z1, ushort x2,
                              ushort y2, ushort z2, Player p, Level lvl, Brush brush) {
     int lenX = (x2 - x1 + 1), lenY = (y2 - y1 + 1);
     QuadY(y1, x1, z1, x2, z2, p, lvl, brush);
     QuadY(y2, x1, z1, x2, z2, p, lvl, brush);
     if (lenY > 2) {
         QuadX(x1, (ushort)(y1 + 1), z1, (ushort)(y2 - 1), z2, p, lvl, brush);
         QuadX(x2, (ushort)(y1 + 1), z1, (ushort)(y2 - 1), z2, p, lvl, brush);
     }
     if (lenX > 2 && lenY > 2) {
         QuadZ(z1, (ushort)(x1 + 1), (ushort)(y1 + 1),
               (ushort)(x2 - 1), (ushort)(y2 - 1), p, lvl, brush);
         QuadZ(z2, (ushort)(x1 + 1), (ushort)(y1 + 1),
               (ushort)(x2 - 1), (ushort)(y2 - 1), p, lvl, brush);
     }
 }
Exemple #30
0
 public override void Use(Player p, string message)
 {
     if ((message.ToLower() == "set") && p != null)
     {
         p.level.jailx = p.pos[0]; p.level.jaily = p.pos[1]; p.level.jailz = p.pos[2];
         p.level.jailrotx = p.rot[0]; p.level.jailroty = p.rot[1];
         Player.SendMessage(p, "Set Jail point.");
     }
     else
     {
         Player who = Player.Find(message);
         if (who != null)
         {
             if (!who.jailed)
             {
                 if (p != null)
                 {
                     if (who.group.Permission >= p.group.Permission) { Player.SendMessage(p, "Cannot jail someone of equal or greater rank."); return; }
                     Player.SendMessage(p, "You jailed " + who.name);
                 }
                 Player.GlobalDie(who, false);
                 who.jailed = true;
                 Player.GlobalSpawn(who, who.level.jailx, who.level.jaily, who.level.jailz, who.level.jailrotx, who.level.jailroty, true);
                 if (!File.Exists("ranks/jailed.txt")) File.Create("ranks/jailed.txt").Close();
                 Extensions.DeleteLineWord("ranks/jailed.txt", who.name);
                 using (StreamWriter writer = new StreamWriter("ranks/jailed.txt", true))
                 {
                     writer.WriteLine(who.name.ToLower() + " " + who.level.name);
                 }
                 Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + " was &8jailed", false);
             }
             else
             {
                 if (!File.Exists("ranks/jailed.txt")) File.Create("ranks/jailed.txt").Close();
                 Extensions.DeleteLineWord("ranks/jailed.txt", who.name.ToLower());
                 who.jailed = false;
                 Command.all.Find("spawn").Use(who, "");
                 Player.SendMessage(p, "You freed " + who.name + " from jail");
                 Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + " was &afreed" + Server.DefaultColor + " from jail", false);
             }
         }
         else
         {
             Player.SendMessage(p, "Could not find specified player.");
         }
     }
 }