Update 29.10.2022
This commit is contained in:
15
C#/Mosleys/Mosleys.Server/ESX/Server/ESX.Config.Weapons.cs
Normal file
15
C#/Mosleys/Mosleys.Server/ESX/Server/ESX.Config.Weapons.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
21
C#/Mosleys/Mosleys.Server/ESX/Server/ESX.Config.cs
Normal file
21
C#/Mosleys/Mosleys.Server/ESX/Server/ESX.Config.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
56
C#/Mosleys/Mosleys.Server/ESX/Server/ESX.cs
Normal file
56
C#/Mosleys/Mosleys.Server/ESX/Server/ESX.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
160
C#/Mosleys/Mosleys.Server/ESX/Server/xPlayer.cs
Normal file
160
C#/Mosleys/Mosleys.Server/ESX/Server/xPlayer.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user