add armor as lonley item
This commit is contained in:
@@ -33,6 +33,7 @@ export default function weaponList(globalData: IGlobalData) {
|
|||||||
var melees;
|
var melees;
|
||||||
var specialsWep;
|
var specialsWep;
|
||||||
var time;
|
var time;
|
||||||
|
var armor;
|
||||||
|
|
||||||
var primary = "";
|
var primary = "";
|
||||||
var secondary = "";
|
var secondary = "";
|
||||||
@@ -43,7 +44,7 @@ export default function weaponList(globalData: IGlobalData) {
|
|||||||
|
|
||||||
//Weapon Menu
|
//Weapon Menu
|
||||||
|
|
||||||
mp.events.add('showWeaponMenu', (primariesArr, secondariesArr, meleesArr, specialsArr, jsonTime, pistol_Amount, pistol50_Amount, Pistol_mk2_Amount, Combatpistol_Amount, SMG_Amount, Carbinerifle_Amount, Compactrifle_Amount, sniperrifle_Amount, Pumpshotgun_Amount, Schutzweste_Amount, Stungun_Amount) => {
|
mp.events.add('showWeaponMenu', (primariesArr, secondariesArr, meleesArr, specialsArr, armorArr, jsonTime, pistol_Amount, pistol50_Amount, Pistol_mk2_Amount, Combatpistol_Amount, SMG_Amount, Carbinerifle_Amount, Compactrifle_Amount, sniperrifle_Amount, Pumpshotgun_Amount, Schutzweste_Amount, Stungun_Amount) => {
|
||||||
if (!globalData.InMenu) {
|
if (!globalData.InMenu) {
|
||||||
|
|
||||||
globalData.InMenu = true;
|
globalData.InMenu = true;
|
||||||
@@ -53,7 +54,7 @@ export default function weaponList(globalData: IGlobalData) {
|
|||||||
melees = meleesArr;
|
melees = meleesArr;
|
||||||
specialsWep = specialsArr;
|
specialsWep = specialsArr;
|
||||||
time = JSON.parse(jsonTime);
|
time = JSON.parse(jsonTime);
|
||||||
|
armor = armorArr;
|
||||||
|
|
||||||
let dealItem = new UIMenuListItem("Waffentransport", "", new ItemsCollection(time));
|
let dealItem = new UIMenuListItem("Waffentransport", "", new ItemsCollection(time));
|
||||||
dealItem.BackColor = new Color(204, 170, 0);
|
dealItem.BackColor = new Color(204, 170, 0);
|
||||||
@@ -65,10 +66,11 @@ export default function weaponList(globalData: IGlobalData) {
|
|||||||
weaponMenu.AddItem(new UIMenuListItem("Sekundäre", "", new ItemsCollection(primaries)));
|
weaponMenu.AddItem(new UIMenuListItem("Sekundäre", "", new ItemsCollection(primaries)));
|
||||||
weaponMenu.AddItem(new UIMenuListItem("Nahkampf", "", new ItemsCollection(melees)));
|
weaponMenu.AddItem(new UIMenuListItem("Nahkampf", "", new ItemsCollection(melees)));
|
||||||
weaponMenu.AddItem(new UIMenuListItem("Spezial", "", new ItemsCollection(specialsWep)));
|
weaponMenu.AddItem(new UIMenuListItem("Spezial", "", new ItemsCollection(specialsWep)));
|
||||||
|
weaponMenu.AddItem(new UIMenuListItem("Schutzweste", "", new ItemsCollection(armor)));
|
||||||
|
weaponMenu.AddItem(saveItem);
|
||||||
weaponMenu.AddItem(WeaponStockItem);
|
weaponMenu.AddItem(WeaponStockItem);
|
||||||
weaponMenu.BindMenuToItem(getWeaponStockMenu(weaponMenu), WeaponStockItem);
|
weaponMenu.BindMenuToItem(getWeaponStockMenu(weaponMenu), WeaponStockItem);
|
||||||
weaponMenu.AddItem(dealItem);
|
weaponMenu.AddItem(dealItem);
|
||||||
weaponMenu.AddItem(saveItem);
|
|
||||||
weaponMenu.AddItem(cancelItem);
|
weaponMenu.AddItem(cancelItem);
|
||||||
weaponMenu.Visible = true;
|
weaponMenu.Visible = true;
|
||||||
|
|
||||||
@@ -102,6 +104,13 @@ export default function weaponList(globalData: IGlobalData) {
|
|||||||
specialWep = String(item.SelectedItem.DisplayText);
|
specialWep = String(item.SelectedItem.DisplayText);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "Schutzweste":
|
||||||
|
if (item.SelectedItem.DisplayText === "Keine") {
|
||||||
|
armor = "";
|
||||||
|
} else {
|
||||||
|
armor = String(item.SelectedItem.DisplayText);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -149,7 +158,7 @@ export default function weaponList(globalData: IGlobalData) {
|
|||||||
|
|
||||||
weaponMenu.ItemSelect.on((item) => {
|
weaponMenu.ItemSelect.on((item) => {
|
||||||
if (item.Text === "Waffen Nehmen") {
|
if (item.Text === "Waffen Nehmen") {
|
||||||
mp.events.callRemote("saveWeaponSelection", primary, secondary, melee, specialWep);
|
mp.events.callRemote("saveWeaponSelection", primary, secondary, melee, specialWep, armor);
|
||||||
weaponMenu.Close();
|
weaponMenu.Close();
|
||||||
globalData.InMenu = false;
|
globalData.InMenu = false;
|
||||||
} else if (item.Text === "Abbrechen") {
|
} else if (item.Text === "Abbrechen") {
|
||||||
|
|||||||
@@ -341,6 +341,7 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
List<string> secondarys = new List<string>();
|
List<string> secondarys = new List<string>();
|
||||||
List<string> melees = new List<string>();
|
List<string> melees = new List<string>();
|
||||||
List<string> specials = new List<string>();
|
List<string> specials = new List<string>();
|
||||||
|
List<string> armor = new List<string>();
|
||||||
List<string> timer = new List<string>();
|
List<string> timer = new List<string>();
|
||||||
int pistol_Amount = 0;
|
int pistol_Amount = 0;
|
||||||
int pistol50_Amount = 0;
|
int pistol50_Amount = 0;
|
||||||
@@ -358,6 +359,7 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
secondarys.Add("Keine");
|
secondarys.Add("Keine");
|
||||||
melees.Add("Keine");
|
melees.Add("Keine");
|
||||||
specials.Add("Keine");
|
specials.Add("Keine");
|
||||||
|
armor.Add("Keine");
|
||||||
|
|
||||||
using (var context = new DatabaseContext())
|
using (var context = new DatabaseContext())
|
||||||
{
|
{
|
||||||
@@ -428,6 +430,11 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
if (user.FactionRank.Order >= weapon.Rank)
|
if (user.FactionRank.Order >= weapon.Rank)
|
||||||
specials.Add(weapon.WeaponModel.ToString());
|
specials.Add(weapon.WeaponModel.ToString());
|
||||||
break;
|
break;
|
||||||
|
case 5:
|
||||||
|
if (user.FactionRank.Order >= weapon.Rank)
|
||||||
|
armor.Add(weapon.WeaponModel.ToString());
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -478,7 +485,7 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
player.TriggerEvent("showWeaponMenu", primarys.ToArray(), secondarys.ToArray(), melees.ToArray(), specials.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());
|
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()); ;
|
||||||
}
|
}
|
||||||
if (nearestJailReleasePoint != null)
|
if (nearestJailReleasePoint != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
client.RemoveAllWeapons();
|
client.RemoveAllWeapons();
|
||||||
client.GiveWeapon(weaponHash, 0);
|
client.GiveWeapon(weaponHash, 0);
|
||||||
}
|
}
|
||||||
|
if (slot == 5)
|
||||||
|
{
|
||||||
|
client.Armor = 100;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[RemoteEvent("cancelWeaponSelection")]
|
[RemoteEvent("cancelWeaponSelection")]
|
||||||
@@ -48,7 +52,7 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
}
|
}
|
||||||
|
|
||||||
[RemoteEvent("saveWeaponSelection")]
|
[RemoteEvent("saveWeaponSelection")]
|
||||||
public void SaveWeaponSelection(Player client, string primaryModel, string secondaryModel, string meleeModel, string specialModel)
|
public void SaveWeaponSelection(Player client, string primaryModel, string secondaryModel, string meleeModel, string specialModel, string armor)
|
||||||
{
|
{
|
||||||
client.RemoveAllWeapons();
|
client.RemoveAllWeapons();
|
||||||
if (!uint.TryParse(primaryModel, out uint primary))
|
if (!uint.TryParse(primaryModel, out uint primary))
|
||||||
@@ -70,17 +74,16 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
client.GiveWeapon((WeaponHash)primary, 300);
|
client.GiveWeapon((WeaponHash)primary, 300);
|
||||||
client.GiveWeapon((WeaponHash)secondary, 100);
|
client.GiveWeapon((WeaponHash)secondary, 100);
|
||||||
client.GiveWeapon((WeaponHash)melee, 1);
|
client.GiveWeapon((WeaponHash)melee, 1);
|
||||||
if (specialModel != "Schutzweste")
|
|
||||||
{
|
|
||||||
client.Armor = 0;
|
|
||||||
if (!uint.TryParse(specialModel, out uint special))
|
if (!uint.TryParse(specialModel, out uint special))
|
||||||
{
|
{
|
||||||
if (specialModel.Contains("mk2") && !specialModel.Contains("_mk2")) specialModel = specialModel.Replace("mk2", "_mk2");
|
if (specialModel.Contains("mk2") && !specialModel.Contains("_mk2")) specialModel = specialModel.Replace("mk2", "_mk2");
|
||||||
special = NAPI.Util.GetHashKey($"weapon_{specialModel}");
|
special = NAPI.Util.GetHashKey($"weapon_{specialModel}");
|
||||||
}
|
}
|
||||||
client.GiveWeapon((WeaponHash)special, 30);
|
client.GiveWeapon((WeaponHash)special, 30);
|
||||||
}
|
|
||||||
else
|
if(armor == "Schutzweste")
|
||||||
{
|
{
|
||||||
client.Armor = 100;
|
client.Armor = 100;
|
||||||
}
|
}
|
||||||
@@ -100,6 +103,9 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
FactionWeapon slot4 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == specialModel).FirstOrDefault();
|
FactionWeapon slot4 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == specialModel).FirstOrDefault();
|
||||||
if (slot4 != null)
|
if (slot4 != null)
|
||||||
slot4.Ammount -= 1;
|
slot4.Ammount -= 1;
|
||||||
|
FactionWeapon slot5 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == armor).FirstOrDefault();
|
||||||
|
if (slot5 != null)
|
||||||
|
slot5.Ammount -= 1;
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user