Archived
Private
Public Access
1
0

Update 29.10.2022

This commit is contained in:
2022-10-29 18:17:27 +02:00
parent 2a1d18cb9d
commit 494fb2d8c5
355 changed files with 408588 additions and 155997 deletions

13
C#/Mosleys/.idea/.idea.Mosleys/.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,13 @@
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/contentModel.xml
/projectSettingsUpdater.xml
/.idea.Mosleys.iml
/modules.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="Marc FiveM" uuid="a2400c43-5d7b-4a49-bcd5-7891ed52b50c">
<driver-ref>mariadb</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.mariadb.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mariadb://161.97.88.49:3306/s6_princep</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectDictionaryState">
<dictionary name="leon" />
</component>
</project>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DiscordProjectSettings">
<option name="show" value="PROJECT_FILES" />
<option name="description" value="" />
</component>
</project>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders>
<Path>Output</Path>
</attachedFolders>
<explicitIncludes />
<explicitExcludes />
</component>
</project>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MarkdownSettings">
<enabledExtensions>
<entry key="MermaidLanguageExtension" value="false" />
<entry key="PlantUMLLanguageExtension" value="false" />
</enabledExtensions>
</component>
</project>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="com.jetbrains.rider.android.RiderAndroidMiscFileCreationComponent">
<option name="ENSURE_MISC_FILE_EXISTS" value="true" />
</component>
</project>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="SqlDialectMappings">
<file url="file://$PROJECT_DIR$/Mosleys.Server/MySql.cs" dialect="GenericSQL" />
<file url="file://$PROJECT_DIR$/Mosleys.Server/ServerScript.cs" dialect="GenericSQL" />
<file url="file://$PROJECT_DIR$/Mosleys.Server/Utils.cs" dialect="GenericSQL" />
</component>
</project>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
</component>
</project>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,204 @@
using System;
using System.Collections.Generic;
using System.Linq;
using CitizenFX.Core;
using CitizenFX.Core.Native;
using CitizenFX.Core.UI;
using Mosleys.Client.Extensions;
using Mosleys.Client.Models;
using Nexd.ESX.Client;
namespace Mosleys.Client {
public static class ExhibitHandler {
public static bool ExhibitsSpawned = false;
public static bool CatalogOpen = false;
private static Exhibit[] _realExhibits;
public static void OnTick() {
// Digital Exhibit
var dist = World.GetDistance(Game.Player.Character.Position, Mosleys.Config.DigitalShowPoint);
if (dist <= 2.0f && !CatalogOpen) {
Screen.DisplayHelpTextThisFrame("Drücke ~INPUT_CONTEXT~ um den Katalog zu öffnen");
if (Game.IsControlJustReleased(0, Control.Context))
OpenCatalog();
}
// Real Exhibits
if (!ExhibitsSpawned) return;
Exhibit closestExhibit = new Exhibit();
float closestDist = float.MaxValue;
bool foundClosest = false;
foreach (var exhibit in _realExhibits) {
if (exhibit?.Ready != true) continue;
exhibit.Vehicle?.Repair();
dist = World.GetDistance(Game.Player.Character.Position, exhibit.Location.ToVector3());
if (dist <= 5.0f && dist < closestDist) {
closestDist = dist;
closestExhibit = exhibit;
foundClosest = true;
}
}
if (!foundClosest) return;
closestExhibit.ShowText();
if (closestExhibit.TestDrive) return;
if (Game.IsControlJustReleased(0, Control.Enter))
closestExhibit.StartTestDrive();
if (Game.IsControlJustReleased(0, Control.Context))
closestExhibit.Buy();
}
public static async void SpawnExhibits() {
var exhibits = await Utils.GetAllExhibits();
_realExhibits = new Exhibit[Mosleys.Config.CarSlots.Length];
for (int i = 0; i < exhibits.Length; i++) {
var exhibit = exhibits[i];
if (exhibit.Slot == 0) continue;
var realExhibit = new Exhibit {
Uuid = exhibit.Uuid,
Owner = exhibit.Owner,
Description = exhibit.Description,
Price = exhibit.Price,
Slot = exhibit.Slot,
Location = Mosleys.Config.CarSlots[exhibit.Slot],
Properties = new VehicleProperties(exhibit.Vehicle),
TestDrive = exhibit.TestDrive
};
if (!exhibit.TestDrive)
realExhibit.Spawn();
else realExhibit.Ready = true;
_realExhibits[exhibit.Slot] = realExhibit;
}
ExhibitsSpawned = true;
}
public static void Cleanup() {
ExhibitsSpawned = false;
foreach (var exhibit in _realExhibits) {
exhibit?.Despawn();
}
_realExhibits = null;
}
public static void UpdateSlot(int slot) {
if (!ExhibitsSpawned) return;
if (_realExhibits[slot] == null)
_realExhibits[slot] = new Exhibit { Slot = slot };
_realExhibits[slot].Update();
}
public static void OnRemove(int slot) {
if (!ExhibitsSpawned || _realExhibits[slot] == null) return;
_realExhibits[slot].Despawn();
_realExhibits[slot] = null;
}
private static async void OpenCatalog(string vehicleUuid = null) {
if (CatalogOpen) return;
CatalogOpen = true;
Screen.ShowNotification("Lade Katalog...");
var exhibits = (await Utils.GetAllExhibits()).Where(exhibit => exhibit.Slot == 0).ToArray();
if (exhibits.Length == 0) {
Notify.Error("Es gibt zur Zeit keine Autos im Katalog!");
CatalogOpen = false;
return;
}
ESX.UI.Menu.CloseAll();
Game.Player.Character.Freeze(true);
var camera = World.CreateCamera(Mosleys.Config.DigitalCamera.ToVector3(),
new Vector3(0, 0, Mosleys.Config.DigitalCamera.W), API.GetGameplayCamFov());
camera.PointAt(Mosleys.Config.CarSlots[0].ToVector3() + new Vector3(0, 0, 1.0f));
camera.IsActive = true;
API.RenderScriptCams(true, false, 0, true, true);
var index = 0;
if (vehicleUuid != null) {
if (exhibits.Any(exhibit => exhibit.Uuid == vehicleUuid))
index = exhibits.ToList().FindIndex(exhibit => exhibit.Uuid == vehicleUuid);
}
var currentCar = new Exhibit { Slot = 0 };
currentCar.FromExhibit(exhibits[index]);
var carNames = exhibits.Select(exhibit => exhibit.DisplayName()).ToArray();
var menuData = new ESX.UI.MenuData() {
title = Mosleys.Config.MenuTitle,
align = "top-left",
elements = new List<ESX.UI.MenuElement> {
new ESX.UI.MenuElement {
label = "Auto",
name = "car",
value = index,
options = carNames,
type = "slider"
},
new ESX.UI.MenuElement {
label = "Probefahrt",
name = "testdrive",
},
new ESX.UI.MenuElement {
label = "Kaufen",
name = "buy"
}
}
};
ESX.UI.Menu.Open("default", API.GetCurrentResourceName(), "digital_exhibits", menuData, async (dData, dMenu) => {
var data = new ESX.UI.MenuData(dData);
var menu = new ESX.UI.Menu(dMenu);
if (data.current.name == "testdrive") {
menu.Close();
CatalogOpen = false;
await currentCar.StartTestDrive(false);
OpenCatalog(currentCar.Uuid);
}
if (data.current.name == "buy") {
menu.Close();
CatalogOpen = false;
currentCar.Buy();
}
}, (dData, dMenu) => {
var menu = new ESX.UI.Menu(dMenu);
menu.Close();
CatalogOpen = false;
}, (dData, dMenu) => {
var data = new ESX.UI.MenuData(dData);
if (data.current.name == "car") {
var newCar = exhibits[data.elements[0].value];
if (currentCar.Uuid == newCar.Uuid) return;
currentCar.Despawn();
currentCar.FromExhibit(newCar);
}
});
while (CatalogOpen) {
currentCar.ShowText(false, 2.5f, 0.15f);
await BaseScript.Delay(0);
}
API.RenderScriptCams(false, false, 0, true, true);
camera.IsActive = false;
camera.Delete();
Game.Player.Character.Freeze(false);
currentCar.Despawn();
}
}
}

View File

@@ -0,0 +1,12 @@
using System;
using CitizenFX.Core.Native;
using Mosleys.Shared.Models;
namespace Mosleys.Client.Extensions {
public static class ExhibitVehicleExtensions {
public static string DisplayName(this ExhibitVehicle exhibit) =>
API.GetDisplayNameFromVehicleModel(Convert.ToUInt32((exhibit.Vehicle as dynamic).model));
}
}

View File

@@ -0,0 +1,9 @@
using CitizenFX.Core;
namespace Mosleys.Client.Extensions {
public static class Vector4Extensions {
public static Vector3 ToVector3(this Vector4 vector) => new Vector3(vector.X, vector.Y, vector.Z);
}
}

View File

@@ -0,0 +1,23 @@
using CitizenFX.Core;
using CitizenFX.Core.Native;
namespace Mosleys.Client.Extensions {
public static class VehicleExtensions {
public static void Freeze(this Entity vehicle, bool toggle) => API.FreezeEntityPosition(vehicle.Handle, toggle);
public static void SetDoorLockStatus(this Vehicle vehicle, LockStatus status) => API.SetVehicleDoorsLocked(vehicle.Handle, (int)status);
}
public enum LockStatus {
None,
Unlocked,
Locked,
LockForPlayers,
LockForInVehicle,
LockedInitially,
ForceShutDoors,
LockedButCanBeDamaged
}
}

View File

@@ -0,0 +1,202 @@
using System.Threading.Tasks;
using CitizenFX.Core;
using CitizenFX.Core.Native;
using Mosleys.Client.Extensions;
using Mosleys.Shared.Models;
using Nexd.ESX.Client;
namespace Mosleys.Client.Models {
public class Exhibit {
private static void DrawText3D(in Vector3 pos, in string text, float scale = 1, in bool rotate = true) {
OutputArgument screenX = new OutputArgument(), screenY = new OutputArgument();
bool onScreen = Function.Call<bool>(Hash.GET_SCREEN_COORD_FROM_WORLD_COORD , pos.X, pos.Y, pos.Z, screenX, screenY);
if (onScreen) {
Vector3 cam = API.GetGameplayCamCoord();
float dist = API.GetDistanceBetweenCoords(cam.X, cam.Y, cam.Z, pos.X, pos.Y, pos.Z, true);
if (rotate)
scale = (((1 / dist) * 2) * (1 / API.GetGameplayCamFov()) * 100) * scale;
API.SetTextColour(220, 220, 220, 255);
API.SetTextScale(0.0f * scale, 0.40f * scale);
API.SetTextFont(4);
API.SetTextProportional(true);
API.SetTextCentre(true);
API.SetTextEntry("STRING");
API.AddTextComponentString(text);
API.EndTextCommandDisplayText(screenX.GetResult<float>(), screenY.GetResult<float>());
}
}
private static string HandleIntColor(int number) {
if (number <= 0) return "Nein";
return "~g~" + number;
}
public bool Ready { get; set; }
public bool Spawned { get; private set; }
public string Uuid { get; set; }
public string Owner { get; set; }
public string Description { get; set; }
public int Price { get; set; }
public int Slot { get; set; }
public bool TestDrive { get; set; }
public VehicleProperties Properties { get; set; }
public Vehicle Vehicle { get; set; }
public Vector4 Location { get; set; }
public async void Spawn() {
if (Spawned) Despawn();
Vehicle = await Mosleys.SpawnVehicle(Properties.model, Location, true);
ESX.Game.SetVehicleProperties(Vehicle, Properties);
Vehicle.IsInvincible = true;
Vehicle.SetDoorLockStatus(LockStatus.Locked);
Vehicle.Freeze(true);
Vehicle.PlaceOnGround();
BaseScript.TriggerServerEvent("ls:mainCheck", Properties.plate, Vehicle.Handle, true);
Spawned = true;
Ready = true;
}
public void Despawn() {
Spawned = false;
Vehicle?.Delete();
}
public async void Update() {
Ready = false;
var exhibit = await Utils.GetExhibitBySlot(Slot);
FromExhibit(exhibit);
}
public void FromExhibit(ExhibitVehicle exhibit) {
Ready = false;
Uuid = exhibit.Uuid;
Owner = exhibit.Owner;
Description = exhibit.Description;
Price = exhibit.Price;
Slot = exhibit.Slot;
Properties = new VehicleProperties(exhibit.Vehicle);
Location = Mosleys.Config.CarSlots[Slot];
TestDrive = exhibit.TestDrive;
if (Spawned || TestDrive) Despawn();
if (!TestDrive) Spawn();
else Ready = true;
}
public void FromExhibit(ExhibitVehicle exhibit, int slot) {
Ready = false;
Uuid = exhibit.Uuid;
Owner = exhibit.Owner;
Description = exhibit.Description;
Price = exhibit.Price;
Slot = slot;
Properties = new VehicleProperties(exhibit.Vehicle);
Location = Mosleys.Config.CarSlots[Slot];
TestDrive = exhibit.TestDrive;
if (Spawned || TestDrive) Despawn();
if (!TestDrive) Spawn();
else Ready = true;
}
public void ShowText(bool keyText = true, float scale = 1.0f, float spacing = 0.1f) {
if (!Ready) return;
float x = Location.X;
float y = Location.Y;
float z = Location.Z;
if (TestDrive)
DrawText3D(new Vector3(x, y, z + 1.1f), "[~r~Dieses Auto ist gerade bei einer Probefahrt~s~]");
else {
string turbo = "~r~Nein";
if (Properties.modTurbo >= 1) turbo = "~g~Ja";
string line1 = "[~b~" + Vehicle.DisplayName + "~s~]";
string line2 = "[Turbo : " + turbo + "~s~] [Motor : ~r~" + HandleIntColor(Properties.modEngine) + "~s~] [Getriebe : ~r~" + HandleIntColor(Properties.modTransmission) + "~s~]";
string line3 = "[Federung : ~r~" + HandleIntColor(Properties.modSuspension) + "~s~] [Panzerung : ~r~" + HandleIntColor(Properties.modArmor) + "~s~] [Bremsen : ~r~" + HandleIntColor(Properties.modBrakes) + "~s~]";
string line4 = "[Beschreibung : ~r~" + Description + "~s~]";
if (keyText) {
string line5 = "Drücke [~r~E~s~] zum kaufen [$~r~" + Price + "~s~]";
const string line6 = "Drücke [~r~F~s~] zum probefahren [~r~90 sek~s~]";
DrawText3D(new Vector3(x, y, z + 1.0f + (spacing * 1)), line6, scale);
DrawText3D(new Vector3(x, y, z + 1.0f + (spacing * 2)), line5, scale);
}
else {
DrawText3D(new Vector3(x, y, z + 1.0f + (spacing * 2)), "[Preis : ~r~" + Price + "~s~]", scale);
}
DrawText3D(new Vector3(x, y, z + 1.0f + (spacing * 3)), line4, scale);
DrawText3D(new Vector3(x, y, z + 1.0f + (spacing * 4)), line3, scale);
DrawText3D(new Vector3(x, y, z + 1.0f + (spacing * 5)), line2, scale);
DrawText3D(new Vector3(x, y, z + 1.0f + (spacing * 6)), line1, scale);
}
}
public async Task StartTestDrive(bool notifyServer = true) {
var lastPos = Game.Player.Character.Position;
if (notifyServer) BaseScript.TriggerServerEvent("mosleys:server:testDrive", Slot, true);
var vehicle = await Mosleys.SpawnVehicle(Properties.model, Mosleys.Config.TestDriveLocation);
ESX.Game.SetVehicleProperties(vehicle, Properties);
BaseScript.TriggerEvent("craftix:refuelVehicle", vehicle.Handle);
Game.Player.Character.SetIntoVehicle(vehicle, VehicleSeat.Driver);
var startTime = Game.GameTime;
var lastSecond = 0;
while (Game.GameTime - startTime <= Mosleys.Config.TestDriveTime) {
int elapsedTime = (int)((Game.GameTime - startTime) / 1000.0f);
if (elapsedTime > lastSecond) {
lastSecond++;
Mosleys.DoCustomHudText($"Probefahrt endet in {Mosleys.Config.TestDriveTime / 1000 - elapsedTime} Sekunden!", 1100);
}
if (Game.IsControlJustReleased(0, Control.VehicleExit)) break;
await BaseScript.Delay(0);
}
vehicle.Delete();
Game.Player.Character.Position = lastPos;
if (notifyServer) BaseScript.TriggerServerEvent("mosleys:server:testDrive", Slot, false);
}
public async void Buy() {
if (!await Mosleys.DisplayConfirmationDialog("Möchtest du dieses Auto wirklich kaufen?")) return;
var taken = await Mosleys.IsPlateTaken(Properties.plate);
if (taken) {
Properties.plate = await Mosleys.GeneratePlate();
Notify.Warning("Das Kennzeichen des Fahrzeugs ist bereits angemeldet. Es wurde ein neues Kennzeichen generiert.");
}
var hasMoney = await Mosleys.ServerCallback<bool>("mosleys:server:checkMoney", Price);
if (!hasMoney) {
Notify.Error("Du hast nicht genügend Geld!");
return;
}
var success = await Mosleys.ServerCallback<bool>("mosleys:server:buyVehicle", new BuyData {
Uuid = Uuid,
Plate = Properties.plate
});
if (!success) {
Notify.Error("Dieses Auto steht nicht mehr zum verkauf!");
return;
}
var vehicle = await Mosleys.SpawnVehicle(Properties.model, Mosleys.Config.SpawnLocation);
ESX.Game.SetVehicleProperties(vehicle, Properties);
vehicle.EngineHealth = 1000;
vehicle.Repair();
vehicle.DirtLevel = 0;
BaseScript.TriggerEvent("craftix:refuelVehicle", vehicle.Handle);
Game.Player.Character.SetIntoVehicle(vehicle, VehicleSeat.Driver);
}
}
}

