public void DeleteMember(string name) {//carefull this can lead to guild with no ranks or members(or no leader) GuildMember Member = null; Rank MemberRank = null; for (int i = 0; i < Ranks.Count; i++) { for (int j = 0; j < Ranks[i].Members.Count; j++) { Member = Ranks[i].Members[j]; MemberRank = Ranks[i]; if (Member.name != name) { continue; } MemberDeleted(Member.name, (PlayerObject)Member.Player, true); if (Member.Player != null) { PlayerObject LeavingMember = (PlayerObject)Member.Player; LeavingMember.RefreshStats(); } MemberRank.Members.Remove(Member); NeedSave = true; Membercount--; break; } } }
public void MemberDeleted(string name, PlayerObject formermember, bool kickself) { PlayerObject player = null; for (int i = 0; i < Ranks.Count; i++) { for (int j = 0; j < Ranks[i].Members.Count; j++) { if ((Ranks[i].Members[j].Player != null) && (Ranks[i].Members[j].Player != formermember)) { player = (PlayerObject)Ranks[i].Members[j].Player; player.Enqueue(new ServerPackets.GuildMemberChange() { Name = name, Status = (byte)(kickself ? 4:3) }); player.GuildMembersChanged = true; } } } if (formermember != null) { formermember.Info.GuildIndex = -1; formermember.MyGuild = null; formermember.MyGuildRank = null; formermember.ReceiveChat(kickself ? "你已经离开了行会。" : "你被请出行会。", ChatType.Guild); formermember.RefreshStats(); formermember.Enqueue(new ServerPackets.GuildStatus() { GuildName = "", GuildRankName = "", MyOptions = (RankOptions)0 }); formermember.BroadcastInfo(); } }
public void RefreshAllStats() { for (int i = 0; i < Ranks.Count; i++) { for (int j = 0; j < Ranks[i].Members.Count; j++) { PlayerObject player = (PlayerObject)Ranks[i].Members[j].Player; if (player != null) { player.RefreshStats(); } } } }
public void MemberDeleted(string name, PlayerObject formermember, bool kickself) { PlayerObject player = null; for (int i = 0; i < Ranks.Count; i++) { for (int j = 0; j < Ranks[i].Members.Count; j++) { if ((Ranks[i].Members[j].Player != null) && (Ranks[i].Members[j].Player != formermember)) { player = (PlayerObject)Ranks[i].Members[j].Player; player.Enqueue(new ServerPackets.GuildMemberChange() { Name = name, Status = (byte)(kickself ? 4:3) }); player.GuildMembersChanged = true; } } } if (formermember != null) { formermember.Info.GuildIndex = -1; string UpdateGuild = "UPDATE " + Settings.DBAccount + ".characterinfo SET GuildIndex = '" + formermember.Info.GuildIndex + "' WHERE IndexID = '" + formermember.Info.Index + "'"; Envir.ConnectADB.Update(UpdateGuild); formermember.MyGuild = null; formermember.MyGuildRank = null; formermember.ReceiveChat(kickself ? "You have left your guild." : "You have been removed from your guild.", ChatType.Guild); formermember.RefreshStats(); formermember.Enqueue(new ServerPackets.GuildStatus() { GuildName = "", GuildRankName = "", MyOptions = (RankOptions)0 }); formermember.BroadcastInfo(); } }
public bool DeleteMember(PlayerObject Kicker, string membername) {//carefull this can lead to guild with no ranks or members(or no leader) GuildMember Member = null; Rank MemberRank = null; if ((Kicker.MyGuild != this) || (Kicker.MyGuildRank == null)) { return(false); } for (int i = 0; i < Ranks.Count; i++) { for (int j = 0; j < Ranks[i].Members.Count; j++) { if (Ranks[i].Members[j].name == membername) { Member = Ranks[i].Members[j]; MemberRank = Ranks[i]; goto Found; } } } Found: if (Member == null) { return(false); } if (((Kicker.MyGuildRank.Index >= MemberRank.Index) && (Kicker.MyGuildRank.Index != 0)) && (Kicker.Info.Name != membername)) { Kicker.ReceiveChat("你的职位权限不够。", ChatType.System); return(false); } if (MemberRank.Index == 0) { if (MemberRank.Members.Count < 2) { Kicker.ReceiveChat("你不能离开行会,因为你是领导者。", ChatType.System); return(false); } for (int i = 0; i < MemberRank.Members.Count; i++) { if ((MemberRank.Members[i].Online) && (MemberRank.Members[i] != Member)) { goto AllOk; } } Kicker.ReceiveChat("需要至少1个行会领导在线。", ChatType.System); return(false); } AllOk: MemberDeleted(membername, (PlayerObject)Member.Player, Member.name == Kicker.Info.Name); if (Member.Player != null) { PlayerObject LeavingMember = (PlayerObject)Member.Player; LeavingMember.RefreshStats(); } MemberRank.Members.Remove(Member); NeedSave = true; Membercount--; return(true); }
public bool DeleteMember(PlayerObject Kicker, string membername) {//carefull this can lead to guild with no ranks or members(or no leader) GuildMember Member = null; Rank MemberRank = null; if ((Kicker.MyGuild != this) || (Kicker.MyGuildRank == null)) { return(false); } for (int i = 0; i < Ranks.Count; i++) { for (int j = 0; j < Ranks[i].Members.Count; j++) { if (Ranks[i].Members[j].name == membername) { Member = Ranks[i].Members[j]; MemberRank = Ranks[i]; goto Found; } } } Found: if (Member == null) { return(false); } if (((Kicker.MyGuildRank.Index >= MemberRank.Index) && (Kicker.MyGuildRank.Index != 0)) && (Kicker.Info.Name != membername)) { Kicker.ReceiveChat("Your rank is not adequate.", ChatType.System); return(false); } if (MemberRank.Index == 0 && Name != Settings.NewbieName) { if (MemberRank.Members.Count < 2) { Kicker.ReceiveChat("You cannot leave the guild when you're leader.", ChatType.System); return(false); } for (int i = 0; i < MemberRank.Members.Count; i++) { if ((MemberRank.Members[i].Online) && (MemberRank.Members[i] != Member)) { goto AllOk; } } Kicker.ReceiveChat("You need at least 1 leader online.", ChatType.System); return(false); } AllOk: MemberDeleted(membername, (PlayerObject)Member.Player, Member.name == Kicker.Info.Name); if (Member.Player != null) { PlayerObject LeavingMember = (PlayerObject)Member.Player; LeavingMember.RefreshStats(); } MemberRank.Members.Remove(Member); NeedSave = true; Membercount--; return(true); }
private void Act(List<NPCActions> acts, PlayerObject player) { for (int i = 0; i < acts.Count; i++) { NPCActions act = acts[i]; uint gold; uint count; switch (act.Type) { case ActionType.Teleport: Map temp = SMain.Envir.GetMap((int) act.Params[0]); if (temp == null) return; player.Teleport(temp, (Point) act.Params[1]); break; case ActionType.GiveGold: gold = (uint)act.Params[0]; if (gold + player.Account.Gold >= uint.MaxValue) gold = uint.MaxValue - player.Account.Gold; player.GainGold(gold); break; case ActionType.TakeGold: gold = (uint) act.Params[0]; if (gold >= player.Account.Gold) gold = player.Account.Gold; player.Account.Gold -= gold; player.Enqueue(new S.LoseGold { Gold = gold }); break; case ActionType.GiveItem: count = (uint)act.Params[1]; while (count > 0) { UserItem item = SMain.Envir.CreateFreshItem((ItemInfo)act.Params[0]); if (item == null) { SMain.Enqueue(string.Format("Failed to create UserItem: {0}, Page: {1}", act.Params[0], Key)); return; } if (item.Info.StackSize > count) { item.Count = count; count = 0; } else { count -= item.Info.StackSize; item.Count = item.Info.StackSize; } if (player.CanGainItem(item, false)) player.GainItem(item); } break; case ActionType.TakeItem: ItemInfo info = (ItemInfo) act.Params[0]; count = (uint) act.Params[1]; for (int o = 0; o < player.Info.Inventory.Length; o++) { UserItem item = player.Info.Inventory[o]; if (item.Info != info) continue; if (count > item.Count) { player.Enqueue(new S.DeleteItem {UniqueID = item.UniqueID, Count = item.Count}); player.Info.Inventory[o] = null; count -= item.Count; continue; } player.Enqueue(new S.DeleteItem { UniqueID = item.UniqueID, Count = count }); if (count == item.Count) player.Info.Inventory[o] = null; else item.Count -= count; break; } player.RefreshStats(); break; } } }
public void MemberDeleted(string name, PlayerObject formermember, bool kickself) { PlayerObject player = null; for (int i = 0; i < Ranks.Count; i++) for (int j = 0; j < Ranks[i].Members.Count; j++) { if ((Ranks[i].Members[j].Player != null) && (Ranks[i].Members[j].Player != formermember)) { player = (PlayerObject)Ranks[i].Members[j].Player; player.Enqueue(new ServerPackets.GuildMemberChange() { Name = name, Status = (byte)(kickself ? 4:3) }); player.GuildMembersChanged = true; } } if (formermember != null) { formermember.Info.GuildIndex = -1; formermember.MyGuild = null; formermember.MyGuildRank = null; formermember.ReceiveChat(kickself ? "You have left your guild." : "You have been removed from your guild.", ChatType.Guild); formermember.RefreshStats(); formermember.Enqueue(new ServerPackets.GuildStatus() { GuildName = "", GuildRankName = "", MyOptions = (RankOptions)0 }); formermember.BroadcastInfo(); } }
public void NewMember(PlayerObject newmember) { if (Ranks.Count < 2) Ranks.Add(new Rank() { Name = "Members", Index = 1}); Rank currentrank = Ranks[Ranks.Count - 1]; GuildMember Member = new GuildMember() { name = newmember.Info.Name, Player = newmember, Id = newmember.Info.Index, LastLogin = Envir.Now, Online = true }; currentrank.Members.Add(Member); PlayerLogged(newmember, true, true); newmember.RefreshStats(); newmember.Enqueue(new ServerPackets.GuildBuffList() { ActiveBuffs = BuffList }); Membercount++; NeedSave = true; }
private void Act(IList<NPCActions> acts, PlayerObject player) { for (var i = 0; i < acts.Count; i++) { NPCActions act = acts[i]; uint gold; uint count; string path; switch (act.Type) { case ActionType.Teleport: var map = SMain.Envir.GetMapByNameAndInstance((string)act.Params[0]); if (map == null) return; var coords = (Point)act.Params[1]; if (coords.X > 0 && coords.Y > 0) player.Teleport(map, coords); else player.TeleportRandom(200, 0, map); break; case ActionType.InstanceTeleport: map = SMain.Envir.GetMapByNameAndInstance((string)act.Params[0], (int)act.Params[1]); if (map == null) return; player.Teleport(map, (Point)act.Params[2]); break; case ActionType.GiveGold: gold = (uint)act.Params[0]; if (gold + player.Account.Gold >= uint.MaxValue) gold = uint.MaxValue - player.Account.Gold; player.GainGold(gold); break; case ActionType.TakeGold: gold = (uint)act.Params[0]; if (gold >= player.Account.Gold) gold = player.Account.Gold; player.Account.Gold -= gold; player.Enqueue(new S.LoseGold { Gold = gold }); break; case ActionType.GiveItem: count = (uint)act.Params[1]; while (count > 0) { UserItem item = SMain.Envir.CreateFreshItem((ItemInfo)act.Params[0]); if (item == null) { SMain.Enqueue(string.Format("Failed to create UserItem: {0}, Page: {1}", act.Params[0], Key)); return; } if (item.Info.StackSize > count) { item.Count = count; count = 0; } else { count -= item.Info.StackSize; item.Count = item.Info.StackSize; } if (player.CanGainItem(item, false)) player.GainItem(item); } break; case ActionType.TakeItem: ItemInfo info = (ItemInfo)act.Params[0]; count = (uint)act.Params[1]; for (int o = 0; o < player.Info.Inventory.Length; o++) { UserItem item = player.Info.Inventory[o]; if (item == null) continue; if (item.Info != info) continue; if (count > item.Count) { player.Enqueue(new S.DeleteItem { UniqueID = item.UniqueID, Count = item.Count }); player.Info.Inventory[o] = null; count -= item.Count; continue; } player.Enqueue(new S.DeleteItem { UniqueID = item.UniqueID, Count = count }); if (count == item.Count) player.Info.Inventory[o] = null; else item.Count -= count; break; } player.RefreshStats(); break; case ActionType.GiveExp: player.GainExp((uint)act.Params[0]); break; case ActionType.GivePet: for (var c = 0; c < (byte)act.Params[1]; c++) { MonsterObject monster = MonsterObject.GetMonster((MonsterInfo)act.Params[0]); if (monster == null) return; monster.PetLevel = (byte)act.Params[2]; monster.Master = player; monster.MaxPetLevel = 7; monster.Direction = player.Direction; monster.ActionTime = SMain.Envir.Time + 1000; monster.Spawn(player.CurrentMap, player.CurrentLocation); player.Pets.Add(monster); } break; case ActionType.AddNameList: path = (string)act.Params[0]; if (File.ReadAllLines(path).All(t => player.Name != t)) { using (var line = File.AppendText(path)) { line.WriteLine(player.Name); } } break; case ActionType.DelNameList: path = (string)act.Params[0]; File.WriteAllLines(path, File.ReadLines(path).Where(l => l != player.Name).ToList()); break; case ActionType.ClearNameList: path = (string)act.Params[0]; File.WriteAllLines(path, new string[] { }); break; case ActionType.GiveHP: player.ChangeHP((int)act.Params[0]); break; case ActionType.GiveMP: player.ChangeMP((int)act.Params[0]); break; case ActionType.ChangeLevel: player.Level = (byte) act.Params[0]; player.LevelUp(); break; case ActionType.SetPkPoint: player.PKPoints = (int) act.Params[0]; break; case ActionType.ChangeGender: switch (player.Info.Gender) { case MirGender.Male: player.Info.Gender = MirGender.Female; break; case MirGender.Female: player.Info.Gender = MirGender.Male; break; } break; case ActionType.ChangeClass: var data = (MirClass)act.Params[0]; switch (data) { case MirClass.Warrior: player.Info.Class = MirClass.Warrior; break; case MirClass.Taoist: player.Info.Class = MirClass.Taoist; break; case MirClass.Wizard: player.Info.Class = MirClass.Wizard; break; case MirClass.Assassin: player.Info.Class = MirClass.Assassin; break; } break; case ActionType.LineMessage: player.ReceiveChat((string)act.Params[0], (ChatType)act.Params[1]); break; case ActionType.GiveSkill: var magic = new UserMagic((Spell)act.Params[0]) { Level = (byte)act.Params[1] }; player.Info.Magics.Add(magic); player.Enqueue(magic.GetInfo()); break; case ActionType.Goto: player.NPCGoto = true; player.NPCGotoPage = "[" + act.Params[0] + "]"; break; case ActionType.Set: player.Info.Flags[(uint) act.Params[0]] = (bool) act.Params[1]; break; } } }