Clothe Shop finished
This commit is contained in:
@@ -148,6 +148,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
WeaponPoint nearestWeapon = PositionManager.WeaponPoints.Find(w => w.Position.DistanceTo(player.Position) <= 1.5 && w.FactionId == user.FactionId);
|
||||
JailReleasePoint nearestJailReleasePoint = PositionManager.JailReleasePoints.Find(j => j.Position.DistanceTo(player.Position) <= 1.5 && (user.FactionId == 1 || user.FactionId == 3) && user.GetData<bool>("duty"));
|
||||
ElevatorPoint nearestElevatorPoint = PositionManager.ElevatorPoints.Find(e => e.Position.DistanceTo(player.Position) <= 1.5 && (user.FactionId == 1 || user.FactionId == 3));
|
||||
ShopPoint nearestShopPoint = PositionManager.ShopPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5 && (!user.GetData<bool>("duty")));
|
||||
if (nearestDuty != null)// Duty Point
|
||||
{
|
||||
var nameTagColor = new Color(0, 0, 0);
|
||||
@@ -325,6 +326,10 @@ namespace ReallifeGamemode.Server.Events
|
||||
}
|
||||
player.TriggerEvent("showElevatorMenu", JsonConvert.SerializeObject(stages.ToArray()));
|
||||
}
|
||||
if(nearestShopPoint != null)
|
||||
{
|
||||
nearestShopPoint.clotheShop.LoadShopNUI(player);
|
||||
}
|
||||
if (user.FactionLeader)
|
||||
{
|
||||
player.TriggerEvent("CLIENT:StartGangwar");
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
pV.SetSharedData("sirenSound", newValue);
|
||||
|
||||
NAPI.ClientEvent.TriggerClientEventForAll("toggleVehicleSiren", pV, newValue);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ namespace ReallifeGamemode.Server.Events
|
||||
player.ClearAccessory(1);
|
||||
player.ClearAccessory(2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[RemoteEvent("updateDutyCloth")]
|
||||
@@ -152,5 +151,112 @@ namespace ReallifeGamemode.Server.Events
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("SERVER:BuyCharacterClothes")]
|
||||
public void RmtEvent_BuyClothes(Client client, string type, string jsonData)
|
||||
{
|
||||
/*
|
||||
* [0] ComponentID
|
||||
* [1] TextureID
|
||||
* [2] ClotheID
|
||||
* [3] TorsoID
|
||||
* [4] UndershirtID
|
||||
* [5] UndershirtTextureID
|
||||
* [6] Price
|
||||
*/
|
||||
|
||||
int[] data = JsonConvert.DeserializeObject<int[]>(jsonData);
|
||||
User user = client.GetUser();
|
||||
if (user.Handmoney < data[6])
|
||||
{
|
||||
client.TriggerEvent("clothesMenu:Error");
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == "clothe")
|
||||
{
|
||||
if (data[0] == 11)//for tops
|
||||
{
|
||||
client.SetClothes(11, data[2], data[1]); //set Top
|
||||
client.SetClothes(8, data[4], data[5]); //set undershirt
|
||||
client.SetClothes(3, data[3], 0); //set Torso
|
||||
}
|
||||
else
|
||||
{
|
||||
client.SetClothes(data[0], data[2], data[1]);
|
||||
}
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
|
||||
var clothes = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == data[0] && c.Duty == false);
|
||||
|
||||
if(clothes == null)
|
||||
{
|
||||
CharacterCloth newCloth = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = false,
|
||||
|
||||
SlotType = 0,
|
||||
SlotId = data[0],
|
||||
ClothId = data[2],
|
||||
Texture = data[1]
|
||||
};
|
||||
dbContext.CharacterClothes.Add(newCloth);
|
||||
}
|
||||
else
|
||||
{
|
||||
clothes.ClothId = data[2];
|
||||
clothes.Texture = data[1];
|
||||
}
|
||||
if(data[0] == 11)
|
||||
{
|
||||
var torso = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == 3 && c.Duty == false);
|
||||
var undershirt = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == 8 && c.Duty == false);
|
||||
if(torso == null)
|
||||
{
|
||||
CharacterCloth newTorso = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = false,
|
||||
|
||||
SlotType = 0,
|
||||
SlotId = 3,
|
||||
ClothId = data[3]
|
||||
};
|
||||
dbContext.CharacterClothes.Add(newTorso);
|
||||
}
|
||||
else
|
||||
{
|
||||
torso.ClothId = data[3];
|
||||
}
|
||||
if(undershirt == null)
|
||||
{
|
||||
CharacterCloth newUndershirt = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
Duty = false,
|
||||
SlotType = 0,
|
||||
SlotId = 8,
|
||||
ClothId = data[4],
|
||||
Texture = data[5]
|
||||
};
|
||||
dbContext.CharacterClothes.Add(newUndershirt);
|
||||
}
|
||||
else
|
||||
{
|
||||
undershirt.ClothId = data[4];
|
||||
undershirt.Texture = data[5];
|
||||
}
|
||||
}
|
||||
user.Handmoney -= data[6];
|
||||
client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney);
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
client.TriggerEvent("clothesMenu:updateLast", data[2], data[1], data[4], data[5], data[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ namespace ReallifeGamemode.Server
|
||||
};
|
||||
|
||||
InventoryManager.LoadItems();
|
||||
ShopManager.LoadClotheShops();
|
||||
|
||||
TuningManager.LoadTuningGarages();
|
||||
|
||||
@@ -81,6 +82,8 @@ namespace ReallifeGamemode.Server
|
||||
Economy.PaydayTimer();
|
||||
WeaponDealManager.WeaponDealTimer();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,9 +110,12 @@ namespace ReallifeGamemode.Server.Managers
|
||||
}
|
||||
else
|
||||
{
|
||||
houseBlips[house.Id] = NAPI.Blip.CreateBlip(40, house.Position, 0.7f, 11, "Haus", shortRange: true);
|
||||
//houseBlips[house.Id] = NAPI.Blip.CreateBlip(40, house.Position, 0.7f, 11, "Haus", shortRange: true); too many blips
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
houseLabels[house.Id] = NAPI.TextLabel.CreateTextLabel(text, house.Position, 10f, 1f, 0, new Color(255, 255, 255));
|
||||
|
||||
if (house.Price != 0)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Server.Shop.Clothing;
|
||||
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
@@ -17,6 +18,9 @@ namespace ReallifeGamemode.Server.Managers
|
||||
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>();
|
||||
|
||||
[ServerEvent(Event.ResourceStart)]
|
||||
public void OnResourceStart()
|
||||
{
|
||||
@@ -48,8 +52,11 @@ namespace ReallifeGamemode.Server.Managers
|
||||
new Vector3(0, 0, 0), 3, new Color(255, 255, 255, 50), false, 0);
|
||||
NAPI.TextLabel.CreateTextLabel("Stempeluhr - Dr\u00fccke ~y~E\n~s~Dienstkleidung - Dr\u00fccke ~y~K", d.Position, 7, 1, 0, new Color(255, 255, 255), false, 0);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion DutyPoints
|
||||
|
||||
#region WeaponPoints
|
||||
|
||||
WeaponPoint weaponPointLSPD = new WeaponPoint()
|
||||
{
|
||||
Position = new Vector3(460.3162, -981.0168, 30.68959),
|
||||
@@ -83,8 +90,11 @@ namespace ReallifeGamemode.Server.Managers
|
||||
new Vector3(0, 0, 0), 2, new Color(255, 255, 255, 50), false, 0);
|
||||
NAPI.TextLabel.CreateTextLabel("Waffenspind - Dr\u00fccke ~y~E", w.Position, 7, 1, 0, new Color(255, 255, 255), false, 0);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion WeaponPoints
|
||||
|
||||
#region JailReleasePoints
|
||||
|
||||
JailReleasePoint jailPointLSPD = new JailReleasePoint()
|
||||
{
|
||||
Position = new Vector3(459.5327, -988.8435, 24.91487)
|
||||
@@ -103,8 +113,11 @@ namespace ReallifeGamemode.Server.Managers
|
||||
new Vector3(0, 0, 0), 1.5f, new Color(255, 255, 255, 50), false, 0);
|
||||
NAPI.TextLabel.CreateTextLabel("Gefängnis PC - Dr\u00fccke ~y~E", j.Position, 7, 1, 0, new Color(255, 255, 255), false, 0);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion JailReleasePoints
|
||||
|
||||
#region ElevetaorPoints
|
||||
|
||||
ElevatorPoint FibElevatorPointEG = new ElevatorPoint()
|
||||
{
|
||||
Position = new Vector3(136.1958, -761.657, 242.152), //FBI oben
|
||||
@@ -134,32 +147,63 @@ namespace ReallifeGamemode.Server.Managers
|
||||
new Vector3(0, 0, 0), 1.5f, new Color(255, 255, 255, 50), false, 0);
|
||||
NAPI.TextLabel.CreateTextLabel("Aufzug - Dr\u00fccke ~y~E", j.Position, 7, 1, 0, new Color(255, 255, 255), false, 0);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion ElevetaorPoints
|
||||
|
||||
#region Shops
|
||||
foreach (var shop in ShopManager.clotheStores)
|
||||
{
|
||||
shop.LoadClothes();
|
||||
ShopPoint shopPoint = new ShopPoint()
|
||||
{
|
||||
Position = shop.vector,
|
||||
clotheShop = shop
|
||||
};
|
||||
ShopPoints.Add(shopPoint);
|
||||
}
|
||||
|
||||
foreach(ShopPoint s in ShopPoints)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
#endregion Shops
|
||||
}
|
||||
}
|
||||
|
||||
public class DutyPoint
|
||||
{
|
||||
public Vector3 Position { get; set; }
|
||||
public int FactionId { get; set; }
|
||||
}
|
||||
|
||||
public class WeaponPoint
|
||||
{
|
||||
public Vector3 Position { get; set; }
|
||||
public int FactionId { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
public class JailReleasePoint
|
||||
{
|
||||
public Vector3 Position { get; set; }
|
||||
}
|
||||
public class ElevatorPoint
|
||||
{
|
||||
public Vector3 Position { get; set; }
|
||||
public int FactionId { get; set; }
|
||||
public string Stage { get; set; }
|
||||
}
|
||||
public class DutyPoint
|
||||
{
|
||||
public Vector3 Position { get; set; }
|
||||
public int FactionId { get; set; }
|
||||
}
|
||||
|
||||
public class WeaponPoint
|
||||
{
|
||||
public Vector3 Position { get; set; }
|
||||
public int FactionId { get; set; }
|
||||
}
|
||||
|
||||
public class JailReleasePoint
|
||||
{
|
||||
public Vector3 Position { get; set; }
|
||||
}
|
||||
|
||||
public class ShopPoint
|
||||
{
|
||||
public Vector3 Position { get; set; }
|
||||
public ClotheShop clotheShop { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class ElevatorPoint
|
||||
{
|
||||
public Vector3 Position { get; set; }
|
||||
public int FactionId { get; set; }
|
||||
public string Stage { get; set; }
|
||||
}
|
||||
|
||||
|
||||
51
ReallifeGamemode.Server/Managers/ShopManager.cs
Normal file
51
ReallifeGamemode.Server/Managers/ShopManager.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Entities.Saves;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Shop.Clothing;
|
||||
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
public class ShopManager
|
||||
{
|
||||
|
||||
public static List<ClotheShop> clotheStores = new List<ClotheShop>();
|
||||
|
||||
public static void LoadClotheShops()
|
||||
{
|
||||
using(var dbContext = new DatabaseContext())
|
||||
{
|
||||
List<SavedBlip> discount = dbContext.Blips.ToList().FindAll(s => s.Name == "Binco" || s.Name == "Discount Store");
|
||||
List<SavedBlip> midclass = dbContext.Blips.ToList().FindAll(s => s.Name == "Suburban");
|
||||
List<SavedBlip> luxury = dbContext.Blips.ToList().FindAll(s => s.Name == "Ponsonbys");
|
||||
|
||||
foreach(var store in discount) {
|
||||
Vector3 pos = new Vector3(store.PositionX, store.PositionY, store.PositionZ);
|
||||
ClotheShop newShop = new ClotheShop(1, pos);
|
||||
clotheStores.Add(newShop);
|
||||
NAPI.Util.ConsoleOutput($"Loading ClotheShop {store.Name}");
|
||||
}
|
||||
foreach(var store in midclass)
|
||||
{
|
||||
Vector3 pos = new Vector3(store.PositionX, store.PositionY, store.PositionZ);
|
||||
ClotheShop newShop = new ClotheShop(2, pos);
|
||||
clotheStores.Add(newShop);
|
||||
NAPI.Util.ConsoleOutput($"Loading ClotheShop {store.Name}");
|
||||
}
|
||||
foreach (var store in luxury)
|
||||
{
|
||||
Vector3 pos = new Vector3(store.PositionX, store.PositionY, store.PositionZ);
|
||||
ClotheShop newShop = new ClotheShop(2, pos);
|
||||
clotheStores.Add(newShop);
|
||||
NAPI.Util.ConsoleOutput($"Loading ClotheShop {store.Name}");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
|
||||
namespace ReallifeGamemode.Server.Shop.Clothing
|
||||
{
|
||||
public class Clothe : ShopClothe
|
||||
{
|
||||
public string clothe;
|
||||
public int undershirtId;
|
||||
public int torsoId;
|
||||
}
|
||||
}
|
||||
@@ -1,92 +1,52 @@
|
||||
using GTANetworkAPI;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
|
||||
namespace ReallifeGamemode.Server.Shop.Clothing
|
||||
{
|
||||
public class ClotheShop
|
||||
{
|
||||
public int category { get; set; } = 1;
|
||||
public int category { get; set; }
|
||||
public Vector3 vector { get; set; }
|
||||
public List<ShopClothe> clotheList = new List<ShopClothe>();
|
||||
|
||||
|
||||
public ClotheShop(int category)
|
||||
public ClotheShop(int category, Vector3 vector)
|
||||
{
|
||||
this.category = category;
|
||||
this.vector = vector;
|
||||
LoadClothes();
|
||||
}
|
||||
|
||||
public void LoadClothes()
|
||||
{
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
clotheList = dbContext.ShopClothes.ToList().FindAll(c => c.Category == category);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[Command("buyclothes")]
|
||||
public void LoadShopNUI(Client client)
|
||||
{
|
||||
LoadClothes();
|
||||
bool gender = client.GetUser().GetCharacter().Gender;
|
||||
List<ShopClothe> tops = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 11);
|
||||
List<ShopClothe> legs = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 4);
|
||||
List<ShopClothe> shoes = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 6);
|
||||
List<ShopClothe> accessoires = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 7);
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
List<Array> clothes = new List<Array>
|
||||
{
|
||||
List<Clothe> clothes = new List<Clothe>();
|
||||
bool gender = client.GetUser().Character.Gender;
|
||||
foreach (var clothe in clotheList)
|
||||
{
|
||||
if(clothe.TypeId == "clothes" )
|
||||
{
|
||||
switch (clothe.ComponentId)
|
||||
{
|
||||
case 11: //tops
|
||||
List<ClothCombination> combinations = dbContext.ClothCombinations.Where(c => c.Top == clothe.ClotheId && c.Gender == gender).ToList();
|
||||
foreach (var combination in combinations)
|
||||
{
|
||||
var top = new Clothe
|
||||
{
|
||||
ComponentId = clothe.ComponentId, //needs to be fist bc it acts like an identifier in JS
|
||||
ClotheId = clothe.ClotheId,
|
||||
Gender = gender,
|
||||
TypeId = "clothes",
|
||||
clothe = "clothes",
|
||||
Category = category,
|
||||
Price = clothe.Price,
|
||||
undershirtId = combination.Undershirt,
|
||||
torsoId = combination.Torso
|
||||
};
|
||||
clothes.Add(top);
|
||||
}
|
||||
break;
|
||||
default: //everything else
|
||||
var garment = new Clothe
|
||||
{
|
||||
ComponentId = clothe.ComponentId, //needs to be fist bc it acts like an identifier in JS
|
||||
ClotheId = clothe.ClotheId,
|
||||
Gender = gender,
|
||||
TypeId = "clothes",
|
||||
clothe = "clothes",
|
||||
Category = category,
|
||||
Price = clothe.Price,
|
||||
undershirtId = -1, //will not be used unless top
|
||||
torsoId = -1 //will not be used unless top
|
||||
};
|
||||
clothes.Add(garment);
|
||||
break;
|
||||
tops.ToArray(),
|
||||
legs.ToArray(),
|
||||
shoes.ToArray(),
|
||||
accessoires.ToArray()
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
client.TriggerEvent("clothesMenu:updateData", JsonConvert.SerializeObject(category), JsonConvert.SerializeObject(clothes.ToArray()));
|
||||
}
|
||||
client.TriggerEvent("clothesMenu:updateData", JsonConvert.SerializeObject(category), JsonConvert.SerializeObject(clothes.ToArray()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user