View File

@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{48D35232-689B-457F-A46E-C770F1EF4218}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Mosleys.Client</RootNamespace>
<AssemblyName>Mosleys.Client.net</AssemblyName>
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>../Output</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup>
<PostBuildEvent>del Newtonsoft.Json.xml</PostBuildEvent>
</PropertyGroup>
<ItemGroup>
<Reference Include="CitizenFX.Core">
<HintPath>..\Librarys\CitizenFX.Core.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="CitizenFX.Core.Client">
<HintPath>..\Librarys\CitizenFX.Core.Client.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.CSharp">
<HintPath>..\Librarys\Microsoft.CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ExhibitHandler.cs" />
<Compile Include="Extensions\ExhibitVehicleExtensions.cs" />
<Compile Include="Extensions\Vector4Extensions.cs" />
<Compile Include="Extensions\VehicleExtensions.cs" />
<Compile Include="Models\Exhibit.cs" />
<Compile Include="Mosleys.cs" />
<Compile Include="Notify.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SellHandler.cs" />
<Compile Include="Utils.cs" />
<Compile Include="VehicleManager.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Mosleys.Shared\Mosleys.Shared.csproj">
<Project>{95000252-da88-4a79-8958-ca70b42ce0f9}</Project>
<Name>Mosleys.Shared</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,132 @@
using System;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using CitizenFX.Core;
using CitizenFX.Core.Native;
using Mosleys.Client.Extensions;
using Mosleys.Shared;
using Nexd.ESX.Client;
namespace Mosleys.Client {
public sealed class Mosleys : BaseScript {
public static Config Config;
public static bool InArea = false;
private static TaskCompletionSource<bool> _dialogTask;
private static Mosleys _instance;
public Mosleys() {
_instance = this;
Config = Config.LoadConfig();
CreateBlip();
EventHandlers["mosleys:dialog_accept"] += new Action(() => _dialogTask?.TrySetResult(true));
EventHandlers["mosleys:dialog_deny"] += new Action(() => _dialogTask?.TrySetResult(false));
EventHandlers["onClientResourceStart"] += new Action<string>(OnStart);
EventHandlers["onResourceStop"] += new Action<string>(OnStop);
EventHandlers["mosleys:client:updateSlot"] += new Action<int>(ExhibitHandler.UpdateSlot);
EventHandlers["mosleys:client:onRemove"] += new Action<int>(ExhibitHandler.OnRemove);
EventHandlers["mosleys:client:openManageMenu"] += new Action(VehicleManager.OpenMenu);
}
public static Task<T> ServerCallback<T>(string name, [Optional] dynamic args) {
var source = new TaskCompletionSource<T>();
ESX.TriggerServerCallback(name, new Action<dynamic>(o => {
source.TrySetResult((T)o);
}), args);
return source.Task;
}
public static Task<Vehicle> SpawnVehicle(int model, Vector4 coords, bool local = false) {
var source = new TaskCompletionSource<Vehicle>();
if (local) {
ESX.Game.Raw.SpawnLocalVehicle(model, coords.ToVector3(), coords.W, new Action<int>(handle => {
source.TrySetResult(new Vehicle(handle));
}));
}
else {
ESX.Game.Raw.SpawnVehicle(model, coords.ToVector3(), coords.W, new Action<int>(handle => {
source.TrySetResult(new Vehicle(handle));
}));
}
return source.Task;
}
public static Task<bool> DisplayConfirmationDialog(string title) {
_dialogTask = new TaskCompletionSource<bool>();
TriggerEvent("okokRequests:RequestMenuData", -1, Config.MenuTitle, title, "mosleys:dialog_accept", "client", "", 0, "mosleys:dialog_deny");
return _dialogTask.Task;
}
public static Task<string> DisplayTextDialog(string placeholder) {
var source = new TaskCompletionSource<string>();
ESX.UI.Menu.Open("dialog", API.GetCurrentResourceName(), "test_dialog", new ESX.UI.MenuData() {
title = placeholder,
type = "default",
align = "center"
}, (dData, dMenu) => {
source.TrySetResult(dData.value as string);
ESX.UI.Menu.Close(new ESX.UI.Menu(dMenu));
}, (dData, dMenu) => {
source.TrySetResult(null);
ESX.UI.Menu.Close(new ESX.UI.Menu(dMenu));
});
return source.Task;
}
public static void DoCustomHudText(string message, int duration) {
_instance.Exports["mythic_notify"].DoCustomHudText("branco", message, duration, true);
}
public static async Task<bool> IsPlateTaken(string plate) {
var taken = await _instance.Exports["esx_vehicleshop"].IsPlateTaken(plate);
return Convert.ToBoolean(taken);
}
public static async Task<string> GeneratePlate() {
var plate = await _instance.Exports["esx_vehicleshop"].GeneratePlate();
return Convert.ToString(plate);
}
private void CreateBlip() {
var blip = new Blip(API.AddBlipForCoord(Config.Blip.Position.X, Config.Blip.Position.Y, Config.Blip.Position.Z));
blip.Sprite = Config.Blip.Sprite;
blip.Color = Config.Blip.Color;
blip.Scale = Config.Blip.Scale;
blip.Name = Config.MenuTitle;
blip.IsShortRange = true;
API.SetBlipDisplay(blip.Handle, 4);
}
private void OnStart(string resourceName) {
if (resourceName != API.GetCurrentResourceName()) return;
Tick += async () => {
var dist = World.GetDistance(Game.Player.Character.Position, Config.Blip.Position);
if (dist <= Config.SpawnRadius) {
if (!InArea) {
ExhibitHandler.SpawnExhibits();
InArea = true;
}
SellHandler.OnTick();
ExhibitHandler.OnTick();
}else if (InArea) {
ExhibitHandler.Cleanup();
InArea = false;
}
};
}
private void OnStop(string resourceName) {
if (resourceName != API.GetCurrentResourceName()) return;
if (ExhibitHandler.ExhibitsSpawned)
ExhibitHandler.Cleanup();
}
}
}

View File

@@ -0,0 +1,16 @@
using CitizenFX.Core;
namespace Mosleys.Client {
public class Notify {
public static void SendMessage(string title, string message, int duration, string type, bool noSound = false) {
BaseScript.TriggerEvent("okokNotify:Alert", title, message, duration, type, noSound);
}
public static void Info(string message) => SendMessage(Mosleys.Config.MenuTitle, message, 5000, "info");
public static void Success(string message) => SendMessage(Mosleys.Config.MenuTitle, message, 5000, "success");
public static void Warning(string message) => SendMessage(Mosleys.Config.MenuTitle, message, 5000, "warning");
public static void Error(string message) => SendMessage(Mosleys.Config.MenuTitle, message, 5000, "error");
}
}

View File

@@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Mosleys.Client")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Mosleys.Client")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("48D35232-689B-457F-A46E-C770F1EF4218")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,175 @@
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using CitizenFX.Core;
using CitizenFX.Core.Native;
using CitizenFX.Core.UI;
using Mosleys.Client.Extensions;
using Mosleys.Shared.Models;
using Nexd.ESX.Client;
namespace Mosleys.Client {
public static class SellHandler {
private static bool _menuOpen = false;
private static SellData _data;
public static void OnTick() {
if (Game.Player.Character.IsInVehicle()) {
World.DrawMarker(MarkerType.HorizontalCircleSkinny, Mosleys.Config.SellLocation, Vector3.Zero, Vector3.Zero,
new Vector3(3.7f, 3.7f, 0.2f), Color.FromArgb(155, 229, 255));
float distance = World.GetDistance(Game.Player.Character.Position, Mosleys.Config.SellLocation);
if (distance <= 4.0f && !_menuOpen) {
Screen.DisplayHelpTextThisFrame("Drücke ~INPUT_CONTEXT~ um das Menü zu öffnen");
if (Game.IsControlJustReleased(0, Control.Context))
HandleSell();
}
}
}
private static async void HandleSell() {
var vehicle = Game.Player.LastVehicle;
var props = ESX.Game.GetVehicleProperties(vehicle);
// Check Vehice Class
if (Mosleys.Config.ForbiddenVehicleClasses.Contains((int)vehicle.ClassType)) {
Notify.Error("Du kannst dieses Fahrzeug hier nicht verkaufen!");
return;
}
// Check Ownership
var owner = await Mosleys.ServerCallback<bool>("mosleys:server:checkVehicleOwnership", props.plate);
if (!owner) {
Notify.Error("Dieses Fahrzeug gehört dir nicht!");
return;
}
vehicle.Freeze(true);
ESX.UI.Menu.CloseAll();
_data = new SellData();
// Create Menu
var menuData = new ESX.UI.MenuData {
title = Mosleys.Config.MenuTitle,
align = "top-left",
elements = new List<ESX.UI.MenuElement>(new [] {
new ESX.UI.MenuElement {
label = "Stellplatztyp wählen",
name = "choose_parkingspace",
value = 0,
options = new [] { "Ausgestellt", "Katalog" },
type = "slider"
},
new ESX.UI.MenuElement {
label = "Beschreibung hinzufügen",
name = "choose_description"
},
new ESX.UI.MenuElement {
label = "Preis wählen",
name = "choose_price"
},
new ESX.UI.MenuElement {
label = "Fertig",
name = "done"
}
})
};
ESX.UI.Menu.Open("default", API.GetCurrentResourceName(), "sell_menu", menuData, (dData, dMenu) => {
HandleMenuInteraction(new ESX.UI.Menu(dMenu), new ESX.UI.MenuData(dData));
}, (dData, dMenu) => {
ESX.UI.Menu.Close(new ESX.UI.Menu(dMenu));
vehicle.Freeze(false);
_menuOpen = false;
});
_menuOpen = true;
}
private static async void HandleMenuInteraction(ESX.UI.Menu menu, ESX.UI.MenuData data) {
if (data.current.name == "choose_description") {
var description = await Mosleys.DisplayTextDialog("Beschreibung");
if (description == "Beschreibung") return;
if (description.Length > 60) {
Notify.Error("Die Beschreibung darf maximal 60 Zeichen lang sein!");
return;
}
_data.Description = description;
}
if (data.current.name == "choose_price") {
var sPrice = await Mosleys.DisplayTextDialog("Preis");
if (!int.TryParse(sPrice, out int price)) {
Notify.Error("Der eingegebene Wert ist keine Zahl!");
return;
}
if (sPrice.Length > 7) {
Notify.Error("Dein Auto darf maximal $9.999.999 kosten!");
return;
}
if (price < Mosleys.Config.MinSellPrice) {
Notify.Error($"Der Preis muss mindestens ${Mosleys.Config.MinSellPrice} betragen!");
return;
}
_data.Price = price;
}
if (data.current.name == "done") {
if (_data.Price == 0) {
Notify.Error("Lege zuerst einen Preis fest!");
return;
}
if (!await Mosleys.DisplayConfirmationDialog("Möchtest du das Auto wirklich verkaufen?")) {
Game.Player.LastVehicle.Freeze(false);
menu.Close();
_menuOpen = false;
return;
}
menu.Close();
_menuOpen = false;
_data.ParkingSpace = data.elements[0].value;
if (_data.ParkingSpace == 0) {
var hasMoney = await Mosleys.ServerCallback<bool>("mosleys:server:checkMoney", Mosleys.Config.ExhibitPrice);
if (!hasMoney) {
Notify.Error($"Du hast nicht genügend Geld! Ein Ausstellungsplatz kostet ${Mosleys.Config.ExhibitPrice}.");
return;
}
}
// Prepare Vehicle
var vehicle = Game.Player.LastVehicle;
vehicle.EngineHealth = 1000;
vehicle.IsEngineRunning = false;
vehicle.Repair();
vehicle.DirtLevel = 0;
var props = ESX.Game.GetVehicleProperties(vehicle);
_data.VehicleProperties = props.GetRaw();
BaseScript.TriggerServerEvent("esx_vehicleshop:deleteVehicle", props.plate);
var success = await Mosleys.ServerCallback<bool>("mosleys:server:sellVehicle", _data) || _data.ParkingSpace == 1;
vehicle.Delete();
if (success)
Notify.Success("Auto ausgestellt!");
else
Notify.Warning("Alle Stellplätze sind belegt, Dein Auto kommt in den Katalog, bis ein Stellplatz frei wird.");
Notify.Info($"Beim Verkauf werden {Mosleys.Config.SellBill * 100}% Provision abgezogen.");
}
}
}
}

View File

@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Threading.Tasks;
using CitizenFX.Core;
using Mosleys.Shared.Models;
namespace Mosleys.Client {
public static class Utils {
public static async Task<ExhibitVehicle[]> GetAllExhibits() {
dynamic data = await Mosleys.ServerCallback<dynamic>("mosleys:server:getExhibits");
try {
List<ExhibitVehicle> vehicles = new List<ExhibitVehicle>();
foreach (var exhibit in data.vehicles) {
vehicles.Add(ExhibitVehicle.FromDynamic(exhibit));
}
return vehicles.ToArray();
}
catch (Exception e) {
Debug.WriteLine(e.ToString());
}
return Array.Empty<ExhibitVehicle>();
}
public static async Task<ExhibitVehicle[]> GetPlayerExhibits() {
dynamic data = await Mosleys.ServerCallback<dynamic>("mosleys:server:getPlayerExhibits");
try {
List<ExhibitVehicle> vehicles = new List<ExhibitVehicle>();
foreach (var exhibit in data.vehicles) {
vehicles.Add(ExhibitVehicle.FromDynamic(exhibit));
}
return vehicles.ToArray();
}
catch (Exception e) {
Debug.WriteLine(e.ToString());
}
return Array.Empty<ExhibitVehicle>();
}
public static async Task<ExhibitVehicle> GetExhibitBySlot(int slot) {
dynamic data = await Mosleys.ServerCallback<dynamic>("mosleys:server:getExhibitBySlot", slot);
return ExhibitVehicle.FromDynamic(data);
}
public static void PrintDynamic(dynamic data, string prefix = "") {
foreach (var element in (data as IDictionary<string, object>)) {
Debug.WriteLine($"{prefix}{element.Key}: {element.Value}");
if (element.Value.GetType() == typeof(ExpandoObject)) {
PrintDynamic(element.Value, prefix + "\t");
}
if (element.Value.GetType() == typeof(List<object>)) {
Debug.WriteLine(prefix + "\t", string.Join(", ", element.Value));
}
}
}
}
}

View File

