Skip to content

Commit

Permalink
fix vehicle/item name too long error
Browse files Browse the repository at this point in the history
  • Loading branch information
RestoreMonarchy committed Oct 8, 2024
1 parent b2605e1 commit e93313e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 1 addition & 3 deletions ZaupShop/Commands/Console/CommandUploadItemShop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ public void Execute(IRocketPlayer caller, string[] command)
{
foreach (ItemAsset asset in items)
{
// get name of item max length 32 characters
string itemName = asset.itemName.Length > 32 ? asset.itemName.Substring(0, 32) : asset.itemName;
pluginInstance.ShopDB.AddItem(asset.id, itemName, 0, false, 0, true);
pluginInstance.ShopDB.AddItem(asset.id, asset.itemName, 0, false, 0, true);
}
Logger.Log($"Done! Finished syncing {count} items with the {ZaupShop.Instance.Configuration.Instance.ItemShopTableName} table in database!");
});
Expand Down
4 changes: 4 additions & 0 deletions ZaupShop/DatabaseMgr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ public bool AddItem(int id, string name, decimal cost, bool isChange, decimal? b
using var connection = createConnection();
using var command = connection.CreateCommand();

name = name.Length > 32 ? name.Substring(0, 32) : name;

command.CommandText = $@"
INSERT INTO `{ZaupShop.Instance.Configuration.Instance.ItemShopTableName}`
(`id`, `itemname`, `cost`, `buyback`)
Expand Down Expand Up @@ -109,6 +111,8 @@ public bool AddVehicle(int id, string name, decimal cost, bool change, bool dont
using var connection = createConnection();
using var command = connection.CreateCommand();

name = name.Length > 32 ? name.Substring(0, 32) : name;

command.CommandText = $@"
INSERT INTO `{ZaupShop.Instance.Configuration.Instance.VehicleShopTableName}`
(`id`, `vehiclename`, `cost`)
Expand Down
2 changes: 1 addition & 1 deletion ZaupShop/ZaupShop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<LangVersion>latest</LangVersion>
<RootNamespace>ZaupShop</RootNamespace>
<AssemblyName>ZaupShop</AssemblyName>
<Version>2.0.1</Version>
<Version>2.0.2</Version>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit e93313e

Please sign in to comment.