private static void SellRequest(WorldClient Client, string Packet) { Client.Send(new GameRideMessage("v")); int price = int.Parse(Packet.Substring(2)); MountPark MP1 = Client.Character.myMap.mountPark; if (MP1 == null) { return; } if (MP1.get_owner() == -1) { Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 94)); return; } if (MP1.get_owner() != Client.Character.ID) { Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 95)); return; } MP1.set_price(price); MountParkTable.Update(MP1); Client.Character.myMap.SendToMap(new MapMountParkMessage(MP1)); }
public static void Update(MountPark model) { try { MySqlCommand Command = new MySqlCommand() { Connection = DatabaseManager.Provider.getConnection(), CommandText = "REPLACE INTO `mountpark_data` VALUES(@map,@cell,@size,@owner,@guild,@price,@data);", }; Command.Prepare(); Command.Parameters.AddWithValue("@map", model.get_map().Id); Command.Parameters.AddWithValue("@cell", model.get_cellid()); Command.Parameters.AddWithValue("@size", model.get_size()); Command.Parameters.AddWithValue("@owner", model.get_owner()); Command.Parameters.AddWithValue("@guild", (model.get_guild() == null ? -1 : model.get_guild().ID)); Command.Parameters.AddWithValue("@price", model.get_price()); Command.Parameters.AddWithValue("@data", (model.parseData())); Command.ExecuteNonQuery(); } catch (Exception e) { Logger.Error("Can't execute query : " + e.ToString()); } }
private static void BuyRequest(WorldClient Client, string Packet) { Client.Send(new GameRideMessage("v")); MountPark MP = Client.Character.myMap.mountPark; if (MP == null) { Client.Send(new BasicNoOperationMessage()); return; } if (MP.get_owner() == -1) { Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 96)); return; } if (MP.get_price() == 0) { Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 97)); return; } if (!Client.Character.HasGuild()) { Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 135)); return; } if (Client.GetCharacter().getCharacterGuild().GradeType != GuildGradeEnum.GRADE_BOSS) { Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 98)); return; } byte enclosMax = (byte)Math.Floor((double)Client.Character.GetGuild().Level / 10); byte TotalEncloGuild = (byte)MountParkTable.CountByGuild(Client.Character.GetGuild().ID); if (TotalEncloGuild >= enclosMax) { Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 103)); return; } if (Client.Character.Kamas < MP.get_price()) { Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 82)); return; } Client.GetCharacter().InventoryCache.SubstractKamas(MP.get_price()); if (MP.get_owner() > 0) { var Owner = CharacterTable.GetCharacter(MP.get_owner()); if (Owner != null && Owner.Account.curPlayer != null) { Owner.Send(new ChatGameMessage("Un enclo a ete vendu a " + MP.get_price() + ".", "CC0000")); Owner.Account.Data.BankKamas += MP.get_price(); Owner.Account.Data.Save(); } else { AccountDataTable.Update(MP.get_price(), MP.get_owner()); } } MP.set_price(0); MP.set_owner(Client.Character.ID); MP.set_guild(Client.Character.GetGuild()); MountParkTable.Update(MP); CharacterTable.Update(Client.Character); Client.GetCharacter().myMap.SendToMap(new MapMountParkMessage(MP)); }
private static void ProcessExchangeMountParkRequest(WorldClient Client, string Packet) { MountPark MP = Client.Character.inMountPark; if (MP != null) { char c = Packet[2]; Packet = Packet.Substring(3); int guid = -1; try { guid = int.Parse(Packet); } catch (Exception e) { }; switch (c) { case 'C': //Parcho => Etable (Stocker) if (guid == -1 || !Client.Character.InventoryCache.hasItemGuid(guid)) { return; } InventoryItemModel obj = Client.Character.InventoryCache.GetItem(guid); //on prend la DD demandée int DDid = -1; Mount DD = null; if (obj.GetStats().HasEffect(EffectEnum.MountOwner)) { DDid = obj.GetStats().GetEffect(EffectEnum.MountOwner).Items; DD = MountTable.getMount(DDid); } //FIXME mettre return au if pour ne pas créer des nouvelles dindes if (DD == null) { int color = StaticMountTable.getMountColorByParchoTemplate(obj.TemplateID); if (color < 1) { return; } DD = new Mount(color); } DD.Intialize(); //On enleve l'Item du Monde et du Perso Client.Character.InventoryCache.remove(guid); InventoryItemTable.removeItem(guid); //on ajoute la dinde a l'étable Client.Account.Data.Mounts.Add(DD.ID, DD); Client.Account.Data.Save(); //On envoie les Packet Client.Send(new ObjectRemoveMessage(obj.ID)); Client.Send(new ExchangeEndMessage('+', DD.parse())); break; case 'c': //Etable => Parcho(Echanger) Mount DD1 = MountTable.getMount(guid); //S'il n'a pas la dinde if (!Client.Account.Data.Mounts.ContainsKey(DD1.ID) || DD1 == null) { return; } //on retire la dinde de l'étable Client.Account.Data.Mounts.Remove(DD1.ID); GenericStats Stat = new GenericStats(); Stat.AddItem(EffectEnum.MountOwner, DD1.ID); Stat.AddSpecialEffect(EffectEnum.MountOwnerName, Client.Character.Name); Stat.AddSpecialEffect(EffectEnum.MountName, DD1.Name); var item = InventoryItemTable.TryCreateItem(StaticMountTable.getMountScroll(DD1.get_color()).ID, Client.Character, 1, -1, Stat.ToItemStats()); Client.Send(new ExchangeEndMessage('-', DD1.ID + "")); Stat = null; break; case 'g': //Equiper Mount DD3 = MountTable.getMount(guid); //S'il n'a pas la dinde if (DD3 == null || !Client.Account.Data.Mounts.ContainsKey(DD3.ID) || Client.Character.Mount != null) { return; } DD3.Intialize(); Client.Account.Data.Mounts.Remove(DD3.ID); Client.Account.Data.Save(); Client.Character.Mount = DD3; //Packets Client.Send(new CharacterRideEventMessage("+", DD3)); Client.Send(new ExchangeEndMessage('-', DD3.ID + "")); Client.Send(new CharacterMountXpGive(Client.Character.MountXPGive)); break; case 'p': //Equipé => Stocker //Si c'est la dinde équipé if (Client.Character.Mount != null ? Client.Character.Mount.ID == guid : false) { //Si le perso est sur la monture on le fait descendre if (Client.Character.isOnMount()) { Client.Character.toogleOnMount(); } //Si ca n'a pas réussie, on s'arrete là (Items dans le sac ?) if (Client.Character.isOnMount()) { return; } Mount DD2 = Client.Character.Mount; DD2.Intialize(); Client.Account.Data.Mounts.Add(DD2.ID, DD2); Client.Account.Data.Save(); Client.Character.Mount = null; //Packets Client.Send(new ExchangeEndMessage('+', DD2.parse())); Client.Send(new CharacterRideEventMessage("-", null)); Client.Send(new CharacterMountXpGive(Client.Character.MountXPGive)); } else //Sinon... { } break; } } else { Client.Send(new BasicNoOperationMessage()); return; } }
public MapMountParkMessage(MountPark mountPark) { this.mountPark = mountPark; }
public void startAction(Player perso, MiniGameAction GA) { if (GA == null) { return; } int actionID = -1; short CcellID = -1; try { actionID = int.Parse(GA._args.Split(';')[1]); CcellID = short.Parse(GA._args.Split(';')[0]); } catch (Exception e) { Logger.Error(e); } if (actionID == -1) { return; } //Verif JobAction ? switch ((MiniGameActionEnum)actionID) { case MiniGameActionEnum.SAVE_POS: String str = this.Map + "," + this.Id; perso.SavePos = str; perso.Client.Send(new TextInformationMessage(TextInformationTypeEnum.INFO, 6)); break; case MiniGameActionEnum.USE_ZAAP: perso.openZaapMenu(); perso.GetClient().miniActions.Remove(GA._id); break; case MiniGameActionEnum.USE_ZAAPI: perso.openZaapiMenu(); perso.GetClient().miniActions.Remove(GA._id); break; case MiniGameActionEnum.PUISER: if (!Object.isInteractive()) { perso.GetClient().Send(new BasicNoOperationMessage()); return; } if (Object.getState() != (int)IObjectEnum.STATE_FULL) { perso.GetClient().Send(new BasicNoOperationMessage()); return; //Si le puits est vide } Object.setState((int)IObjectEnum.STATE_EMPTYING); Object.setInteractive(false); perso.myMap.SendToMap(new MapGameActionMessage(GA._id, 501, perso.ID + "", this.Id + "," + Object.getUseDuration() + "," + Object.getUnknowValue())); perso.myMap.SendToMap(new GameMapObjectMessage(perso.myMap)); break; case MiniGameActionEnum.RETURN_TO_INCARNAM: if (perso.Level > 15) { perso.Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 127)); perso.GetClient().miniActions.Remove(GA._id); return; } //TODO Map By Perso perso.Teleport(MapTable.Get(10298), 314); perso.GetClient().miniActions.Remove(GA._id); break; case MiniGameActionEnum.ACCESS_TO_MOUNTPARK: if (Object.getState() != (int)IObjectEnum.STATE_EMPTY) { ; } if (perso.Deshonor >= 5) { perso.Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 83)); perso.GetClient().miniActions.Remove(GA._id); return; } perso.inMountPark = perso.myMap.mountPark; perso.isAaway = true; perso.Send(new GameActionEnvironementMessage(16, perso.GetClient().Account.parseDragoList())); break; case MiniGameActionEnum.BUY_MOUNTPARK: MountPark MP = perso.myMap.mountPark; if (MP.get_owner() == -1) //Public { perso.Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 96)); return; } if (MP.get_price() == 0) //Non en vente { perso.Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 97)); return; } if (!perso.HasGuild()) //Pas de guilde { perso.Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 135)); return; } if (perso.getCharacterGuild().Grade != 1) //Non meneur { perso.Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 98)); return; } perso.Send(new GameRideMessage("D" + MP.get_price() + "|" + MP.get_price())); break; case MiniGameActionEnum.SELL_MOUNTPARK: case MiniGameActionEnum.SET_MOUNTPARK_PRICE: MountPark MP1 = perso.myMap.mountPark; if (MP1 == null) { return; } if (MP1.get_owner() == -1) //Public { perso.Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 94)); return; } if (MP1.get_owner() != perso.ID) { perso.Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 95)); return; } perso.Send(new GameRideMessage("D" + MP1.get_price() + "|" + MP1.get_price())); break; default: Logger.Error("Case.startAction non definie pour l'actionID = " + actionID); break; } }