@@ -0,0 +1,199 @@
using System.Collections.Generic;
using System.Linq;
using CitizenFX.Core;
using CitizenFX.Core.Native;
using Mosleys.Client.Extensions;
using Mosleys.Client.Models;
using Mosleys.Shared.Models;
using Nexd.ESX.Client;
namespace Mosleys.Client {
public static class VehicleManager {
private static bool _menuOpen = false;
private static Exhibit _currentCar;
public static async void OpenMenu() {
if (_menuOpen) _currentCar?.Despawn();
var exhibits = await Utils.GetPlayerExhibits();
if (exhibits.Length == 0) {
Notify.Error("Du hast keine Autos ausgestellt!");
_menuOpen = false;
return;
}
Camera camera = null;
if (!_menuOpen) {
Game.Player.Character.Freeze(true);
camera = World.CreateCamera(Mosleys.Config.DigitalCamera.ToVector3(),
new Vector3(0, 0, Mosleys.Config.DigitalCamera.W), API.GetGameplayCamFov());
camera.PointAt(Mosleys.Config.CarSlots[0].ToVector3() + new Vector3(0, 0, 1.0f));
camera.IsActive = true;
API.RenderScriptCams(true, false, 0, true, true);
}
_menuOpen = true;
_currentCar = new Exhibit { Slot = 0 };
_currentCar.FromExhibit(exhibits[0], 0);
var menuData = new ESX.UI.MenuData {
title = Mosleys.Config.MenuTitle,
align = "top-left",
elements = exhibits.Select(exhibit => new ESX.UI.MenuElement {
name = exhibit.Uuid,
label = exhibit.DisplayName() + " - $" + exhibit.Price
}).ToList()
};
ESX.UI.Menu.CloseAll();
ESX.UI.Menu.Open("default", API.GetCurrentResourceName(), "owner_menu", menuData, (dData, dMenu) => {
var data = new ESX.UI.MenuData(dData);
OpenSubMenu(exhibits.Single(exhibit => exhibit.Uuid == data.current.name));
}, (dData, dMenu) => {
var menu = new ESX.UI.Menu(dMenu);
menu.Close();
_menuOpen = false;
}, (dData, dMenu) => {
var data = new ESX.UI.MenuData(dData);
var index = data.elements.FindIndex(element => element.name == data.current.name);
_currentCar.Despawn();
_currentCar.FromExhibit(exhibits[index], 0);
});
while (_menuOpen) {
_currentCar.ShowText(false, 5.0f, 0.15f);
await BaseScript.Delay(0);
}
if (camera != null) {
API.RenderScriptCams(false, false, 0, true, true);
camera.IsActive = false;
camera.Delete();
Game.Player.Character.Freeze(false);
_currentCar.Despawn();
}
}
private static void OpenSubMenu(ExhibitVehicle exhibit) {
var menuData = new ESX.UI.MenuData {
title = Mosleys.Config.MenuTitle + " - " + exhibit.DisplayName(),
align = "top-left",
elements = new List<ESX.UI.MenuElement> {
new ESX.UI.MenuElement {
name = "change_price",
label = "Preis ändern"
},
new ESX.UI.MenuElement {
name = "change_description",
label = "Beschreibung ändern"
},
new ESX.UI.MenuElement {
name = "delete",
label = "Zurückziehen"
}
}
};
if (exhibit.Slot == 0) {
var elements = menuData.elements;
elements.Insert(0, new ESX.UI.MenuElement {
name = "push",
label = $"Ausstellen (${Mosleys.Config.ExhibitPrice})"
});
menuData.elements = elements;
}
ESX.UI.Menu.Open("default", API.GetCurrentResourceName(), "owner_vehicle_menu", menuData, async (dData, dMenu) => {
var data = new ESX.UI.MenuData(dData);
var menu = new ESX.UI.Menu(dMenu);
if (data.current.name == "change_price") {
var sPrice = await Mosleys.DisplayTextDialog("Neuer Preis");
if (!int.TryParse(sPrice, out int price)) {
Notify.Error("Der eingegebene Wert ist keine Zahl!");
return;
}
if (sPrice.Length > 7) {
Notify.Error("Dein Auto darf maximal $9.999.999 kosten!");
return;
}
if (price < Mosleys.Config.MinSellPrice) {
Notify.Error($"Der Preis muss mindestens ${Mosleys.Config.MinSellPrice} betragen!");
return;
}
exhibit.Price = price;
var success = await Mosleys.ServerCallback<bool>("mosleys:server:updateExhibit", new ExhibitUpdate {
Action = UpdateAction.Update,
Exhibit = exhibit
});
if (success) Notify.Success("Der Preis wurde geändert!");
else Notify.Error("Der Preis konnte nicht geändert werden!");
}
if (data.current.name == "change_description") {
var description = await Mosleys.DisplayTextDialog("Beschreibung");
if (description == "Beschreibung") return;
if (description.Length > 60) {
Notify.Error("Die Beschreibung darf maximal 60 Zeichen lang sein!");
return;
}
exhibit.Description = description;
var success = await Mosleys.ServerCallback<bool>("mosleys:server:updateExhibit", new ExhibitUpdate {
Action = UpdateAction.Update,
Exhibit = exhibit
});
if (success) Notify.Success("Die Beschreibung wurde geändert!");
else Notify.Error("Die Beschreibung konnte nicht geändert werden!");
}
if (data.current.name == "delete") {
var confirmation = await Mosleys.DisplayConfirmationDialog("Möchtest du dieses Auto wirklich aus dem Sortiment nehmen?");
if (!confirmation) return;
var success = await Mosleys.ServerCallback<bool>("mosleys:server:updateExhibit", new ExhibitUpdate {
Action = UpdateAction.Delete,
Exhibit = exhibit
});
if (success) Notify.Success("Dein Auto wird wieder in die Garage geliefert!");
else Notify.Error("Das Auto konnte nicht zurückgezogen werden!");
if (success) {
ESX.UI.Menu.CloseAll();
OpenMenu();
}
}
if (data.current.name == "push") {
var hasMoney = await Mosleys.ServerCallback<bool>("mosleys:server:checkMoney", Mosleys.Config.ExhibitPrice);
if (!hasMoney) {
Notify.Error("Du hast nicht genügend Geld!");
return;
}
var newSlot = await Mosleys.ServerCallback<int>("mosleys:server:push", exhibit.Uuid);
if (newSlot != 0) Notify.Success("Auto ausgestellt");
else Notify.Error("Das Auto konnte nicht ausgestellt werden!");
if (newSlot != 0) {
menu.Close();
exhibit.Slot = newSlot;
OpenSubMenu(exhibit);
}
}
}, (dData, dMenu) => {
OpenMenu();
});
}
}
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]

View File

@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]

View File

@@ -0,0 +1 @@
1772fe7811bac0b83ee8d664ce41b0555ef86dfc

View File

@@ -0,0 +1,16 @@
D:\Programmierstuff\C#\Mosleys\Mosleys.Client\bin\Release\CitizenFX.Core.dll
D:\Programmierstuff\C#\Mosleys\Mosleys.Client\bin\Release\System.Reflection.Metadata.dll
D:\Programmierstuff\C#\Mosleys\Mosleys.Client\bin\Release\System.Collections.Immutable.dll
D:\Programmierstuff\C#\Mosleys\Mosleys.Client\bin\Release\MsgPack.dll
D:\Programmierstuff\C#\Mosleys\Mosleys.Client\bin\Release\CitizenFX.Core.pdb
D:\Programmierstuff\C#\Mosleys\Mosleys.Client\bin\Release\CitizenFX.Core.xml
D:\Programmierstuff\C#\Mosleys\Mosleys.Client\bin\Release\MsgPack.xml
D:\Programmierstuff\C#\Mosleys\Mosleys.Client\obj\Release\Mosleys.Client.csproj.AssemblyReference.cache
D:\Programmierstuff\C#\Mosleys\Mosleys.Client\obj\Release\Mosleys.Client.csproj.CoreCompileInputs.cache
D:\Programmierstuff\C#\Mosleys\Mosleys.Client\bin\Release\Mosleys.Client.net.dll
D:\Programmierstuff\C#\Mosleys\Mosleys.Client\bin\Release\Mosleys.Client.net.pdb
D:\Programmierstuff\C#\Mosleys\Mosleys.Client\obj\Release\Mosleys.Client.net.dll
D:\Programmierstuff\C#\Mosleys\Output\Mosleys.Client.net.dll
D:\Programmierstuff\C#\Mosleys\Mosleys.Client\obj\Release\Mosleys.Client.csproj.CopyComplete
D:\Programmierstuff\C#\Mosleys\Output\fxmanifest.lua
D:\Programmierstuff\C#\Mosleys\Output\settings.ini

View File

@@ -0,0 +1,15 @@
namespace Nexd.ESX.Server
{
public static partial class ESX
{
public static partial class Config
{
public static class Weapons
{
public static dynamic Raw => Config.Raw.Weapons;
public static string[] DefaultWeaponTints => Raw.DefaultWeaponTints;
}
}
}
}

View File

@@ -0,0 +1,21 @@
namespace Nexd.ESX.Server
{
public static partial class ESX
{
public static partial class Config
{
public static dynamic Raw => ESX.Raw.Config ?? (ESX.Raw.Config);
public static string Locale => Raw.Locale;
public static string[] Accounts => new string[] { Raw.Accounts.bank, Raw.Accounts.money, Raw.Accounts.black_money };
public static dynamic StartingAccountMoney => Raw.StartingAccountMoney;
public static bool EnableSocietyPayouts => Raw.EnableSocietyPayouts;
public static bool EnableHud => Raw.EnableHud;
public static int MaxWeight => Raw.MaxWeight;
public static int PaycheckInterval => Raw.PaycheckInterval;
public static bool EnableDebug => Raw.EnableDebug;
}
}
}

View File

@@ -0,0 +1,56 @@
namespace Nexd.ESX.Server
{
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using CitizenFX.Core;
public static partial class ESX
{
public static dynamic Raw;
static ESX() => BaseScript.TriggerEvent("esx:getSharedObject", new object[] { new Action<dynamic>(esx => { Raw = esx; }) });
public static xPlayer GetPlayerFromId(int playerid) => new xPlayer(Raw.GetPlayerFromId(playerid));
public static xPlayer GetPlayerFromIdentifier(string identifier) => new xPlayer(Raw.GetPlayerFromIdentifier(identifier));
public static dynamic GetPlayerFromIdEx(int playerid) => Raw.GetPlayerFromId(playerid);
public static dynamic GetPlayerFromIdentifierEx(string identifier) => Raw.GetPlayerFromIdentifier(identifier);
public static bool DoesJobExist(string job, int grade) => Raw.DoesJobExist(job, grade);
public static void SavePlayer(xPlayer xPlayer, Action callback = null) => Raw.SavePlayer(xPlayer.Raw, callback);
public static void SavePlayers(Action callback = null) => Raw.SavePlayers(callback);
public static void CreatePickup(
string itemType,
string itemName,
int count,
string label,
int playerid,
[Optional, DefaultParameterValue(null)]List<string> components,
[Optional, DefaultParameterValue(0)]int tintIndex) =>
Raw.CreatePickup(itemType, itemName, count, label, playerid, components, tintIndex);
public static void UseItem(int playerid, string itemName) => Raw.UseItem(playerid, itemName);
public static string GetItemLabel(string item) => Raw.GetItemLabel(item);
public static void RegisterUsableItem(string item, Action<int> callback = null) => Raw.RegisterUsableItem(item, callback);
public static void RegisterServerCallback(string name, Action<int, CallbackDelegate, dynamic> callback) => Raw.RegisterServerCallback(name, callback);
public static void Trace(object args) => Raw.Trace(args);
public static string GetRandomString(int length) => Raw.GetRandomString(length);
public static dynamic GetConfig() => Raw.GetConfig();
public static dynamic GetWeaponFromHash(long hash) => Raw.GetWeaponFromHash(hash);
public static dynamic GetWeaponList() => Raw.GetWeaponList();
public static dynamic GetWeaponComponent(string weaponName, string weaponComponent) => Raw.GetWeaponComponent(weaponName, weaponComponent);
public static dynamic GetWeapon(string itemName) => Raw.GetWeapon(itemName);
public static dynamic GetWeaponLabel(string weapon) => Raw.GetWeaponLabel(weapon);
public static List<xPlayer> GetPlayers()
{
List<xPlayer> temp = new List<xPlayer>();
var rawdata = Raw.GetPlayers();
foreach (var i in rawdata)
{
temp.Add(ESX.GetPlayerFromId(i));
}
return temp;
}
}
}

View File

@@ -0,0 +1,160 @@
namespace Nexd.ESX.Server
{
using System.Collections.Generic;
using CitizenFX.Core;
using Nexd.ESX.Shared;
public class xPlayer
{
public dynamic Raw;
public int Index => Raw.source;
public xPlayer() { }
public xPlayer(dynamic data) => Raw = data;
public bool IsOnline => Raw != null;
public void TriggerEvent(string eventName, dynamic args = null) => Raw.triggerEvent(eventName, args);
public float GetHeading() => Raw.getCoords(true).heading;
public void Kick(string reason) => Raw.kick(reason);
public void SetMoney(int money) => Raw.setMoney(money);
public uint GetMoney() => Raw.getMoney();
public void AddMoney(int amount) => Raw.addMoney(amount);
public void RemoveMoney(int amount) => Raw.removeMoney(amount);
public string GetIdentifier() => Raw.getIdentifier();
public void SetGroup(string newgroup) => Raw.setGroup(newgroup);
public string GetGroup() => Raw.getGroup();
public void Set(dynamic key, dynamic value) => Raw.set(key, value);
public dynamic Get(dynamic key) => Raw.get(key);
public string GetName() => Raw.getName();
public void SetName(string newname) => Raw.setName(newname);
public void SetAccountMoney(string account, int money) => Raw.setAccountMoney(account, money);
public void AddAccountMoney(string account, int amount) => Raw.addAccountMoney(account, amount);
public void RemoveAccountMoney(string account, int amount) => Raw.removeAccountMoney(account, amount);
public InventoryItem GetInventoryItem(string name) => new InventoryItem(Raw.getInventoryItem(name));
public void AddInventoryItem(string name, int count) => Raw.addInventoryItem(name, count);
public void RemoveInventoryItem(string name, int count) => Raw.removeInventoryItem(name, count);
public void SetInventoryItem(string name, int count) => Raw.setInventoryItem(name, count);
public double GetWeight() => Raw.getWeight();
public double GetMaxWeight() => Raw.getMaxWeight();
public bool CanCarryItem(string name, int count) => Raw.canCarryItem(name, count);
public bool CanSwapItem(string firstitem, int firstitemcount, string testitem, int testitemcount) => Raw.canSwapItem(firstitem, firstitemcount, testitem, testitemcount);
public void SetMaxWeight(double newWeight) => Raw.setMaxWeight(newWeight);
public void SetJob(string job, int grade) => Raw.setJob(job, grade);
public void AddWeapon(string weaponName, int ammo) => Raw.addWeapon(weaponName, ammo);
public void AddWeaponComponent(string weaponName, string weaponComponent) => Raw.addWeaponComponent(weaponName, weaponComponent);
public void AddWeaponAmmo(string weaponName, int ammoCount) => Raw.addWeaponAmmo(weaponName, ammoCount);
public void UpdateWeaponAmmo(string weaponName, int ammoCount) => Raw.updateWeaponAmmo(weaponName, ammoCount);
public void SetWeaponTint(string weaponName, int weaponTintIndex) => Raw.setWeaponTint(weaponName, weaponTintIndex);
public int GetWeaponTint(string weaponName) => Raw.getWeaponTint(weaponName);
public void RemoveWeapon(string weaponName) => Raw.removeWeapon(weaponName);
public void RemoveWeaponComponent(string weaponName, string weaponComponent) => Raw.removeWeaponComponent(weaponName, weaponComponent);
public void RemoveWeaponAmmo(string weaponName, int ammoCount) => Raw.removeWeaponAmmo(weaponName, ammoCount);
public bool HasWeaponComponent(string weaponName, string weaponComponent) => Raw.hasWeaponComponent(weaponName, weaponComponent);
public bool HasWeapon(string weaponName) => Raw.hasWeapon(weaponName);
public Shared.Weapon GetWeapon(string weaponName) => GetLoadout().Find(x => x.name == weaponName);
public int GetWeaponLoadoutNum(string weaponName) => GetLoadout().FindIndex(x => x.name == weaponName);
public void ShowNotification(string message) => Raw.showNotification(message);
public void ShowHelpNotification(string message, bool thisframe = false, bool beep = true, int duration = -1) => Raw.showHelpNotification(message, thisframe, beep, duration);
public Job GetJob() => new Job(Raw.getJob());
public Account GetAccount(string name) => new Account(Raw.getAccount(name));
public Vector3 GetCoords(bool vector) => Raw.getCoords(vector);
public Vector3 GetCoords(bool vector, ref float heading)
{
dynamic data = Raw.getCoords(vector);
Vector3 coords = new Vector3(data.X, data.Y, data.Z);
heading = data.heading;
return coords;
}
public Account[] GetAccounts(bool minimal)
{
Account[] accounts = new Account[3];
var raw = Raw.getAccounts(minimal);
for (int i = 0; i < 3; i++)
accounts[i] = new Account(raw[i]);
return accounts;
}
public List<InventoryItem> GetInventory(bool minimal)
{
List<InventoryItem> inventory = new List<InventoryItem>();
var rawdata = Raw.getInventory(minimal);
foreach (var i in rawdata)
{
inventory.Add(new InventoryItem(i));
}
return inventory;
}
public List<Shared.Weapon> GetLoadout()
{
List<Shared.Weapon> temp = new List<Shared.Weapon>();
var loadout = Raw.getLoadout();
foreach (var i in loadout)
{
temp.Add(new Shared.Weapon(i));
}
return temp;
}
public void SetCoords(Vector3 coords)
{
dynamic table = new
{
x = coords.X,
y = coords.Y,
z = coords.Z,
heading = 0.0f
};
Raw.setCoords(table);
}
public void SetCoords(Vector3 coords, float heading)
{
dynamic table = new
{
x = coords.X,
y = coords.Y,
z = coords.Z,
heading = heading
};
Raw.setCoords(table);
}
public void UpdateCoords(Vector3 coords)
{
dynamic table = new
{
x = coords.X,
y = coords.Y,
z = coords.Z,
heading = 0.0f
};
Raw.updateCoords(table);
}
public void UpdateCoords(Vector3 coords, float heading)
{
dynamic table = new
{
x = coords.X,
y = coords.Y,
z = coords.Z,
heading = heading
};
Raw.updateCoords(table);
}
}
}

