Skip to content

Commit

Permalink
Merge pull request #7 from Pustalorc/legacy
Browse files Browse the repository at this point in the history
Minor changes
  • Loading branch information
cemahseri authored Aug 5, 2019
2 parents 8b34fbf + c9b8fab commit 6ff1760
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 25 deletions.
60 changes: 50 additions & 10 deletions ZaupShop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,14 @@ public bool Buy(UnturnedPlayer playerid, string[] components0)
var array = Assets.find(EAssetType.VEHICLE);

var vAsset = array.Cast<VehicleAsset>()
.First(k => k?.vehicleName?.ToLower().Contains(components[1].ToLower()) == true);
.FirstOrDefault(k => k?.vehicleName?.ToLower().Contains(components[1].ToLower()) == true);

if (vAsset == null)
{
message = Instance.Translate("could_not_find", components[1]);
UnturnedChat.Say(playerid, message);
return false;
}

id = vAsset.id;
name = vAsset.vehicleName;
Expand Down Expand Up @@ -304,9 +311,16 @@ public bool Buy(UnturnedPlayer playerid, string[] components0)
if (!ushort.TryParse(components[0], out id))
{
var array = Assets.find(EAssetType.ITEM);
var iAsset = array.Cast<ItemAsset>().First(k =>
var iAsset = array.Cast<ItemAsset>().FirstOrDefault(k =>
k?.itemName?.ToLower().Contains(components[0].ToLower()) == true);

if (iAsset == null)
{
message = Instance.Translate("could_not_find", components[1]);
UnturnedChat.Say(playerid, message);
return false;
}

id = iAsset.id;
name = iAsset.itemName;
}
Expand Down Expand Up @@ -382,7 +396,14 @@ public void Cost(UnturnedPlayer playerid, string[] components)
var array = Assets.find(EAssetType.VEHICLE);

var vAsset = array.Cast<VehicleAsset>()
.First(k => k?.vehicleName?.ToLower().Contains(components[1].ToLower()) == true);
.FirstOrDefault(k => k?.vehicleName?.ToLower().Contains(components[1].ToLower()) == true);

if (vAsset == null)
{
message = Instance.Translate("could_not_find", components[1]);
UnturnedChat.Say(playerid, message);
return;
}

id = vAsset.id;
name = vAsset.vehicleName;
Expand Down Expand Up @@ -410,9 +431,16 @@ public void Cost(UnturnedPlayer playerid, string[] components)
if (!ushort.TryParse(components[0], out id))
{
var array = Assets.find(EAssetType.ITEM);
var iAsset = array.Cast<ItemAsset>().First(k =>
var iAsset = array.Cast<ItemAsset>().FirstOrDefault(k =>
k?.itemName?.ToLower().Contains(components[0].ToLower()) == true);

if (iAsset == null)
{
message = Instance.Translate("could_not_find", components[1]);
UnturnedChat.Say(playerid, message);
return;
}

id = iAsset.id;
name = iAsset.itemName;
}
Expand Down Expand Up @@ -468,30 +496,41 @@ public bool Sell(UnturnedPlayer playerid, string[] components)
}

string name = null;
ItemAsset vAsset = null;
if (!ushort.TryParse(components[0], out var id))
{
var array = Assets.find(EAssetType.ITEM);
var iAsset = array.Cast<ItemAsset>().First(k =>
var iAsset = array.Cast<ItemAsset>().FirstOrDefault(k =>
k?.itemName?.ToLower().Contains(components[0].ToLower()) == true);

if (iAsset == null)
{
message = Instance.Translate("could_not_find", components[1]);
UnturnedChat.Say(playerid, message);
return false;
}

id = iAsset.id;
name = iAsset.itemName;
}

if (Assets.find(EAssetType.ITEM, id) == null)
if (id == 0)
{
message = Instance.Translate("could_not_find", components[0]);
UnturnedChat.Say(playerid, message);
return false;
}

if (name == null && id != 0)
var vAsset = (ItemAsset) Assets.find(EAssetType.ITEM, id);

if (vAsset == null)
{
vAsset = (ItemAsset) Assets.find(EAssetType.ITEM, id);
name = vAsset.itemName;
message = Instance.Translate("could_not_find", components[0]);
UnturnedChat.Say(playerid, message);
return false;
}

if (name == null) name = vAsset.itemName;

// Get how many they have
if (playerid.Inventory.has(id) == null)
{
Expand Down Expand Up @@ -595,6 +634,7 @@ public bool Sell(UnturnedPlayer playerid, string[] components)
playerid.Player.gameObject.SendMessage("ZaupShopOnSell", new object[] {playerid, addmoney, amt, id},
SendMessageOptions.DontRequireReceiver);
UnturnedChat.Say(playerid, message);

return true;
}
}
Expand Down
30 changes: 15 additions & 15 deletions ZaupShop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,23 @@
<HintPath>lib\Assembly-CSharp-firstpass.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="BouncyCastle.Crypto, Version=1.8.3.0, Culture=neutral, PublicKeyToken=0e99375e54769942">
<SpecificVersion>False</SpecificVersion>
<Reference Include="BouncyCastle.Crypto">
<HintPath>Libraries\BouncyCastle.Crypto.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Google.Protobuf, Version=3.6.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<Reference Include="Google.Protobuf">
<HintPath>Libraries\Google.Protobuf.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="I18N.West, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<Reference Include="I18N.West">
<HintPath>Libraries\I18N.West.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="MySql.Data, Version=8.0.17.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<Reference Include="MySql.Data">
<HintPath>Libraries\MySql.Data.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Renci.SshNet, Version=2016.1.0.0, Culture=neutral, PublicKeyToken=1cee9f8bde3db106, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<Reference Include="Renci.SshNet">
<HintPath>Libraries\Renci.SshNet.dll</HintPath>
<Private>False</Private>
</Reference>
Expand All @@ -86,14 +81,19 @@
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Drawing.Design" />
<Reference Include="System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL" />
<Reference Include="System.Management">
<Private>False</Private>
</Reference>
<Reference Include="System.Transactions">
<Private>False</Private>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Data">
<Private>False</Private>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="Uconomy, Version=1.0.4.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<Reference Include="Uconomy">
<HintPath>lib\Uconomy.dll</HintPath>
<Private>False</Private>
</Reference>
Expand Down

0 comments on commit 6ff1760

Please sign in to comment.