Add ItemShop, fix ClotheShop Payment, fix Vehicle Respawn, Add Vehicle Lock from outside
This commit is contained in:
@@ -863,5 +863,42 @@ namespace ReallifeGamemode.Server.Managers
|
||||
ChatService.SendMessage(target, $"{client.Name} hat deine Anfrage angenommen.");
|
||||
|
||||
}
|
||||
|
||||
[RemoteEvent("SERVER:BuyItems")]
|
||||
public void SrvEvent_BuyItem(Client client, string itemName)
|
||||
{
|
||||
IItem shopItem = GetItemByName(itemName);
|
||||
|
||||
using(var dbContext = new DatabaseContext()){
|
||||
User user = client.GetUser(dbContext);
|
||||
|
||||
if (user.Handmoney < shopItem.Price)
|
||||
{
|
||||
client.TriggerEvent("itemMenu:Error");
|
||||
return;
|
||||
}
|
||||
|
||||
UserItem item = dbContext.UserItems.Where(i => i.ItemId == shopItem.Id && i.UserId == user.Id).FirstOrDefault();
|
||||
if(item == null)
|
||||
{
|
||||
var newItem = new UserItem
|
||||
{
|
||||
ItemId = shopItem.Id,
|
||||
UserId = user.Id,
|
||||
Amount = 1,
|
||||
Slot = -1
|
||||
};
|
||||
dbContext.UserItems.Add(newItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
item.Amount += 1;
|
||||
}
|
||||
user.Handmoney -= shopItem.Price;
|
||||
dbContext.SaveChanges();
|
||||
client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,23 @@
|
||||
using System.Collections.Generic;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Server.Shop.Clothing;
|
||||
using ReallifeGamemode.Server.Shop.SevenEleven;
|
||||
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
public class PositionManager : Script
|
||||
{
|
||||
public static List<DutyPoint> DutyPoints = new List<DutyPoint>();
|
||||
public static List<ColShape> DutyColShapes = new List<ColShape>();
|
||||
|
||||
public static List<WeaponPoint> WeaponPoints = new List<WeaponPoint>();
|
||||
public static List<ColShape> WeaponColShapes = new List<ColShape>();
|
||||
|
||||
public static List<JailReleasePoint> JailReleasePoints = new List<JailReleasePoint>();
|
||||
public static List<ColShape> JailReleaseColShapes = new List<ColShape>();
|
||||
|
||||
public static List<ElevatorPoint> ElevatorPoints = new List<ElevatorPoint>();
|
||||
public static List<ColShape> ElevatorColShapes = new List<ColShape>();
|
||||
|
||||
public static List<ShopPoint> ShopPoints = new List<ShopPoint>();
|
||||
public static List<ColShape> ShopColShapes = new List<ColShape>();
|
||||
public static List<ClotheshopPoint> clotheshopPoints = new List<ClotheshopPoint>();
|
||||
|
||||
public static List<ItemshopPoint> itemshopPoints = new List<ItemshopPoint>();
|
||||
|
||||
[ServerEvent(Event.ResourceStart)]
|
||||
public void OnResourceStart()
|
||||
@@ -154,21 +152,40 @@ namespace ReallifeGamemode.Server.Managers
|
||||
foreach (var shop in ShopManager.clotheStores)
|
||||
{
|
||||
shop.LoadClothes();
|
||||
ShopPoint shopPoint = new ShopPoint()
|
||||
ClotheshopPoint shopPoint = new ClotheshopPoint()
|
||||
{
|
||||
Position = shop.vector,
|
||||
clotheShop = shop
|
||||
};
|
||||
ShopPoints.Add(shopPoint);
|
||||
clotheshopPoints.Add(shopPoint);
|
||||
}
|
||||
|
||||
foreach(ShopPoint s in ShopPoints)
|
||||
foreach(ClotheshopPoint s in clotheshopPoints)
|
||||
{
|
||||
NAPI.Marker.CreateMarker(1, new Vector3(s.Position.X, s.Position.Y, s.Position.Z - 2), new Vector3(s.Position.X, s.Position.Y, s.Position.Z + 1),
|
||||
new Vector3(0, 0, 0), 2, new Color(255, 255, 255, 50), false, 0);
|
||||
NAPI.TextLabel.CreateTextLabel("Kleiderladen - Dr\u00fccke ~y~E", s.Position, 7, 1, 0, new Color(255, 255, 255), false, 0);
|
||||
}
|
||||
|
||||
|
||||
foreach(var shop in ShopManager.itemShops)
|
||||
{
|
||||
shop.LoadItems();
|
||||
ItemshopPoint shopPoint = new ItemshopPoint()
|
||||
{
|
||||
Position = shop.vector3,
|
||||
itemShop = shop
|
||||
};
|
||||
itemshopPoints.Add(shopPoint);
|
||||
}
|
||||
|
||||
foreach(ItemshopPoint s in itemshopPoints)
|
||||
{
|
||||
NAPI.Marker.CreateMarker(1, new Vector3(s.Position.X, s.Position.Y, s.Position.Z - 2), new Vector3(s.Position.X, s.Position.Y, s.Position.Z + 1),
|
||||
new Vector3(0, 0, 0), 2, new Color(255, 255, 255, 50), false, 0);
|
||||
NAPI.TextLabel.CreateTextLabel("24/7 - Dr\u00fccke ~y~E", s.Position, 7, 1, 0, new Color(255, 255, 255), false, 0);
|
||||
}
|
||||
|
||||
#endregion Shops
|
||||
}
|
||||
|
||||
@@ -193,13 +210,20 @@ public class JailReleasePoint
|
||||
public Vector3 Position { get; set; }
|
||||
}
|
||||
|
||||
public class ShopPoint
|
||||
public class ClotheshopPoint
|
||||
{
|
||||
public Vector3 Position { get; set; }
|
||||
public ClotheShop clotheShop { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class ItemshopPoint
|
||||
{
|
||||
public Vector3 Position { get; set; }
|
||||
public ItemShop itemShop { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class ElevatorPoint
|
||||
{
|
||||
public Vector3 Position { get; set; }
|
||||
|
||||
@@ -6,6 +6,7 @@ using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Entities.Saves;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Shop.Clothing;
|
||||
using ReallifeGamemode.Server.Shop.SevenEleven;
|
||||
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
@@ -13,6 +14,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
|
||||
public static List<ClotheShop> clotheStores = new List<ClotheShop>();
|
||||
public static List<ItemShop> itemShops = new List<ItemShop>();
|
||||
|
||||
public static void LoadClotheShops()
|
||||
{
|
||||
@@ -42,10 +44,26 @@ namespace ReallifeGamemode.Server.Managers
|
||||
clotheStores.Add(newShop);
|
||||
NAPI.Util.ConsoleOutput($"Loading ClotheShop {store.Name}");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadItemShops()
|
||||
{
|
||||
using(var dbContext = new DatabaseContext())
|
||||
{
|
||||
int id = 0;
|
||||
List<SavedBlip> shops = dbContext.Blips.ToList().FindAll(s => s.Name == "24/7");
|
||||
foreach(var store in shops)
|
||||
{
|
||||
Vector3 pos = new Vector3(store.PositionX, store.PositionY, store.PositionZ);
|
||||
ItemShop newShop = new ItemShop(pos, id);
|
||||
itemShops.Add(newShop);
|
||||
id++;
|
||||
}
|
||||
NAPI.Util.ConsoleOutput($"Loaded {itemShops.Count}x 24/7");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Timers;
|
||||
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
@@ -862,17 +864,22 @@ namespace ReallifeGamemode.Server.Managers
|
||||
}
|
||||
|
||||
[ServerEvent(Event.VehicleDeath)]
|
||||
public static void VehicleManagerVehicleDeath(Vehicle vehicle)
|
||||
public static async Task VehicleManagerVehicleDeath(Vehicle vehicle)
|
||||
{
|
||||
ServerVehicle serverVehicle = GetServerVehicleFromVehicle(vehicle);
|
||||
|
||||
|
||||
if (serverVehicle == null)
|
||||
{
|
||||
vehicle.Delete();
|
||||
return;
|
||||
}
|
||||
|
||||
serverVehicle.Spawn(vehicle);
|
||||
Vehicle newVeh = serverVehicle.Spawn(vehicle);
|
||||
await Task.Delay(2000);
|
||||
newVeh.Repair();
|
||||
newVeh.Rotation = new Vector3(0, 0, serverVehicle.Heading);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user