View File

@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8DFEB53F-2F99-427F-96BF-2290697FB9B2}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Mosleys.Server</RootNamespace>
<AssemblyName>Mosleys.Server.net</AssemblyName>
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>../Output</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<PostBuildEvent>del Newtonsoft.Json.xml</PostBuildEvent>
</PropertyGroup>
<ItemGroup>
<Reference Include="CitizenFX.Core.Server">
<HintPath>..\Librarys\CitizenFX.Core.Server.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.CSharp">
<HintPath>..\Librarys\Microsoft.CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ESX\Server\ESX.Config.cs" />
<Compile Include="ESX\Server\ESX.Config.Weapons.cs" />
<Compile Include="ESX\Server\ESX.cs" />
<Compile Include="ESX\Server\xPlayer.cs" />
<Compile Include="MySql.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ServerScript.cs" />
<Compile Include="Utils.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Mosleys.Shared\Mosleys.Shared.csproj">
<Project>{95000252-da88-4a79-8958-ca70b42ce0f9}</Project>
<Name>Mosleys.Shared</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="ESX" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Mosleys.Server {
public static class MySql {
public static dynamic MySqlObject;
public static Task Execute(string qry, IDictionary<string, object> parameters = null) {
var source = new TaskCompletionSource<dynamic>();
MySqlObject.query(qry, parameters, new Action<dynamic>(_ => {
source.TrySetResult(null);
}));
return source.Task;
}
public static Task<dynamic[]> FetchAll(string qry, IDictionary<string, object> parameters = null) {
var source = new TaskCompletionSource<dynamic[]>();
MySqlObject.query(qry, parameters, new Action<dynamic>(data => {
source.TrySetResult((data as List<dynamic>).ToArray());
}));
return source.Task;
}
public static async Task<dynamic> FetchOne(string qry, IDictionary<string, object> parameters = null) {
var result = await FetchAll(qry, parameters);
if (result.Length == 0) return null;
return result[0];
}
public static async void InitialSetup() {
await Execute("CREATE TABLE IF NOT EXISTS cardealer (uuid VARCHAR(36) PRIMARY KEY, owner VARCHAR(46), description VARCHAR(60), price INT(7), slot INT(2), vehicle LONGTEXT, testdrive TINYINT(1))");
await Execute("UPDATE cardealer SET testdrive = 0");
}
}
}

View File

@@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Mosleys.Server")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Mosleys.Server")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("8DFEB53F-2F99-427F-96BF-2290697FB9B2")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,183 @@
using System;
using System.Dynamic;
using System.Linq;
using System.Threading.Tasks;
using CitizenFX.Core;
using Mosleys.Shared;
using Mosleys.Shared.Models;
using Newtonsoft.Json;
using Nexd.ESX.Server;
using ESX = Nexd.ESX.Server.ESX;
namespace Mosleys.Server {
public sealed class ServerScript : BaseScript {
public static ServerConfig Config;
public ServerScript() {
Config = new ServerConfig();
MySql.MySqlObject = Exports["oxmysql"];
MySql.InitialSetup();
RegisterCallback<bool, string>("mosleys:server:checkVehicleOwnership", CheckVehicleOwnership);
RegisterCallback<bool, int>("mosleys:server:checkMoney", CheckMoney);
RegisterCallback<bool, SellData>("mosleys:server:sellVehicle", SellVehicle, true);
RegisterCallback("mosleys:server:getExhibits", GetExhibits);
RegisterCallback("mosleys:server:getPlayerExhibits", GetPlayerExhibits);
RegisterCallback<ExhibitVehicle, int>("mosleys:server:getExhibitBySlot", GetExhibitBySlot);
RegisterCallback<bool, BuyData>("mosleys:server:buyVehicle", BuyVehicle, true);
RegisterCallback<bool, ExhibitUpdate>("mosleys:server:updateExhibit", UpdateVehicle, true);
RegisterCallback<int, string>("mosleys:server:push", PushToExhibit);
EventHandlers["mosleys:server:testDrive"] += new Action<int, bool>(UpdateTestDrive);
}
private static void RegisterCallback<TRes>(string name, Func<xPlayer, Task<TRes>> handler) {
ESX.RegisterServerCallback(name, async (source, cb, args) => {
try {
var result = await handler.Invoke(ESX.GetPlayerFromId(source));
cb(result);
}
catch (Exception e) {
Debug.WriteLine(e.ToString());
cb(null);
}
});
}
private static void RegisterCallback<TRes, TArg>(string name, Func<xPlayer, TArg, Task<TRes>> handler, bool castViaJson = false) {
ESX.RegisterServerCallback(name, async (source, cb, args) => {
try {
TArg arg;
if (castViaJson) {
arg = JsonConvert.DeserializeObject<TArg>(JsonConvert.SerializeObject(args));
}
else {
arg = Convert.ChangeType(args, typeof(TArg));
}
var result = await handler.Invoke(ESX.GetPlayerFromId(source), arg);
cb(result);
}
catch (Exception e) {
Debug.WriteLine(e.ToString());
cb(null);
}
});
}
private async Task<bool> CheckVehicleOwnership(xPlayer source, string plate) {
var result = await MySql.FetchAll($"SELECT * FROM owned_vehicles WHERE owner = '{source.GetIdentifier()}'");
return result.Any(vehicle => vehicle.plate == plate);
}
private async Task<bool> CheckMoney(xPlayer source, int price) {
return source.GetAccount("bank").money >= price;
}
private async Task<bool> SellVehicle(xPlayer source, SellData data) {
var exhibit = new ExhibitVehicle {
Uuid = Guid.NewGuid().ToString(),
Owner = source.GetIdentifier(),
Description = data.Description,
Price = data.Price,
Vehicle = data.VehicleProperties,
TestDrive = false
};
int slot = data.ParkingSpace == 0 ? await Utils.FindFreeSlot() : 0;
if (slot >= Config.CarSlots.Length) slot = 0;
exhibit.Slot = slot;
await Utils.SaveExhibit(exhibit);
if (data.ParkingSpace == 0) {
source.RemoveAccountMoney("bank", Config.ExhibitPrice);
Utils.UpdatePlayers(slot);
}
return slot != 0;
}
private async Task<dynamic> GetExhibits(xPlayer soruce) {
var vehicles = await Utils.GetAllExhibits();
dynamic data = new ExpandoObject();
data.vehicles = vehicles;
return data;
}
private async Task<dynamic> GetPlayerExhibits(xPlayer source) {
var vehicles = await Utils.GetAllExhibits();
vehicles = vehicles.Where(vehicle => vehicle.Owner == source.GetIdentifier()).ToArray();
dynamic data = new ExpandoObject();
data.vehicles = vehicles;
return data;
}
private async Task<ExhibitVehicle> GetExhibitBySlot(xPlayer source, int slot) =>
await Utils.GetExhibitBySlot(slot);
private async void UpdateTestDrive(int slot, bool toggle) {
var exhibit = await Utils.GetExhibitBySlot(slot);
if (exhibit == null) return;
exhibit.TestDrive = toggle;
await Utils.SaveExhibit(exhibit);
Utils.UpdatePlayers(slot);
}
private async Task<bool> BuyVehicle(xPlayer source, BuyData data) {
var exhibit = await Utils.GetExhibitByUuid(data.Uuid);
if (exhibit == null) return false;
var hasMoney = await CheckMoney(source, exhibit.Price);
if (!hasMoney) return false;
dynamic vehicle = exhibit.Vehicle;
vehicle.plate = data.Plate;
source.RemoveAccountMoney("bank", exhibit.Price);
Utils.PaySeller(exhibit.Owner, exhibit.Price);
TriggerEvent("esx_vehicleshop:setVehicleOwnedPlayerId", source.Index, vehicle);
await MySql.Execute($"DELETE FROM cardealer WHERE uuid = '{data.Uuid}'");
if (exhibit.Slot != 0) TriggerClientEvent("mosleys:client:onRemove", exhibit.Slot);
return true;
}
private async Task<bool> UpdateVehicle(xPlayer source, ExhibitUpdate update) {
if (update.Exhibit.Owner != source.GetIdentifier()) return false;
if (update.Action == UpdateAction.Update) {
await Utils.SaveExhibit(update.Exhibit);
if (update.Exhibit.Slot != 0 ) Utils.UpdatePlayers(update.Exhibit.Slot);
}
if (update.Action == UpdateAction.Delete) {
await MySql.Execute($"DELETE FROM cardealer WHERE uuid = '{update.Exhibit.Uuid}'");
TriggerEvent("esx_vehicleshop:setVehicleOwnedPlayerId", source.Index, update.Exhibit.Vehicle);
if (update.Exhibit.Slot != 0) TriggerClientEvent("mosleys:client:onRemove", update.Exhibit.Slot);
}
return true;
}
private async Task<int> PushToExhibit(xPlayer source, string uuid) {
var exhibit = await Utils.GetExhibitByUuid(uuid);
var slot = await Utils.FindFreeSlot();
if (slot >= Config.CarSlots.Length) return 0;
var hasMoney = await CheckMoney(source, Config.ExhibitPrice);
if (!hasMoney) return 0;
source.RemoveAccountMoney("bank", Config.ExhibitPrice);
exhibit.Slot = slot;
await Utils.SaveExhibit(exhibit);
Utils.UpdatePlayers(slot);
return slot;
}
}
}

View File

@@ -0,0 +1,101 @@
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Threading.Tasks;
using CitizenFX.Core;
using Mosleys.Shared.Models;
using Newtonsoft.Json;
using Nexd.ESX.Server;
namespace Mosleys.Server {
public static class Utils {
public static async Task<ExhibitVehicle[]> GetAllExhibits() {
var vehicles = new List<ExhibitVehicle>();
var data = await MySql.FetchAll("SELECT * FROM cardealer");
try {
foreach (var exhibit in data) {
exhibit.vehicle = JsonConvert.DeserializeObject<ExpandoObject>(exhibit.vehicle as string);
var json = JsonConvert.SerializeObject(exhibit);
vehicles.Add(JsonConvert.DeserializeObject<ExhibitVehicle>(json));
}
}
catch (Exception e) {
Debug.WriteLine(e.ToString());
}
return vehicles.ToArray();
}
public static async Task<ExhibitVehicle> GetExhibitBySlot(int slot) {
var data = await MySql.FetchOne($"SELECT * FROM cardealer WHERE slot = {slot}");
data.vehicle = JsonConvert.DeserializeObject<ExpandoObject>(data.vehicle as string);
var json = JsonConvert.SerializeObject(data);
return JsonConvert.DeserializeObject<ExhibitVehicle>(json);
}
public static async Task<ExhibitVehicle> GetExhibitByUuid(string uuid) {
var data = await MySql.FetchOne($"SELECT * FROM cardealer WHERE uuid = '{uuid}'");
data.vehicle = JsonConvert.DeserializeObject<ExpandoObject>(data.vehicle as string);
var json = JsonConvert.SerializeObject(data);
return JsonConvert.DeserializeObject<ExhibitVehicle>(json);
}
public static async Task<int> FindFreeSlot() {
var vehicles = await GetAllExhibits();
int slot = 1;
while (vehicles.Any(veh => veh.Slot == slot)) {
slot++;
}
return slot;
}
public static async Task SaveExhibit(ExhibitVehicle exhibit) {
if (string.IsNullOrEmpty(exhibit.Description))
exhibit.Description = "Nicht angegeben";
await MySql.Execute($"DELETE FROM cardealer WHERE uuid = '{exhibit.Uuid}'");
await MySql.Execute("INSERT INTO cardealer VALUES (@uuid, @owner, @description, @price, @slot, @vehicle, @testdrive)", new Dictionary<string, object>() {
{"@uuid", exhibit.Uuid},
{"@owner", exhibit.Owner},
{"@description", exhibit.Description},
{"@price", exhibit.Price},
{"@slot", exhibit.Slot},
{"@vehicle", JsonConvert.SerializeObject(exhibit.Vehicle)},
{"@testdrive", Convert.ToInt32(exhibit.TestDrive)}
});
}
public static void UpdatePlayers(int slot) {
BaseScript.TriggerClientEvent("mosleys:client:updateSlot", slot);
}
public static async void PaySeller(string identifier, int amount) {
try {
var seller = ESX.GetPlayerFromIdentifier(identifier);
if (seller.IsOnline) seller.AddAccountMoney("bank", (int)(amount * (1 - ServerScript.Config.SellBill)));
else {
var data = await MySql.FetchOne($"SELECT accounts FROM users WHERE identifier = '{identifier}'");
var accounts = JsonConvert.DeserializeObject<ExpandoObject>(data.accounts);
accounts.bank += amount;
await MySql.Execute($"UPDATE users SET accounts = @accounts WHERE identifier = @identifier", new Dictionary<string, object>() {
{"@accounts", JsonConvert.SerializeObject(accounts)},
{"@identifier", identifier}
});
}
BaseScript.TriggerEvent("esx_addonaccount:getSharedAccount", $"society_{ServerScript.Config.TargetSociety}", new Action<dynamic>(society => {
society.addMoney((int)(amount * ServerScript.Config.SellBill));
}));
}
catch (Exception e) {
Debug.WriteLine(e.ToString());
}
}
}
}

View File

@@ -0,0 +1,23 @@
fx_version 'cerulean'
games { 'gta5' }
-- details
author 'Leon Hoppe'
description "Mosley's"
version '2.0'
shared_scripts {
'Nexd.ESX.Shared.dll',
'Mosleys.Shared.dll',
'settings.ini'
}
client_scripts {
'Newtonsoft.Json.dll',
'Nexd.ESX.Client.dll',
'Mosleys.Client.net.dll'
}
server_scripts {
'@mysql-async/lib/MySQL.lua',
}

View File

