simplify weapon rack amount

This commit is contained in:
hydrant
2021-04-11 05:06:11 +02:00
parent 3702b571da
commit c82bc12bcd
2 changed files with 32 additions and 110 deletions

View File

@@ -359,19 +359,6 @@ namespace ReallifeGamemode.Server.Events
List<string> specials = new List<string>();
List<string> armor = new List<string>();
List<string> timer = new List<string>();
int pistol_Amount = 0;
int pistol50_Amount = 0;
int Pistol_mk2_Amount = 0;
int Combatpistol_Amount = 0;
int SMG_Amount = 0;
int Carbinerifle_Amount = 0;
int Compactrifle_Amount = 0;
int sniperrifle_Amount = 0;
int Pumpshotgun_Amount = 0;
int Schutzweste_Amount = 0;
int Stungun_Amount = 0;
int CombatPDW_Amount = 0;
int Assaultrifle_Amount = 0;
string dealTime = "Starten";
primarys.Add("Keine");
secondarys.Add("Keine");
@@ -454,64 +441,31 @@ namespace ReallifeGamemode.Server.Events
break;
}
}
foreach (var weapon in weapons)
{
if (weapon.WeaponModel == "Pistol")
{
pistol_Amount = weapon.Ammount;
}
else if (weapon.WeaponModel == "Pistol50")
{
pistol50_Amount = weapon.Ammount;
}
else if (weapon.WeaponModel == "Pistol_MK2")
{
Pistol_mk2_Amount = weapon.Ammount;
}
else if (weapon.WeaponModel == "Combatpistol")
{
Combatpistol_Amount = weapon.Ammount;
}
else if (weapon.WeaponModel == "SMG")
{
SMG_Amount = weapon.Ammount;
}
else if (weapon.WeaponModel == "CarbineRifle")
{
Carbinerifle_Amount = weapon.Ammount;
}
else if (weapon.WeaponModel == "CompactRifle")
{
Compactrifle_Amount = weapon.Ammount;
}
else if (weapon.WeaponModel == "sniperrifle")
{
sniperrifle_Amount = weapon.Ammount;
}
else if (weapon.WeaponModel == "PumpShotgun")
{
Pumpshotgun_Amount = weapon.Ammount;
}
else if (weapon.WeaponModel == "Schutzweste")
{
Schutzweste_Amount = weapon.Ammount;
}
else if (weapon.WeaponModel == "Stungun")
{
Stungun_Amount = weapon.Ammount;
}
else if (weapon.WeaponModel == "assaultrifle")
{
Assaultrifle_Amount = weapon.Ammount;
}
else if (weapon.WeaponModel == "CombatPDW")
{
CombatPDW_Amount = weapon.Ammount;
}
}
}
player.TriggerEvent("showWeaponMenu", primarys.ToArray(), secondarys.ToArray(), melees.ToArray(), specials.ToArray(), armor.ToArray(), JsonConvert.SerializeObject(timer.ToArray()), pistol_Amount.ToString(), pistol50_Amount.ToString(), Pistol_mk2_Amount.ToString(), Combatpistol_Amount.ToString(), SMG_Amount.ToString(), Carbinerifle_Amount.ToString(), Compactrifle_Amount.ToString(), sniperrifle_Amount.ToString(), Pumpshotgun_Amount.ToString(), Schutzweste_Amount.ToString(), Stungun_Amount.ToString(), CombatPDW_Amount.ToString(), Assaultrifle_Amount.ToString()); ;
List<string> allWeapons = context.FactionWeapons.Select(w => w.WeaponModel).Distinct().ToList();
List<WeaponRackWeaponAmountInfo> amountInfos = new List<WeaponRackWeaponAmountInfo>();
foreach (var weapon in allWeapons)
{
int amount = 0;
var tempFactionWeapon = weapons.Where(f => f.WeaponModel == weapon).FirstOrDefault();
if(tempFactionWeapon != null)
{
amount = tempFactionWeapon.Ammount;
}
amountInfos.Add(new WeaponRackWeaponAmountInfo()
{
WeaponModel = weapon,
Amount = amount
});
}
player.TriggerEvent("showWeaponMenu", primarys.ToArray(), secondarys.ToArray(), melees.ToArray(), specials.ToArray(), armor.ToArray(), JsonConvert.SerializeObject(timer.ToArray()), JsonConvert.SerializeObject(amountInfos));
}
}
if (nearestJailReleasePoint != null)
{