Merge Ammunation in Develop
This commit is contained in:
@@ -235,6 +235,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
ItemshopPoint nearestItemShopPoint = PositionManager.itemshopPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5);
|
||||
JobPoint nearestJobPoint = PositionManager.JobPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.6);
|
||||
Player nearestCuffPlayer = PositionManager.cuffPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.6 && user.GetData<bool>("duty"));
|
||||
AmmunationPoint nearestAmmunationPoint = PositionManager.AmmunationPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5);
|
||||
|
||||
if (user?.FactionId != null)
|
||||
{
|
||||
@@ -516,6 +517,17 @@ namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
nearestFriseurPoint.friseurShop.LoadShopNUI(player);
|
||||
}
|
||||
if (nearestAmmunationPoint != null)
|
||||
{
|
||||
if (!user.WeaponLicense)
|
||||
{
|
||||
player.SendNotification("~r~Du besitzt keinen Waffenschein");
|
||||
}
|
||||
else
|
||||
{
|
||||
nearestAmmunationPoint.Ammunation.LoadShopNUI(player);
|
||||
}
|
||||
}
|
||||
if (user.FactionLeader)
|
||||
{
|
||||
player.TriggerEvent("CLIENT:StartGangwar");
|
||||
|
||||
@@ -118,5 +118,24 @@ namespace ReallifeGamemode.Server.Events
|
||||
context.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:Ammunation_BuyWeapon")]
|
||||
public void AmmunationBuyWeapoon(Player player, string weaponmodel, int ammo, int 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(NAPI.Util.WeaponNameToModel(weaponmodel), ammo);
|
||||
//client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,6 +122,7 @@ namespace ReallifeGamemode.Server
|
||||
ShopManager.LoadClotheShops();
|
||||
ShopManager.LoadItemShops();
|
||||
ShopManager.LoadFriseur();
|
||||
ShopManager.LoadAmmunations();
|
||||
TuningManager.LoadTuningGarages();
|
||||
|
||||
TimeManager.StartTimeManager();
|
||||
|
||||
@@ -6,6 +6,7 @@ using ReallifeGamemode.Server.Shop.SevenEleven;
|
||||
using ReallifeGamemode.Server.Shop.Friseur;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Shop.Ammunation;
|
||||
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
@@ -29,6 +30,8 @@ namespace ReallifeGamemode.Server.Managers
|
||||
|
||||
public static List<Player> cuffPoints = new List<Player>();
|
||||
|
||||
public static List<AmmunationPoint> AmmunationPoints = new List<AmmunationPoint>();
|
||||
|
||||
public static void LoadPositionManager()
|
||||
{
|
||||
#region DutyPoints
|
||||
@@ -280,6 +283,20 @@ namespace ReallifeGamemode.Server.Managers
|
||||
NAPI.TextLabel.CreateTextLabel("24/7 - Dr\u00fccke ~y~E", s.Position, 7, 1, 0, new Color(255, 255, 255), false, 0);
|
||||
}
|
||||
|
||||
foreach (Ammunation s in ShopManager.Ammunations)
|
||||
{
|
||||
NAPI.Marker.CreateMarker(1, new Vector3(s.vector.X, s.vector.Y, s.vector.Z - 2), new Vector3(s.vector.X, s.vector.Y, s.vector.Z + 1),
|
||||
new Vector3(0, 0, 0), 2, new Color(255, 255, 255, 50), false, 0);
|
||||
NAPI.TextLabel.CreateTextLabel("Ammunation - Dr\u00fccke ~y~E", s.vector, 7, 1, 0, new Color(255, 255, 255), false, 0);
|
||||
|
||||
AmmunationPoint ammuShop = new AmmunationPoint
|
||||
{
|
||||
Position = s.vector,
|
||||
Ammunation = s
|
||||
};
|
||||
AmmunationPoints.Add(ammuShop);
|
||||
}
|
||||
|
||||
#endregion Shops
|
||||
}
|
||||
|
||||
@@ -407,3 +424,9 @@ public class ElevatorPoint
|
||||
public int FactionId { get; set; }
|
||||
public string Stage { get; set; }
|
||||
}
|
||||
|
||||
public class AmmunationPoint
|
||||
{
|
||||
public Vector3 Position { get; set; }
|
||||
public Ammunation Ammunation { get; set; }
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Shop.Clothing;
|
||||
using ReallifeGamemode.Server.Shop.SevenEleven;
|
||||
using ReallifeGamemode.Server.Shop.Friseur;
|
||||
using ReallifeGamemode.Server.Shop.Ammunation;
|
||||
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
@@ -14,6 +15,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
public static List<ClotheShop> clotheStores = new List<ClotheShop>();
|
||||
public static List<ItemShop> itemShops = new List<ItemShop>();
|
||||
public static List<Friseur> FriseurStores = new List<Friseur>();
|
||||
public static List<Ammunation> Ammunations = new List<Ammunation>();
|
||||
|
||||
public static void LoadClotheShops()
|
||||
{
|
||||
@@ -81,5 +83,20 @@ namespace ReallifeGamemode.Server.Managers
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadAmmunations()
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
List<SavedBlip> ammunations = dbContext.Blips.ToList().FindAll(s => s.Name == "Ammunation");
|
||||
|
||||
foreach (var store in ammunations)
|
||||
{
|
||||
Vector3 pos = new Vector3(store.PositionX, store.PositionY, store.PositionZ);
|
||||
Ammunation newShop = new Ammunation(pos);
|
||||
Ammunations.Add(newShop);
|
||||
}
|
||||
NAPI.Util.ConsoleOutput($"Loading {ammunations.Count} Ammunations");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
40
ReallifeGamemode.Server/Shop/Ammunation/Ammunation.cs
Normal file
40
ReallifeGamemode.Server/Shop/Ammunation/Ammunation.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
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
|
||||
{
|
||||
public class Ammunation
|
||||
{
|
||||
public Vector3 vector { get; set; }
|
||||
public List<Weapon> weaponList = new List<Weapon>();
|
||||
|
||||
public Ammunation(Vector3 position)
|
||||
{
|
||||
this.vector = position;
|
||||
LoadWeapons();
|
||||
}
|
||||
|
||||
public void LoadWeapons()
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
weaponList = dbContext.Weapons.ToList().FindAll(w => w.AmmunationActive == true);
|
||||
}
|
||||
}
|
||||
public void LoadShopNUI(Player client)
|
||||
{
|
||||
|
||||
List<Weapon> shopWeapons = weaponList.ToList();
|
||||
client.TriggerEvent("AmmunationShop:LoadNativeUI", JsonConvert.SerializeObject(shopWeapons));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user