@@ -0,0 +1,39 @@
{[Blip]
Position [-41.5, -1676.1, 30]
Sprite 380
Color 44
Scale 1.0
}
{[General]
MenuTitle Mosley's
ExhibitPrice 500
TestDriveTime 90000
SpawnRadius 100.0
MinSellPrice 1000
ForbiddenVehicleClasses [10, 13, 14, 15, 16, 18, 19, 20, 21]
SpawnLocation [3.556, -1652.677, 28.853, 229.645]
TestDriveLocation [-48.724, -1645.301, 29.034, 318.446]
DigitalShowPoint [-31.4151, -1663.9031, 29.5]
DigitalCamera [-24.2456, -1643.7988, 33.1410, 186.6901]
}
{[CarSlots]
0 [-24.969, -1651.355, 28.35, 258.833]
1 [-51.790, -1694.293, 28.35, 301.206]
2 [-56.162, -1690.660, 28.35, 298.664]
3 [-59.606, -1685.879, 28.35, 309.221]
4 [-53.514, -1678.981, 28.35, 301.604]
5 [-43.349, -1666.895, 28.35, 296.207]
6 [-35.946, -1657.419, 28.35, 144.485]
7 [-16.085, -1653.906, 28.35, 308.377]
8 [-27.076, -1657.913, 28.35, 286.712]
9 [-23.641, -1643.140, 28.35, 121.021]
10 [-18.106, -1645.940, 28.35, 132.801]
11 [-43.647, -1690.989, 28.35, 311.298]
12 [-47.901, -1688.066, 28.35, 306.442]
13 [-51.714, -1683.800, 28.35, 306.119]
}

View File

@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]

View File

@@ -0,0 +1 @@
534f4db9ea8ef7acfc1233e7413c6b4d36a209be

View File

@@ -0,0 +1,20 @@
D:\Programmierstuff\C#\Mosleys\Mosleys.Server\bin\Release\fxmanifest.lua
D:\Programmierstuff\C#\Mosleys\Mosleys.Server\bin\Release\settings.ini
D:\Programmierstuff\C#\Mosleys\Mosleys.Server\bin\Release\Mosleys.Server.dll
D:\Programmierstuff\C#\Mosleys\Mosleys.Server\bin\Release\Mosleys.Server.pdb
D:\Programmierstuff\C#\Mosleys\Mosleys.Server\bin\Release\Mosleys.Shared.dll
D:\Programmierstuff\C#\Mosleys\Mosleys.Server\bin\Release\Nexd.ESX.Server.dll
D:\Programmierstuff\C#\Mosleys\Mosleys.Server\bin\Release\Nexd.ESX.Shared.dll
D:\Programmierstuff\C#\Mosleys\Mosleys.Server\obj\Release\Mosleys.Server.csproj.AssemblyReference.cache
D:\Programmierstuff\C#\Mosleys\Mosleys.Server\obj\Release\Mosleys.Server.csproj.CoreCompileInputs.cache
D:\Programmierstuff\C#\Mosleys\Mosleys.Server\obj\Release\Mosleys.Server.csproj.CopyComplete
D:\Programmierstuff\C#\Mosleys\Mosleys.Server\Output\fxmanifest.lua
D:\Programmierstuff\C#\Mosleys\Mosleys.Server\Output\settings.ini
D:\Programmierstuff\C#\Mosleys\Mosleys.Server\Output\Mosleys.Server.dll
D:\Programmierstuff\C#\Mosleys\Mosleys.Server\Output\Mosleys.Shared.dll
D:\Programmierstuff\C#\Mosleys\Mosleys.Server\Output\Nexd.ESX.Server.dll
D:\Programmierstuff\C#\Mosleys\Mosleys.Server\Output\Nexd.ESX.Shared.dll
D:\Programmierstuff\C#\Mosleys\Output\fxmanifest.lua
D:\Programmierstuff\C#\Mosleys\Output\settings.ini
D:\Programmierstuff\C#\Mosleys\Output\Mosleys.Server.net.dll
D:\Programmierstuff\C#\Mosleys\Mosleys.Server\obj\Release\Mosleys.Server.net.dll

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net481" />
</packages>

View File

@@ -0,0 +1,205 @@
using CitizenFX.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using CitizenFX.Core.Native;
namespace Mosleys.Shared {
public sealed class Config {
private sealed class SectionScript {
private const char SplitChar = ' ';
private const string SectionStart = "{";
private const string SectionEnd = "}";
private const string CommentPrefix = "//";
private readonly string _fileName;
private readonly List<Tuple<string, Dictionary<string, string>>> _loadedData =
new List<Tuple<string, Dictionary<string, string>>>();
private readonly List<string> _allSections = new List<string>();
public SectionScript(string fileName, bool load = false) {
_fileName = fileName;
if (!load)
return;
Read();
}
public string this[string section, string key, string result = ""] =>
GetValue(section, key, result);
public T GetValue<T>(string section, string key, T result) {
if (!SectionExists(section))
return result;
string data = GetData(section, key, result.ToString());
try {
return (T)Convert.ChangeType(data, typeof(T));
}
catch (InvalidCastException) {
return result;
}
}
public Vector3 GetVector3(string section, string key, Vector3 result) {
if (!SectionExists(section))
return result;
string data = GetData(section, key, result.ToString());
data = data.Replace("[", "").Replace("]", "").Replace(" ", "");
return new Vector3(data.Split(',').Select(Convert.ToSingle).ToArray());
}
public Vector4 GetVector4(string section, string key, Vector4 result) {
if (!SectionExists(section))
return result;
string data = GetData(section, key, result.ToString());
data = data.Replace("[", "").Replace("]", "").Replace(" ", "");
return new Vector4(data.Split(',').Select(Convert.ToSingle).ToArray());
}
public int[] GetIntArray(string section, string key, int[] result) {
if (!SectionExists(section))
return result;
string data = GetData(section, key, result.ToString());
data = data.Replace("[", "").Replace("]", "").Replace(" ", "");
return data.Split(',').Select(n => Convert.ToInt32(n)).ToArray();
}
public Vector4[] GetVector4Array(string section) {
List<Vector4> vectors = new List<Vector4>();
foreach (Tuple<string, Dictionary<string, string>> tuple in _loadedData) {
if (!tuple.Item1.Equals(section)) continue;
foreach (var key in tuple.Item2.Values) {
var data = key.Replace("[", "").Replace("]", "").Replace(" ", "");
var vector = new Vector4(data.Split(',').Select(Convert.ToSingle).ToArray());
vectors.Add(vector);
}
}
return vectors.ToArray();
}
public string GetData(string section, string key, string result) {
foreach (Tuple<string, Dictionary<string, string>> tuple in _loadedData) {
if (tuple.Item1.Equals(section))
return tuple.Item2.ContainsKey(key) ? tuple.Item2[key] : result;
}
return result;
}
public bool SectionExists(string section) => _allSections.Contains(section);
public void Read() {
_loadedData.Clear();
_allSections.Clear();
string str1 = "";
Dictionary<string, string> source = new Dictionary<string, string>();
string str2 = API.LoadResourceFile(API.GetCurrentResourceName(), _fileName);
char[] chArray = { '\n' };
foreach (string str3 in str2.Split(chArray).Select(str => str.Trim())) {
string text = str3.Replace("\r", "");
if (!string.IsNullOrEmpty(text) && !string.IsNullOrWhiteSpace(text)) {
if (text.StartsWith(SectionStart)) {
str1 = text.Substring(1);
if (text.EndsWith(SectionEnd) && !str1.Contains(SectionStart)) {
str1 = str1.Remove(str1.Length - 1, 1);
_loadedData.Add(
new Tuple<string, Dictionary<string, string>>(str1,
new Dictionary<string, string>()));
if (!_allSections.Contains(str1))
_allSections.Add(str1);
source.Clear();
}
}
else if (text.EndsWith(SectionEnd) || text.StartsWith(SectionEnd)) {
Dictionary<string, string> dictionary =
source.ToDictionary(
entry => entry.Key,
entry => entry.Value);
_loadedData.Add(new Tuple<string, Dictionary<string, string>>(str1, dictionary));
if (!_allSections.Contains(str1))
_allSections.Add(str1);
source.Clear();
}
else if (!text.StartsWith(CommentPrefix)) {
Tuple<string, string> data = ConvertToData(text);
if (!source.ContainsKey(data.Item1))
source.Add(data.Item1, data.Item2);
}
}
}
}
private Tuple<string, string> ConvertToData(string text) {
int length = text.IndexOf(SplitChar);
if (length == -1)
return new Tuple<string, string>(text, "");
string str = "";
if (length - 1 < text.Length)
str = text.Substring(length + 1, text.Length - length - 1);
return new Tuple<string, string>(text.Substring(0, length), str);
}
}
public static Config LoadConfig() {
var script = new SectionScript("settings.ini", true);
var config = new Config {
Blip = new BlipConfig {
Position = script.GetVector3("[Blip]", "Position", Vector3.Zero),
Sprite = (BlipSprite)script.GetValue("[Blip]", "Sprite", 380),
Color = (BlipColor)script.GetValue("[Blip]", "Color", 44),
Scale = script.GetValue("[Blip]", "Scale", 1.0f)
},
MenuTitle = script.GetValue("[General]", "MenuTitle", "Mosley's"),
ExhibitPrice = script.GetValue("[General]", "ExhibitPrice", 500),
TestDriveTime = script.GetValue("[General]", "TestDriveTime", 90000),
SpawnRadius = script.GetValue("[General]", "SpawnRadius", 100f),
MinSellPrice = script.GetValue("[General]", "MinSellPrice", 1000),
SellBill = script.GetValue("[General]", "SellBill", 0.1f),
ForbiddenVehicleClasses =
script.GetIntArray("[General]", "ForbiddenVehicleClasses", Array.Empty<int>()),
SellLocation = script.GetVector3("[General]", "SellLocation", Vector3.Zero),
SpawnLocation = script.GetVector4("[General]", "SpawnLocation", Vector4.Zero),
TestDriveLocation = script.GetVector4("[General]", "TestDriveLocation", Vector4.Zero),
DigitalShowPoint = script.GetVector3("[General]", "DigitalShowPoint", Vector3.Zero),
DigitalCamera = script.GetVector4("[General]", "DigitalCamera", Vector4.Zero),
CarSlots = script.GetVector4Array("[CarSlots]")
};
return config;
}
public BlipConfig Blip;
public string MenuTitle;
public int ExhibitPrice;
public int TestDriveTime;
public float SpawnRadius;
public int MinSellPrice;
public float SellBill;
public int[] ForbiddenVehicleClasses;
public Vector3 SellLocation;
public Vector4 SpawnLocation;
public Vector4 TestDriveLocation;
public Vector3 DigitalShowPoint;
public Vector4 DigitalCamera;
public Vector4[] CarSlots;
}
public struct BlipConfig {
public Vector3 Position;
public BlipSprite Sprite;
public BlipColor Color;
public float Scale;
}
}

View File

@@ -0,0 +1,17 @@
namespace Nexd.ESX.Client
{
using CitizenFX.Core;
public static partial class ESX
{
public static partial class Game
{
public static class Utils
{
public static dynamic Raw => ESX.Raw.Game.Utils;
public static void DrawText3D(Vector3 coords, string text, double size, dynamic font) => Raw.DrawText3D(coords, text, size, font);
}
}
}
}

View File

@@ -0,0 +1,89 @@
namespace Nexd.ESX.Client
{
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using CitizenFX.Core;
public static partial class ESX
{
public static partial class Game
{
public static dynamic Raw => ESX.Raw.Game;
public static void DeleteObject(string obj) => Raw.DeleteObject(obj);
public static void DeleteVehicle(string vehicle) => Raw.DeleteVehicle(vehicle);
public static dynamic GetClosestObject([Optional()] Vector3 coords, [Optional()] dynamic modelFilter) => Raw.GetClosestObject(coords, modelFilter);
public static Ped GetClosestPed([Optional()] Vector3 coords, [Optional()] dynamic modelFilter) => new Ped(Raw.GetClosestPed(coords, modelFilter));
public static Player GetClosestPlayer([Optional()] Vector3 coords) => new Player(Raw.GetClosestPlayer(coords));
public static Vehicle GetClosestVehicle([Optional()] Vector3 coords, [Optional()] dynamic modelFilter) => new Vehicle(Raw.GetClosestVehicle(coords, modelFilter));
public static dynamic GetObjects() => Raw.GetObjects();
public static dynamic GetPedMugshot(string ped, bool transparent = true) => Raw.GetPedMugshot(ped, transparent);
public static Vehicle GetVehicleInDirection() => new Vehicle(Raw.GetVehicleInDirection());
public static VehicleProperties GetVehicleProperties(Vehicle vehicle) => new VehicleProperties(Raw.GetVehicleProperties(vehicle.Handle));
public static VehicleProperties GetVehicleProperties(int vehicle) => new VehicleProperties(Raw.GetVehicleProperties(vehicle));
public static bool IsSpawnPointClear([Optional()] Vector3 coords, double maxDistance) => Raw.IsSpawnPointClear(coords, maxDistance);
public static void SetVehicleProperties(Vehicle vehicle, VehicleProperties properties) => Raw.SetVehicleProperties(vehicle.Handle, properties.GetRaw());
public static void SpawnLocalObject(string hash, Vector3 coords, [Optional()] Action<int> callback) => Raw.SpawnLocalObject(hash, coords, callback);
public static void SpawnLocalObject(int hash, Vector3 coords, [Optional()] Action<int> callback) => Raw.SpawnLocalObject(hash, coords, callback);
public static void SpawnObject(string hash, Vector3 coords, [Optional()] Action<int> callback) => Raw.SpawnObject(hash, coords, callback);
public static void SpawnObject(int hash, Vector3 coords, [Optional()] Action<int> callback) => Raw.SpawnObject(hash, coords, callback);
public static void SpawnLocalVehicle(string hash, Vector3 coords, double heading, [Optional()] Action<int> callback) => Raw.SpawnLocalVehicle(hash, coords, heading, callback);
public static void SpawnLocalVehicle(int hash, Vector3 coords, double heading, [Optional()] Action<int> callback) => Raw.SpawnLocalVehicle(hash, coords, heading, callback);
public static void SpawnVehicle(string hash, Vector3 coords, double heading, [Optional()] Action<int> callback) => Raw.SpawnVehicle(hash, coords, heading, callback);
public static void SpawnVehicle(int hash, Vector3 coords, double heading, [Optional()] Action<int> callback) => Raw.SpawnVehicle(hash, coords, heading, callback);
public static void Teleport(string entity, Vector3 coords, [Optional()] Action callback) => Raw.Teleport(entity, coords, callback);
public static List<Ped> GetPeds([Optional()] bool onlyOtherPeds)
{
var data = Raw.GetPeds(onlyOtherPeds);
List<Ped> peds = new List<Ped>();
foreach (var i in data)
peds.Add(new Ped(i));
return peds;
}
public static List<Player> GetPlayers(bool onlyOtherPlayers = false, bool returnKeyValue = false, bool returnPeds = false)
{
var data = Raw.GetPlayers(onlyOtherPlayers, returnKeyValue, returnPeds);
List<Player> players = new List<Player>();
foreach (var i in data)
players.Add(new Player(i));
return players;
}
public static List<Player> GetPlayersInArea([Optional()] Vector3 coords, double maxDistance)
{
var data = Raw.GetPlayersInArea(coords, maxDistance);
List<Player> players = new List<Player>();
foreach (var i in data)
players.Add(new Player(i));
return players;
}
public static List<Vehicle> GetVehicles()
{
var data = Raw.GetVehicles();
List<Vehicle> vehicles = new List<Vehicle>();
foreach (var i in data)
vehicles.Add(new Vehicle(i));
return vehicles;
}
public static List<Vehicle> GetVehiclesInArea([Optional()] Vector3 coords, double maxDistance)
{
var data = Raw.GetVehiclesInArea(coords, maxDistance);
List<Vehicle> vehicles = new List<Vehicle>();
foreach (var i in data)
vehicles.Add(new Vehicle(i));
return vehicles;
}
}
}
}

View File

@@ -0,0 +1,15 @@
namespace Nexd.ESX.Client
{
public static partial class ESX
{
public static partial class Scaleform
{
public class Utils
{
public static dynamic Raw => ESX.Raw.Scaleform.Utils;
public static int RequestScaleformMovie(string movie) => Raw.RequestScaleformMovie(movie);
}
}
}
}

