Clientside Ammunation
This commit is contained in:
@@ -7,6 +7,8 @@ using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
|
||||
namespace ReallifeGamemode.Server.Shop.Ammunation
|
||||
{
|
||||
@@ -25,7 +27,7 @@ namespace ReallifeGamemode.Server.Shop.Ammunation
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
weaponList = dbContext.Weapons.ToList();
|
||||
weaponList = dbContext.Weapons.ToList().FindAll(w => w.AmmunationActive == true);
|
||||
}
|
||||
}
|
||||
public void LoadShopNUI(Player client)
|
||||
@@ -34,5 +36,25 @@ namespace ReallifeGamemode.Server.Shop.Ammunation
|
||||
List<Weapon> shopWeapons = weaponList.ToList();
|
||||
client.TriggerEvent("AmmunationShop:LoadNativeUI", JsonConvert.SerializeObject(shopWeapons));
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:Ammunation_BuyWeapon")]
|
||||
public void AmmunationBuyWeapoon(Player player, WeaponHash weaponmodel, int ammo , int price)
|
||||
{
|
||||
player.SendChatMessage("JO IS ANGEKOMMEN" + weaponmodel + " " + ammo + " " + price);
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User user = player.GetUser(dbContext);
|
||||
|
||||
if (user.Handmoney < price)
|
||||
{
|
||||
player.SendNotification("Du hast nicht genügend Geld bei dir");
|
||||
return;
|
||||
}
|
||||
user.Handmoney -= price;
|
||||
dbContext.SaveChanges();
|
||||
player.GiveWeapon((WeaponHash)weaponmodel, ammo);
|
||||
//client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user