public static void HandlePetitionOffer(IRealmClient client, RealmPacketIn packet) { var unk = packet.ReadUInt32(); var petitionId = packet.ReadEntityId(); var playerId = packet.ReadEntityId(); var player = World.GetCharacter(playerId.Low); var petition = PetitionRecord.LoadRecordByItemId(petitionId.Low); var namePlayer = player.Name; if (player.Faction != client.ActiveCharacter.Faction) { if (petition.Type == PetitionType.Guild) { GuildHandler.SendResult(client, GuildCommandId.CREATE, client.ActiveCharacter.Name, GuildResult.NOT_ALLIED); } else { ArenaTeamHandler.SendResult(client, ArenaTeamCommandId.INVITE, ArenaTeamResult.NOT_ALLIED); } return; } if (petition.Type == PetitionType.Guild) { if (player.IsInGuild) { GuildHandler.SendResult(client, GuildCommandId.INVITE, namePlayer, GuildResult.ALREADY_IN_GUILD_S); return; } } else { if (player.ArenaTeamMember[(uint)ArenaMgr.GetSlotByType((uint)petition.Type)] != null) { ArenaTeamHandler.SendResult(client, ArenaTeamCommandId.CREATE, string.Empty, namePlayer, ArenaTeamResult.ALREADY_IN_ARENA_TEAM_S); return; } else if (player.Level < 80) { ArenaTeamHandler.SendResult(client, ArenaTeamCommandId.CREATE, string.Empty, namePlayer, ArenaTeamResult.TARGET_TOO_LOW); return; } } SendPetitionSignatures(player.Client, client.ActiveCharacter.Inventory.GetItem(petitionId) as PetitionCharter); }
public static void HandlePetitionTurnIn(IRealmClient client, RealmPacketIn packet) { var petitionGuid = packet.ReadEntityId(); var petition = client.ActiveCharacter.Inventory.GetItem(petitionGuid) as PetitionCharter; if (petition == null) { return; } var name = petition.Petition.Name; var type = petition.Petition.Type; if (petition.Petition.SignedIds.Count < ((uint)type - 1)) { SendPetitionTurnInResults(client, PetitionTurns.NEED_MORE_SIGNATURES); return; } if (type == PetitionType.Guild && client.ActiveCharacter.IsInGuild) { SendPetitionTurnInResults(client, PetitionTurns.ALREADY_IN_GUILD); return; } else if (client.ActiveCharacter.ArenaTeamMember[(uint)ArenaMgr.GetSlotByType((uint)type)] != null) { ArenaTeamHandler.SendResult(client, ArenaTeamCommandId.CREATE, name, string.Empty, ArenaTeamResult.ALREADY_IN_ARENA_TEAM); return; } else if (type == PetitionType.Guild && GuildMgr.DoesGuildExist(name)) { GuildHandler.SendResult(client, GuildCommandId.CREATE, name, GuildResult.NAME_EXISTS); return; } else if (ArenaMgr.DoesArenaTeamExist(name)) { ArenaTeamHandler.SendResult(client, ArenaTeamCommandId.CREATE, name, string.Empty, ArenaTeamResult.NAME_EXISTS); return; } else { petition.Destroy(); if (type == PetitionType.Guild) { var guild = new Guild(client.ActiveCharacter.Record, name); foreach (var chr in petition.Petition.SignedIds) { if (chr == 0) { continue; } else { var character = World.GetCharacter(chr); guild.AddMember(character); } } } else { var team = new ArenaTeam(client.ActiveCharacter.Record, name, (uint)type); foreach (var chr in petition.Petition.SignedIds) { if (chr == 0) { continue; } else { var character = World.GetCharacter(chr); team.AddMember(character); } } } SendPetitionTurnInResults(client, PetitionTurns.OK); } }