View File

@@ -0,0 +1,15 @@
namespace Nexd.ESX.Client
{
public static partial class ESX
{
public static partial class Scaleform
{
public static dynamic Raw => ESX.Raw.Scaleform;
public static void ShowBreakingNews(string title, string message, string bottom, int sec) => Raw.ShowBreakingNews(title, message, bottom, sec);
public static void ShowFreemodeMessage(string title, string message, int sec) => Raw.ShowFreemodeMessage(title, message, sec);
public static void ShowPopupWarning(string title, string message, string footer, int sec) => Raw.ShowPopupWarning(title, message, footer, sec);
public static void ShowTrafficMovie(int sec) => Raw.ShowTrafficMovie(sec);
}
}
}

View File

@@ -0,0 +1,20 @@
namespace Nexd.ESX.Client
{
using System;
using System.Runtime.InteropServices;
public static partial class ESX
{
public static class Streaming
{
public static dynamic Raw => ESX.Raw.Streaming;
public static int RequestAnimDict(string animDict, [Optional()] Action callback) => Raw.RequestAnimDict(animDict, callback);
public static int RequestAnimSet(string animSet, [Optional()] Action callback) => Raw.RequestAnimSet(animSet, callback);
public static int RequestModel(string model, [Optional()] Action callback) => Raw.RequestModel(model, callback);
public static int RequestNamedPtfxAsset(string assetName, [Optional()] Action callback) => Raw.RequestNamedPtfxAsset(assetName, callback);
public static int RequestStreamedTextureDict(string textureDict, [Optional()] Action callback) => Raw.RequestStreamedTextureDict(textureDict, callback);
public static int RequestWeaponAsset(string hash, [Optional()] Action callback) => Raw.RequestWeaponAsset(hash, callback);
}
}
}

View File

@@ -0,0 +1,18 @@
namespace Nexd.ESX.Client
{
public static partial class ESX
{
public static partial class UI
{
public class HUD
{
public static dynamic Raw => ESX.Raw.UI.HUD;
public static void RegisterElement(string name, int index, int priority, string html, dynamic data) => Raw.RegisterElement(name, index, priority, html, data);
public static void RemoveElement(string name) => Raw.RemoveElement(name);
public static void SetDisplay(double opacity) => Raw.SetDisplay(opacity);
public static void UpdateElement(string name, dynamic data) => Raw.UpdateElement(name, data);
}
}
}
}

View File

@@ -0,0 +1,90 @@
namespace Nexd.ESX.Client
{
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
public static partial class ESX
{
public static partial class UI
{
public class Menu
{
public static dynamic Raw => ESX.Raw.UI.Menu;
public dynamic RawInstance;
public Menu(dynamic data) => RawInstance = data;
public Menu() => RawInstance = new System.Dynamic.ExpandoObject();
public Menu(string menuType, string nameSpace, string menuName)
{
RawInstance = new System.Dynamic.ExpandoObject();
RawInstance.name = menuName;
RawInstance.type = menuType;
RawInstance.@namespace = nameSpace;
RawInstance.data = new MenuData();
}
public string type
{
get => RawInstance.type;
set => RawInstance.type = value;
}
public string @namespace
{
get => RawInstance.@namespace;
set => RawInstance.@namespace = value;
}
public string name
{
get => RawInstance.name;
set => RawInstance.name = value;
}
public MenuData data
{
get => new MenuData(RawInstance.data);
set => RawInstance.data = value;
}
public void Close() => Close(this);
public static void Close(string type, string @namespace, string name) => Raw.Close(type, @namespace, name);
public static void Close(Menu menu) => Raw.Close(menu.type, menu.@namespace, menu.name);
public static void CloseAll() => Raw.CloseAll();
public static Menu GetOpened(string type, string @namespace, string name) => new Menu(Raw.GetOpened(type, @namespace, name));
public static bool IsOpen(string type, string @namespace, string name) => Raw.RawIsOpen(type, @namespace, name);
public static Menu Open(
string type,
string @namespace,
string name,
MenuData data,
[Optional()] Action<dynamic, dynamic> submit,
[Optional()] Action<dynamic, dynamic> cancel,
[Optional()] Action<dynamic, dynamic> change, [Optional()] Action close) =>
new Menu(Raw.Open(type, @namespace, name, data.Raw, submit, cancel, change, close));
public static void RegisterType(string type, [Optional()] Action<string, string, dynamic> open, [Optional()] Action<string, Menu> close) => Raw.RegisterType(type, open, close);
public static List<Menu> GetOpenedMenus()
{
var data = Raw.GetOpenedMenus();
List<Menu> menus = new List<Menu>();
foreach (var i in data)
menus.Add(new Menu(i));
return menus;
}
}
}
}
}

View File

@@ -0,0 +1,10 @@
namespace Nexd.ESX.Client
{
public static partial class ESX
{
public static partial class UI
{
public static dynamic Raw => ESX.Raw.UI;
}
}
}

View File

@@ -0,0 +1,63 @@
namespace Nexd.ESX.Client
{
using System;
using CitizenFX.Core;
public static partial class ESX
{
private static dynamic Raw;
static ESX() => BaseScript.TriggerEvent("esx:getSharedObject", new object[] { new Action<dynamic>(esx => { Raw = esx; }) });
public static void TriggerServerCallback(string name, Action<dynamic> callback, dynamic args = null) => Raw.TriggerServerCallback(name, callback, args);
public static PlayerData GetPlayerData() => new PlayerData(Raw.GetPlayerData());
public static bool IsPlayerLoaded() => Raw.IsPlayerLoaded();
public static void SetPlayerData(dynamic key, dynamic value) => Raw.SetPlayerData(key, value);
public static void ShowInventory() => Raw.ShowInventory();
public static void ShowHelpNotification(string message, bool thisFrame = false, bool beep = true, int duration = -1) => Raw.ShowHelpNotification(message, thisFrame, beep, duration);
public static void ShowAdvancedNotification(
string sender,
string subject,
string message,
NotificationPicture notificationPicture = NotificationPicture.CHAR_MULTIPLAYER,
IconType iconType = IconType.ChatBox,
bool flash = false,
bool savetoBreif = true,
HudColor hudColor = HudColor.HUD_COLOUR_DEFAULT)
{
if (hudColor != HudColor.HUD_COLOUR_DEFAULT)
{
Raw.ShowAdvancedNotification(sender, subject, message, notificationPicture.ToString(), (int)iconType, flash, savetoBreif, (int)hudColor);
return;
}
Raw.ShowAdvancedNotification(sender, subject, message, notificationPicture.ToString(), (int)iconType, flash, savetoBreif, null);
}
public static void ShowAdvancedNotification(
string sender,
string subject,
string message,
string textureDict,
IconType iconType,
bool flash = false,
bool savetoBreif = true,
HudColor hudColor = HudColor.HUD_COLOUR_DEFAULT)
{
if (hudColor != HudColor.HUD_COLOUR_DEFAULT)
{
Raw.ShowAdvancedNotification(sender, subject, message, textureDict, (int)iconType, flash, savetoBreif, (int)hudColor);
return;
}
Raw.ShowAdvancedNotification(sender, subject, message, textureDict, (int)iconType, flash, savetoBreif, null);
}
public static void ShowNotification(string message, HudColor hudColor = HudColor.HUD_COLOUR_DEFAULT)
{
if(hudColor != HudColor.HUD_COLOUR_DEFAULT) CitizenFX.Core.Native.API.ThefeedNextPostBackgroundColor((int)hudColor);
Raw.ShowNotification(message);
}
}
}

View File

@@ -0,0 +1,231 @@
namespace Nexd.ESX.Client
{
public enum HudColor : int
{
HUD_COLOUR_PURE_WHITE,
HUD_COLOUR_WHITE,
HUD_COLOUR_BLACK,
HUD_COLOUR_GREY,
HUD_COLOUR_GREYLIGHT,
HUD_COLOUR_GREYDARK,
HUD_COLOUR_RED,
HUD_COLOUR_REDLIGHT,
HUD_COLOUR_REDDARK,
HUD_COLOUR_BLUE,
HUD_COLOUR_BLUELIGHT,
HUD_COLOUR_BLUEDARK,
HUD_COLOUR_YELLOW,
HUD_COLOUR_YELLOWLIGHT,
HUD_COLOUR_YELLOWDARK,
HUD_COLOUR_ORANGE,
HUD_COLOUR_ORANGELIGHT,
HUD_COLOUR_ORANGEDARK,
HUD_COLOUR_GREEN,
HUD_COLOUR_GREENLIGHT,
HUD_COLOUR_GREENDARK,
HUD_COLOUR_PURPLE,
HUD_COLOUR_PURPLELIGHT,
HUD_COLOUR_PURPLEDARK,
HUD_COLOUR_PINK,
HUD_COLOUR_RADAR_HEALTH,
HUD_COLOUR_RADAR_ARMOUR,
HUD_COLOUR_RADAR_DAMAGE,
HUD_COLOUR_NET_PLAYER1,
HUD_COLOUR_NET_PLAYER2,
HUD_COLOUR_NET_PLAYER3,
HUD_COLOUR_NET_PLAYER4,
HUD_COLOUR_NET_PLAYER5,
HUD_COLOUR_NET_PLAYER6,
HUD_COLOUR_NET_PLAYER7,
HUD_COLOUR_NET_PLAYER8,
HUD_COLOUR_NET_PLAYER9,
HUD_COLOUR_NET_PLAYER10,
HUD_COLOUR_NET_PLAYER11,
HUD_COLOUR_NET_PLAYER12,
HUD_COLOUR_NET_PLAYER13,
HUD_COLOUR_NET_PLAYER14,
HUD_COLOUR_NET_PLAYER15,
HUD_COLOUR_NET_PLAYER16,
HUD_COLOUR_NET_PLAYER17,
HUD_COLOUR_NET_PLAYER18,
HUD_COLOUR_NET_PLAYER19,
HUD_COLOUR_NET_PLAYER20,
HUD_COLOUR_NET_PLAYER21,
HUD_COLOUR_NET_PLAYER22,
HUD_COLOUR_NET_PLAYER23,
HUD_COLOUR_NET_PLAYER24,
HUD_COLOUR_NET_PLAYER25,
HUD_COLOUR_NET_PLAYER26,
HUD_COLOUR_NET_PLAYER27,
HUD_COLOUR_NET_PLAYER28,
HUD_COLOUR_NET_PLAYER29,
HUD_COLOUR_NET_PLAYER30,
HUD_COLOUR_NET_PLAYER31,
HUD_COLOUR_NET_PLAYER32,
HUD_COLOUR_SIMPLEBLIP_DEFAULT,
HUD_COLOUR_MENU_BLUE,
HUD_COLOUR_MENU_GREY_LIGHT,
HUD_COLOUR_MENU_BLUE_EXTRA_DARK,
HUD_COLOUR_MENU_YELLOW,
HUD_COLOUR_MENU_YELLOW_DARK,
HUD_COLOUR_MENU_GREEN,
HUD_COLOUR_MENU_GREY,
HUD_COLOUR_MENU_GREY_DARK,
HUD_COLOUR_MENU_HIGHLIGHT,
HUD_COLOUR_MENU_STANDARD,
HUD_COLOUR_MENU_DIMMED,
HUD_COLOUR_MENU_EXTRA_DIMMED,
HUD_COLOUR_BRIEF_TITLE,
HUD_COLOUR_MID_GREY_MP,
HUD_COLOUR_NET_PLAYER1_DARK,
HUD_COLOUR_NET_PLAYER2_DARK,
HUD_COLOUR_NET_PLAYER3_DARK,
HUD_COLOUR_NET_PLAYER4_DARK,
HUD_COLOUR_NET_PLAYER5_DARK,
HUD_COLOUR_NET_PLAYER6_DARK,
HUD_COLOUR_NET_PLAYER7_DARK,
HUD_COLOUR_NET_PLAYER8_DARK,
HUD_COLOUR_NET_PLAYER9_DARK,
HUD_COLOUR_NET_PLAYER10_DARK,
HUD_COLOUR_NET_PLAYER11_DARK,
HUD_COLOUR_NET_PLAYER12_DARK,
HUD_COLOUR_NET_PLAYER13_DARK,
HUD_COLOUR_NET_PLAYER14_DARK,
HUD_COLOUR_NET_PLAYER15_DARK,
HUD_COLOUR_NET_PLAYER16_DARK,
HUD_COLOUR_NET_PLAYER17_DARK,
HUD_COLOUR_NET_PLAYER18_DARK,
HUD_COLOUR_NET_PLAYER19_DARK,
HUD_COLOUR_NET_PLAYER20_DARK,
HUD_COLOUR_NET_PLAYER21_DARK,
HUD_COLOUR_NET_PLAYER22_DARK,
HUD_COLOUR_NET_PLAYER23_DARK,
HUD_COLOUR_NET_PLAYER24_DARK,
HUD_COLOUR_NET_PLAYER25_DARK,
HUD_COLOUR_NET_PLAYER26_DARK,
HUD_COLOUR_NET_PLAYER27_DARK,
HUD_COLOUR_NET_PLAYER28_DARK,
HUD_COLOUR_NET_PLAYER29_DARK,
HUD_COLOUR_NET_PLAYER30_DARK,
HUD_COLOUR_NET_PLAYER31_DARK,
HUD_COLOUR_NET_PLAYER32_DARK,
HUD_COLOUR_BRONZE,
HUD_COLOUR_SILVER,
HUD_COLOUR_GOLD,
HUD_COLOUR_PLATINUM,
HUD_COLOUR_GANG1,
HUD_COLOUR_GANG2,
HUD_COLOUR_GANG3,
HUD_COLOUR_GANG4,
HUD_COLOUR_SAME_CREW,
HUD_COLOUR_FREEMODE,
HUD_COLOUR_PAUSE_BG,
HUD_COLOUR_FRIENDLY,
HUD_COLOUR_ENEMY,
HUD_COLOUR_LOCATION,
HUD_COLOUR_PICKUP,
HUD_COLOUR_PAUSE_SINGLEPLAYER,
HUD_COLOUR_FREEMODE_DARK,
HUD_COLOUR_INACTIVE_MISSION,
HUD_COLOUR_DAMAGE,
HUD_COLOUR_PINKLIGHT,
HUD_COLOUR_PM_MITEM_HIGHLIGHT,
HUD_COLOUR_SCRIPT_VARIABLE,
HUD_COLOUR_YOGA,
HUD_COLOUR_TENNIS,
HUD_COLOUR_GOLF,
HUD_COLOUR_SHOOTING_RANGE,
HUD_COLOUR_FLIGHT_SCHOOL,
HUD_COLOUR_NORTH_BLUE,
HUD_COLOUR_SOCIAL_CLUB,
HUD_COLOUR_PLATFORM_BLUE,
HUD_COLOUR_PLATFORM_GREEN,
HUD_COLOUR_PLATFORM_GREY,
HUD_COLOUR_FACEBOOK_BLUE,
HUD_COLOUR_INGAME_BG,
HUD_COLOUR_DARTS,
HUD_COLOUR_WAYPOINT,
HUD_COLOUR_MICHAEL,
HUD_COLOUR_FRANKLIN,
HUD_COLOUR_TREVOR,
HUD_COLOUR_GOLF_P1,
HUD_COLOUR_GOLF_P2,
HUD_COLOUR_GOLF_P3,
HUD_COLOUR_GOLF_P4,
HUD_COLOUR_WAYPOINTLIGHT,
HUD_COLOUR_WAYPOINTDARK,
HUD_COLOUR_PANEL_LIGHT,
HUD_COLOUR_MICHAEL_DARK,
HUD_COLOUR_FRANKLIN_DARK,
HUD_COLOUR_TREVOR_DARK,
HUD_COLOUR_OBJECTIVE_ROUTE,
HUD_COLOUR_PAUSEMAP_TINT,
HUD_COLOUR_PAUSE_DESELECT,
HUD_COLOUR_PM_WEAPONS_PURCHASABLE,
HUD_COLOUR_PM_WEAPONS_LOCKED,
HUD_COLOUR_END_SCREEN_BG,
HUD_COLOUR_CHOP,
HUD_COLOUR_PAUSEMAP_TINT_HALF,
HUD_COLOUR_NORTH_BLUE_OFFICIAL,
HUD_COLOUR_SCRIPT_VARIABLE_2,
HUD_COLOUR_H,
HUD_COLOUR_HDARK,
HUD_COLOUR_T,
HUD_COLOUR_TDARK,
HUD_COLOUR_HSHARD,
HUD_COLOUR_CONTROLLER_MICHAEL,
HUD_COLOUR_CONTROLLER_FRANKLIN,
HUD_COLOUR_CONTROLLER_TREVOR,
HUD_COLOUR_CONTROLLER_CHOP,
HUD_COLOUR_VIDEO_EDITOR_VIDEO,
HUD_COLOUR_VIDEO_EDITOR_AUDIO,
HUD_COLOUR_VIDEO_EDITOR_TEXT,
HUD_COLOUR_HB_BLUE,
HUD_COLOUR_HB_YELLOW,
HUD_COLOUR_VIDEO_EDITOR_SCORE,
HUD_COLOUR_VIDEO_EDITOR_AUDIO_FADEOUT,
HUD_COLOUR_VIDEO_EDITOR_TEXT_FADEOUT,
HUD_COLOUR_VIDEO_EDITOR_SCORE_FADEOUT,
HUD_COLOUR_HEIST_BACKGROUND,
HUD_COLOUR_VIDEO_EDITOR_AMBIENT,
HUD_COLOUR_VIDEO_EDITOR_AMBIENT_FADEOUT,
HUD_COLOUR_GB,
HUD_COLOUR_G,
HUD_COLOUR_B,
HUD_COLOUR_LOW_FLOW,
HUD_COLOUR_LOW_FLOW_DARK,
HUD_COLOUR_G1,
HUD_COLOUR_G2,
HUD_COLOUR_G3,
HUD_COLOUR_G4,
HUD_COLOUR_G5,
HUD_COLOUR_G6,
HUD_COLOUR_G7,
HUD_COLOUR_G8,
HUD_COLOUR_G9,
HUD_COLOUR_G10,
HUD_COLOUR_G11,
HUD_COLOUR_G12,
HUD_COLOUR_G13,
HUD_COLOUR_G14,
HUD_COLOUR_G15,
HUD_COLOUR_ADVERSARY,
HUD_COLOUR_DEGEN_RED,
HUD_COLOUR_DEGEN_YELLOW,
HUD_COLOUR_DEGEN_GREEN,
HUD_COLOUR_DEGEN_CYAN,
HUD_COLOUR_DEGEN_BLUE,
HUD_COLOUR_DEGEN_MAGENTA,
HUD_COLOUR_STUNT_1,
HUD_COLOUR_STUNT_2,
HUD_COLOUR_SPECIAL_RACE_SERIES,
HUD_COLOUR_SPECIAL_RACE_SERIES_DARK,
HUD_COLOUR_CS,
HUD_COLOUR_CS_DARK,
HUD_COLOUR_TECH_GREEN,
HUD_COLOUR_TECH_GREEN_DARK,
HUD_COLOUR_TECH_RED,
HUD_COLOUR_TECH_GREEN_VERY_DARK,
HUD_COLOUR_DEFAULT //not a real value, used in logic
}
}

View File

@@ -0,0 +1,12 @@
namespace Nexd.ESX.Client
{
public enum IconType : int
{
ChatBox = 1,
Email = 2,
AddFriendRequest = 3,
RightJumpingWindow = 7,
RP = 8,
Dollar = 9
}
}

View File

@@ -0,0 +1,172 @@
namespace Nexd.ESX.Client
{
public enum NotificationPicture
{
CHAR_ABIGAIL,
CHAR_ALL_PLAYERS_CONF,
CHAR_AMANDA,
CHAR_AMMUNATION,
CHAR_ANDREAS,
CHAR_ANTONIA,
CHAR_ARTHUR,
CHAR_ASHLEY,
CHAR_BANK_BOL,
CHAR_BANK_FLEECA,
CHAR_BANK_MAZE,
CHAR_BARRY,
CHAR_BEVERLY,
CHAR_BIKESITE,
CHAR_BLANK_ENTRY,
CHAR_BLIMP,
CHAR_BLOCKED,
CHAR_BOATSITE,
CHAR_BROKEN_DOWN_GIRL,
CHAR_BUGSTARS,
CHAR_CALL911,
CHAR_CARSITE,
CHAR_CARSITE2,
CHAR_CASTRO,
CHAR_CHAT_CALL,
CHAR_CHEF,
CHAR_CHENG,
CHAR_CHENGSR,
CHAR_CHOP,
CHAR_CRIS,
CHAR_DAVE,
CHAR_DEFAULT,
CHAR_DENISE,
CHAR_DETONATEBOMB,
CHAR_DETONATEPHONE,
CHAR_DEVIN,
CHAR_DIAL_A_SUB,
CHAR_DOM,
CHAR_DOMESTIC_GIRL,
CHAR_DREYFUSS,
CHAR_DR_FRIEDLANDER,
CHAR_EPSILON,
CHAR_ESTATE_AGENT,
CHAR_FACEBOOK,
CHAR_FILMNOIR,
CHAR_FLOYD,
CHAR_FRANKLIN,
CHAR_FRANK_TREV_CONF,
CHAR_GAYMILITARY,
CHAR_HAO,
CHAR_HITCHER_GIRL,
CHAR_HUMANDEFAULT,
CHAR_HUNTER,
CHAR_JIMMY,
CHAR_JIMMY_BOSTON,
CHAR_JOE,
CHAR_JOSEF,
CHAR_JOSH,
CHAR_LAMAR,
CHAR_LAZLOW,
CHAR_LESTER,
CHAR_LESTER_DEATHWISH,
CHAR_LEST_FRANK_CONF,
CHAR_LEST_MIKE_CONF,
CHAR_LIFEINVADER,
CHAR_LS_CUSTOMS,
CHAR_LS_TOURIST_BOARD,
CHAR_MANUEL,
CHAR_MARNIE,
CHAR_MARTIN,
CHAR_MARY_ANN,
CHAR_MAUDE,
CHAR_MECHANIC,
CHAR_MICHAEL,
CHAR_MIKE_FRANK_CONF,
CHAR_MIKE_TREV_CONF,
CHAR_MILSITE,
CHAR_MINOTAUR,
CHAR_MOLLY,
CHAR_MP_ARMY_CONTACT,
CHAR_MP_BIKER_BOSS,
CHAR_MP_BIKER_MECHANIC,
CHAR_MP_BRUCIE,
CHAR_MP_DETONATEPHONE,
CHAR_MP_FAM_BOSS,
CHAR_MP_FIB_CONTACT,
CHAR_MP_FM_CONTACT,
CHAR_MP_GERALD,
CHAR_MP_JULIO,
CHAR_MP_MECHANIC,
CHAR_MP_MERRYWEATHER,
CHAR_MP_MEX_BOSS,
CHAR_MP_MEX_DOCKS,
CHAR_MP_MEX_LT,
CHAR_MP_MORS_MUTUAL,
CHAR_MP_PROF_BOSS,
CHAR_MP_RAY_LAVOY,
CHAR_MP_ROBERTO,
CHAR_MP_SNITCH,
CHAR_MP_STRETCH,
CHAR_MP_STRIPCLUB_PR,
CHAR_MRS_THORNHILL,
CHAR_MULTIPLAYER,
CHAR_NIGEL,
CHAR_OMEGA,
CHAR_ONEIL,
CHAR_ORTEGA,
CHAR_OSCAR,
CHAR_PATRICIA,
CHAR_PEGASUS_DELIVERY,
CHAR_PLANESITE,
CHAR_PROPERTY_ARMS_TRAFFICKING,
CHAR_PROPERTY_BAR_AIRPORT,
CHAR_PROPERTY_BAR_BAYVIEW,
CHAR_PROPERTY_BAR_CAFE_ROJO,
CHAR_PROPERTY_BAR_COCKOTOOS,
CHAR_PROPERTY_BAR_ECLIPSE,
CHAR_PROPERTY_BAR_FES,
CHAR_PROPERTY_BAR_HEN_HOUSE,
CHAR_PROPERTY_BAR_HI_MEN,
CHAR_PROPERTY_BAR_HOOKIES,
CHAR_PROPERTY_BAR_IRISH,
CHAR_PROPERTY_BAR_LES_BIANCO,
CHAR_PROPERTY_BAR_MIRROR_PARK,
CHAR_PROPERTY_BAR_PITCHERS,
CHAR_PROPERTY_BAR_SINGLETONS,
CHAR_PROPERTY_BAR_TEQUILALA,
CHAR_PROPERTY_BAR_UNBRANDED,
CHAR_PROPERTY_CAR_MOD_SHOP,
CHAR_PROPERTY_CAR_SCRAP_YARD,
CHAR_PROPERTY_CINEMA_DOWNTOWN,
CHAR_PROPERTY_CINEMA_MORNINGWOOD,
CHAR_PROPERTY_CINEMA_VINEWOOD,
CHAR_PROPERTY_GOLF_CLUB,
CHAR_PROPERTY_PLANE_SCRAP_YARD,
CHAR_PROPERTY_SONAR_COLLECTIONS,
CHAR_PROPERTY_TAXI_LOT,
CHAR_PROPERTY_TOWING_IMPOUND,
CHAR_PROPERTY_WEED_SHOP,
CHAR_RON,
CHAR_SAEEDA,
CHAR_SASQUATCH,
CHAR_SIMEON,
CHAR_SOCIAL_CLUB,
CHAR_SOLOMON,
CHAR_STEVE,
CHAR_STEVE_MIKE_CONF,
CHAR_STEVE_TREV_CONF,
CHAR_STRETCH,
CHAR_STRIPPER_CHASTITY,
CHAR_STRIPPER_CHEETAH,
CHAR_STRIPPER_FUFU,
CHAR_STRIPPER_INFERNUS,
CHAR_STRIPPER_JULIET,
CHAR_STRIPPER_NIKKI,
CHAR_STRIPPER_PEACH,
CHAR_STRIPPER_SAPPHIRE,
CHAR_TANISHA,
CHAR_TAXI,
CHAR_TAXI_LIZ,
CHAR_TENNIS_COACH,
CHAR_TOW_TONYA,
CHAR_TRACEY,
CHAR_TREVOR,
CHAR_WADE,
CHAR_YOUTUBE
}
}

View File

@@ -0,0 +1,72 @@
namespace Nexd.ESX.Client
{
using System.Collections.Generic;
public static partial class ESX
{
public static partial class UI
{
public class MenuData
{
public dynamic Raw;
public MenuData(dynamic data) => Raw = data;
public MenuData()
{
Raw = new System.Dynamic.ExpandoObject();
Raw.title = new System.Dynamic.ExpandoObject();
Raw.align = new System.Dynamic.ExpandoObject();
Raw.elements = new System.Dynamic.ExpandoObject();
Raw.elements.head = new System.Dynamic.ExpandoObject();
Raw.elements.rows = new System.Dynamic.ExpandoObject();
}
public List<MenuElement> elements
{
get
{
List<MenuElement> temp = new List<MenuElement>();
foreach (var i in Raw.elements)
temp.Add(new MenuElement(i));
return temp;
}
set => Raw.elements = value;
}
public MenuElement current => new MenuElement(Raw.current);
public string title
{
get => Raw.title;
set => Raw.title = value;
}
public string align
{
get => Raw.align;
set => Raw.align = value;
}
public string[] head
{
get => Raw.elements.head;
set => Raw.elements.head = value;
}
public dynamic rows
{
get => Raw.elements.rows;
set => Raw.elements.rows = value;
}
public string type {
get => Raw.type;
set => Raw.type = value;
}
}
}
}
}

View File

@@ -0,0 +1,66 @@
namespace Nexd.ESX.Client
{
public static partial class ESX
{
public static partial class UI
{
public class MenuElement
{
public dynamic Raw;
public MenuElement(dynamic data) => Raw = data;
public MenuElement(dynamic label, dynamic value, dynamic customdata = null, string type = "default")
{
Raw = new System.Dynamic.ExpandoObject();
Raw.label = label;
Raw.value = value;
Raw.type = type;
custom = customdata;
}
public MenuElement()
{
Raw = new System.Dynamic.ExpandoObject();
Raw.label = new System.Dynamic.ExpandoObject();
Raw.value = new System.Dynamic.ExpandoObject();
Raw.name = new System.Dynamic.ExpandoObject();
Raw.options = new System.Dynamic.ExpandoObject();
Raw.type = "default";
custom = new System.Dynamic.ExpandoObject();
}
public dynamic label
{
get => Raw.label;
set => Raw.label = value;
}
public dynamic name {
get => Raw.name;
set => Raw.name = value;
}
public dynamic value
{
get => Raw.value;
set => Raw.value = value;
}
public dynamic options {
get => Raw.options;
set => Raw.options = value;
}
public string type
{
get => Raw.type;
set => Raw.type = value;
}
public dynamic custom { get; set; }
}
}
}
}

View File

@@ -0,0 +1,67 @@
namespace Nexd.ESX.Client
{
using System.Collections.Generic;
using CitizenFX.Core;
using Nexd.ESX.Shared;
public class PlayerData
{
public dynamic Raw;
public PlayerData() { }
public PlayerData(dynamic data) => Raw = data;
public Job job => new Job(Raw.job);
public Vector3 coords => new Vector3((float)Raw.coords.x, (float)Raw.coords.y, (float)Raw.coords.z);
public double heading => Raw.coords.heading;
public double maxWeight => Raw.maxWeight;
public List<Shared.Weapon> loadout
{
get
{
List<Shared.Weapon> temp = new List<Shared.Weapon>();
var loadout = Raw.loadout;
foreach (var i in loadout)
{
temp.Add(new Shared.Weapon(i));
}
return temp;
}
}
public Account[] accounts
{
get
{
Account[] accounts = new Account[3];
var raw = Raw.accounts;
for (int i = 0; i < 3; i++)
accounts[i] = new Account(raw[i]);
return accounts;
}
}
public List<InventoryItem> inventory
{
get
{
List<InventoryItem> inventory = new List<InventoryItem>();
var rawdata = Raw.inventory;
foreach (var i in rawdata)
{
inventory.Add(new InventoryItem(i));
}
return inventory;
}
}
}
}

View File

@@ -0,0 +1,334 @@
using System;
using System.Collections.Generic;
using System.Dynamic;
using CitizenFX.Core;
namespace Nexd.ESX.Client {
public class VehicleProperties {
private dynamic Raw;
public VehicleProperties() {
Raw = new ExpandoObject();
}
public VehicleProperties(dynamic data) => Raw = data;
public dynamic GetRaw() => Raw;
public int model {
get => Convert.ToInt32(Raw.model);
set => Raw.model = Convert.ToInt32(value);
}
public string plate {
get => Raw.plate;
set => Raw.plate = value;
}
public int plateIndex {
get => Raw.plateIndex;
set => Raw.plateIndex = value;
}
public double bodyHealth {
get => Raw.bodyHealth;
set => Raw.bodyHealth = value;
}
public double engineHealth {
get => Raw.engineHealth;
set => Raw.engineHealth = value;
}
public double tankHealth {
get => Raw.tankHealth;
set => Raw.tankHealth = value;
}
public double fuelLevel {
get => Raw.fuelLevel;
set => Raw.fuelLevel = value;
}
public double dirtLevel {
get => Raw.dirtLevel;
set => Raw.dirtLevel = value;
}
public VehicleColor color1 {
get => (VehicleColor)Raw.color1;
set => Raw.color1 = (int)value;
}
public VehicleColor color2 {
get => (VehicleColor)Raw.color2;
set => Raw.color2 = (int)value;
}
public VehicleColor pearlescentColor {
get => (VehicleColor)Raw.pearlescentColor;
set => Raw.pearlescentColor = (int)value;
}
public VehicleColor wheelColor {
get => (VehicleColor)Raw.wheelColor;
set => Raw.wheelColor = (int)value;
}
public VehicleWheelType wheels {
get => (VehicleWheelType)Raw.wheels;
set => Raw.wheels = (int)value;
}
public VehicleWindowTint windowTint {
get => (VehicleWindowTint)Raw.windowTint;
set => Raw.windowTint = (int)value;
}
public List<bool> neonEnabled {
get => Raw.neonEnabled;
set => Raw.neonEnabled = value;
}
public List<int> neonColor {
get => Raw.neonColor;
set => Raw.neonColor = value;
}
public List<object> extras {
get => Raw.extras;
set => Raw.extras = value;
}
public dynamic tyreSmokeColor {
get => Raw.tyreSmokeColor;
set => Raw.tyreSmokeColor = value;
}
public int modSpoilers {
get => Raw.modSpoilers;
set => Raw.modSpoilers = value;
}
public int modFrontBumper {
get => Raw.modFrontBumper;
set => Raw.modFrontBumper = value;
}
public int modRearBumper {
get => Raw.modRearBumper;
set => Raw.modRearBumper = value;
}
public int modSideSkirt {
get => Raw.modSideSkirt;
set => Raw.modSideSkirt = value;
}
public int modExhaust {
get => Raw.modExhaust;
set => Raw.modExhaust = value;
}
public int modFrame {
get => Raw.modFrame;
set => Raw.modFrame = value;
}
public int modGrille {
get => Raw.modGrille;
set => Raw.modGrille = value;
}
public int modHood {
get => Raw.modHood;
set => Raw.modHood = value;
}
public int modFender {
get => Raw.modFender;
set => Raw.modFender = value;
}
public int modRightFender {
get => Raw.modRightFender;
set => Raw.modRightFender = value;
}
public int modRoof {
get => Raw.modRoof;
set => Raw.modRoof = value;
}
public int modEngine {
get => Raw.modEngine;
set => Raw.modEngine = value;
}
public int modBrakes {
get => Raw.modBrakes;
set => Raw.modBrakes = value;
}
public int modTransmission {
get => Raw.modTransmission;
set => Raw.modTransmission = value;
}
public int modHorns {
get => Raw.modHorns;
set => Raw.modHorns = value;
}
public int modSuspension {
get => Raw.modSuspension;
set => Raw.modSuspension = value;
}
public int modArmor {
get => Raw.modArmor;
set => Raw.modArmor = value;
}
public int modTurbo {
get => Raw.modTurbo;
set => Raw.modTurbo = value;
}
public bool modSmokeEnabled {
get => Raw.modSmokeEnabled;
set => Raw.modSmokeEnabled = value;
}
public bool modXenon {
get => Raw.modXenon;
set => Raw.modXenon = value;
}
public int modFrontWheels {
get => Raw.modFrontWheels;
set => Raw.modFrontWheels = value;
}
public int modBackWheels {
get => Raw.modBackWheels;
set => Raw.modBackWheels = value;
}
public int modPlateHolder {
get => Raw.modPlateHolder;
set => Raw.modPlateHolder = value;
}
public int modVanityPlate {
get => Raw.modVanityPlate;
set => Raw.modVanityPlate = value;
}
public int modTrimA {
get => Raw.modTrimA;
set => Raw.modTrimA = value;
}
public int modOrnaments {
get => Raw.modOrnaments;
set => Raw.modOrnaments = value;
}
public int modDashboard {
get => Raw.modDashboard;
set => Raw.modDashboard = value;
}
public int modDial {
get => Raw.modDial;
set => Raw.modDial = value;
}
public int modDoorSpeaker {
get => Raw.modDoorSpeaker;
set => Raw.modDoorSpeaker = value;
}
public int modSeats {
get => Raw.modSeats;
set => Raw.modSeats = value;
}
public int modSteeringWheel {
get => Raw.modSteeringWheel;
set => Raw.modSteeringWheel = value;
}
public int modShifterLeavers {
get => Raw.modShifterLeavers;
set => Raw.modShifterLeavers = value;
}
public int modAPlate {
get => Raw.modAPlate;
set => Raw.modAPlate = value;
}
public int modSpeakers {
get => Raw.modSpeakers;
set => Raw.modSpeakers = value;
}
public int modTrunk {
get => Raw.modTrunk;
set => Raw.modTrunk = value;
}
public int modHydrolic {
get => Raw.modHydrolic;
set => Raw.modHydrolic = value;
}
public int modEngineBlock {
get => Raw.modEngineBlock;
set => Raw.modEngineBlock = value;
}
public int modAirFilter {
get => Raw.modAirFilter;
set => Raw.modAirFilter = value;
}
public int modStruts {
get => Raw.modStruts;
set => Raw.modStruts = value;
}
public int modArchCover {
get => Raw.modArchCover;
set => Raw.modArchCover = value;
}
public int modAerials {
get => Raw.modAerials;
set => Raw.modAerials = value;
}
public int modTrimB {
get => Raw.modTrimB;
set => Raw.modTrimB = value;
}
public int modTank {
get => Raw.modTank;
set => Raw.modTank = value;
}
/*public int modWindows
{
get => Raw.modWindows;
set => Raw.modWindows = value;
}*/
public int modLivery {
get => Raw.modLivery;
set => Raw.modLivery = value;
}
}
}

View File

@@ -0,0 +1,26 @@
namespace Nexd.ESX.Shared
{
using System;
public class Account
{
public enum AccountType : int
{
Cash = 0,
Bank = 1,
Black = 2
}
public dynamic Raw;
public string name => Raw.name;
public int money => Convert.ToInt32(Raw.money);
public string label => Raw.label;
public Account() { }
public Account(dynamic data) => Raw = data;
}
}

View File

@@ -0,0 +1,25 @@
namespace Nexd.ESX.Shared
{
public class InventoryItem
{
public dynamic Raw;
public string name => Raw.name;
public int count => Raw.count;
public string label => Raw.label;
public double weight => Raw.weight;
public bool usable => Raw.usable;
public bool rare => Raw.rare;
public bool canRemove => Raw.canRemove;
public InventoryItem() { }
public InventoryItem(dynamic data) => Raw = data;
}
}

View File

@@ -0,0 +1,29 @@
namespace Nexd.ESX.Shared
{
public class Job
{
public dynamic Raw;
public int id => Raw.id;
public string name => Raw.name;
public string label => Raw.label;
public int grade => Raw.grade;
public string grade_name => Raw.grade_name;
public string grade_label => Raw.grade_label;
public int grade_salary => Raw.grade_salary;
public dynamic skin_male => Raw.skin_male;
public dynamic skin_female => Raw.skin_female;
public Job() { }
public Job(dynamic data) => Raw = data;
}
}

View File

@@ -0,0 +1,35 @@
namespace Nexd.ESX.Shared
{
using System.Collections.Generic;
public class Weapon
{
public dynamic Raw;
public string name => Raw.name;
public int ammo => Raw.ammo;
public string label => Raw.label;
public int tintIndex => Raw.tintIndex;
public List<string> components
{
get
{
List<string> temp = new List<string>();
foreach (var i in Raw.components)
{
temp.Add(i);
}
return temp;
}
}
public Weapon() { }
public Weapon(dynamic data) => Raw = data;
}
}

View File

@@ -0,0 +1,6 @@
namespace Mosleys.Shared.Models {
public struct BuyData {
public string Uuid { get; set; }
public string Plate { get; set; }
}
}

View File

@@ -0,0 +1,11 @@
namespace Mosleys.Shared.Models {
public struct ExhibitUpdate {
public UpdateAction Action { get; set; }
public ExhibitVehicle Exhibit { get; set; }
}
public enum UpdateAction {
Update,
Delete
}
}

View File

@@ -0,0 +1,25 @@
using System;
using System.Dynamic;
namespace Mosleys.Shared.Models {
public class ExhibitVehicle {
public string Uuid { get; set; }
public string Owner { get; set; }
public string Description { get; set; }
public int Price { get; set; }
public int Slot { get; set; }
public ExpandoObject Vehicle { get; set; }
public bool TestDrive { get; set; }
public static ExhibitVehicle FromDynamic(dynamic data) {
var vehicle = new ExhibitVehicle();
vehicle.Uuid = data.Uuid;
vehicle.Owner = data.Owner;
vehicle.Description = data.Description;
vehicle.Price = Convert.ToInt32(data.Price);
vehicle.Slot = Convert.ToInt32(data.Slot);
vehicle.Vehicle = data.Vehicle;
vehicle.TestDrive = data.TestDrive;
return vehicle;
}
}
}

View File

@@ -0,0 +1,10 @@
using System.Dynamic;
namespace Mosleys.Shared.Models {
public struct SellData {
public int ParkingSpace { get; set; }
public string Description { get; set; }
public int Price { get; set; }
public ExpandoObject VehicleProperties { get; set; }
}
}

View File

@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{95000252-DA88-4A79-8958-CA70B42CE0F9}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Mosleys.Shared</RootNamespace>
<AssemblyName>Mosleys.Shared</AssemblyName>
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="CitizenFX.Core">
<HintPath>..\Librarys\CitizenFX.Core.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.CSharp">
<HintPath>..\Librarys\Microsoft.CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Config.cs" />
<Compile Include="ESX\Client\Enums\HudColor.cs" />
<Compile Include="ESX\Client\Enums\IconType.cs" />
<Compile Include="ESX\Client\Enums\NotificationPicture.cs" />
<Compile Include="ESX\Client\ESX.cs" />
<Compile Include="ESX\Client\ESX.Game.cs" />
<Compile Include="ESX\Client\ESX.Game.Utils.cs" />
<Compile Include="ESX\Client\ESX.Scaleform.cs" />
<Compile Include="ESX\Client\ESX.Scaleform.Utils.cs" />
<Compile Include="ESX\Client\ESX.Streaming.cs" />
<Compile Include="ESX\Client\ESX.UI.cs" />
<Compile Include="ESX\Client\ESX.UI.HUD.cs" />
<Compile Include="ESX\Client\ESX.UI.Menu.cs" />
<Compile Include="ESX\Client\Models\ESX.UI.MenuData.cs" />
<Compile Include="ESX\Client\Models\ESX.UI.MenuElement.cs" />
<Compile Include="ESX\Client\Models\PlayerData.cs" />
<Compile Include="ESX\Client\Models\VehicleProperties.cs" />
<Compile Include="ESX\Shared\Account.cs" />
<Compile Include="ESX\Shared\InventoryItem.cs" />
<Compile Include="ESX\Shared\Job.cs" />
<Compile Include="ESX\Shared\Weapon.cs" />
<Compile Include="Models\BuyData.cs" />
<Compile Include="Models\ExhibitUpdate.cs" />
<Compile Include="Models\ExhibitVehicle.cs" />
<Compile Include="Models\SellData.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SectionScript.cs" />
<Compile Include="ServerConfig.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="fxmanifest.lua">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="settings.ini">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Mosleys.Shared")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Mosleys.Shared")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("95000252-DA88-4A79-8958-CA70B42CE0F9")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using CitizenFX.Core;
using CitizenFX.Core.Native;
namespace Mosleys.Shared {
}

View File

@@ -0,0 +1,154 @@
using System;
using System.Collections.Generic;
using System.Linq;
using CitizenFX.Core.Native;
namespace Mosleys.Shared {
public sealed class ServerConfig {
private sealed class ServerSectionScript {
private const char SplitChar = ' ';
private const string SectionStart = "{";
private const string SectionEnd = "}";
private const string CommentPrefix = "//";
private readonly string _fileName;
private readonly List<Tuple<string, Dictionary<string, string>>> _loadedData =
new List<Tuple<string, Dictionary<string, string>>>();
private readonly List<string> _allSections = new List<string>();
public ServerSectionScript(string fileName, bool load = false) {
_fileName = fileName;
if (!load)
return;
Read();
}
public string this[string section, string key, string result = ""] =>
GetValue(section, key, result);
public T GetValue<T>(string section, string key, T result) {
if (!SectionExists(section))
return result;
string data = GetData(section, key, result.ToString());
try {
return (T)Convert.ChangeType(data, typeof(T));
}
catch (InvalidCastException) {
return result;
}
}
public int[] GetIntArray(string section, string key, int[] result) {
if (!SectionExists(section))
return result;
string data = GetData(section, key, result.ToString());
data = data.Replace("[", "").Replace("]", "").Replace(" ", "");
return data.Split(',').Select(n => Convert.ToInt32(n)).ToArray();
}
public float[] GetFloatArray(string section, string key, float[] result) {
if (!SectionExists(section))
return result;
string data = GetData(section, key, result.ToString());
data = data.Replace("[", "").Replace("]", "").Replace(" ", "");
return data.Split(',').Select(Convert.ToSingle).ToArray();
}
public float[][] GetFloatArray2d(string section) {
List<float[]> floats = new List<float[]>();
foreach (Tuple<string, Dictionary<string, string>> tuple in _loadedData) {
if (!tuple.Item1.Equals(section)) continue;
foreach (var key in tuple.Item2.Values) {
var data = key.Replace("[", "").Replace("]", "").Replace(" ", "");
var vector = data.Split(',').Select(Convert.ToSingle).ToArray();
floats.Add(vector);
}
}
return floats.ToArray();
}
public string GetData(string section, string key, string result) {
foreach (Tuple<string, Dictionary<string, string>> tuple in _loadedData) {
if (tuple.Item1.Equals(section))
return tuple.Item2.ContainsKey(key) ? tuple.Item2[key] : result;
}
return result;
}
public bool SectionExists(string section) => _allSections.Contains(section);
public void Read() {
_loadedData.Clear();
_allSections.Clear();
string str1 = "";
Dictionary<string, string> source = new Dictionary<string, string>();
string str2 = API.LoadResourceFile(API.GetCurrentResourceName(), _fileName);
char[] chArray = { '\n' };
foreach (string str3 in str2.Split(chArray).Select(str => str.Trim())) {
string text = str3.Replace("\r", "");
if (!string.IsNullOrEmpty(text) && !string.IsNullOrWhiteSpace(text)) {
if (text.StartsWith(SectionStart)) {
str1 = text.Substring(1);
if (text.EndsWith(SectionEnd) && !str1.Contains(SectionStart)) {
str1 = str1.Remove(str1.Length - 1, 1);
_loadedData.Add(
new Tuple<string, Dictionary<string, string>>(str1,
new Dictionary<string, string>()));
if (!_allSections.Contains(str1))
_allSections.Add(str1);
source.Clear();
}
}
else if (text.EndsWith(SectionEnd) || text.StartsWith(SectionEnd)) {
Dictionary<string, string> dictionary =
source.ToDictionary(
entry => entry.Key,
entry => entry.Value);
_loadedData.Add(new Tuple<string, Dictionary<string, string>>(str1, dictionary));
if (!_allSections.Contains(str1))
_allSections.Add(str1);
source.Clear();
}
else if (!text.StartsWith(CommentPrefix)) {
Tuple<string, string> data = ConvertToData(text);
if (!source.ContainsKey(data.Item1))
source.Add(data.Item1, data.Item2);
}
}
}
}
public Tuple<string, string> ConvertToData(string text) {
int length = text.IndexOf(SplitChar);
if (length == -1)
return new Tuple<string, string>(text, "");
string str = "";
if (length - 1 < text.Length)
str = text.Substring(length + 1, text.Length - length - 1);
return new Tuple<string, string>(text.Substring(0, length), str);
}
}
public ServerConfig() {
var script = new ServerSectionScript("settings.ini", true);
ExhibitPrice = script.GetValue("[General]", "ExhibitPrice", 500);
SellBill = script.GetValue("[General]", "SellBill", 0.1f);
TargetSociety = script.GetValue("[General]", "TargetSociety", "mechanic");
CarSlots = script.GetFloatArray2d("[CarSlots]");
}
public readonly int ExhibitPrice;
public readonly float SellBill;
public readonly string TargetSociety;
public readonly float[][] CarSlots;
}
}

View File

@@ -0,0 +1,21 @@
fx_version 'cerulean'
games { 'gta5' }
-- details
author 'Leon Hoppe'
description "Mosley's"
version '2.0'
files {
'Newtonsoft.Json.dll',
'Mosleys.Shared.dll',
'settings.ini'
}
client_scripts {
'Mosleys.Client.net.dll'
}
server_scripts {
'Mosleys.Server.net.dll'
}

Some files were not shown because too many files have changed in this diff Show More