No idea if there is anything like this already
Hello,
I could vomit from Lua and decided to code a wrapper for the ESX framework to make it somewhat “easier” to develop things.
This is for Developers, not for cp skids who just download everything and lets see.
- YOU CAN’T USE THIS ALONE, NOT A RESOURCE
- ONLY TESTED IT WITH ESX V1 FINAL BUT IT PROBABLY WORKS WITH OLDER VERSIONS
So what is this, and.. what can I do with this?
Probably you can do anything that you were able to do in the past, just in C#.
Nexd.ESX.Client contains everything that is available on clientside using ESX (And some extra stuff)
Nexd.ESX.Server contains everything that is available on serverside using ESX (And some extra stuff)
Nexd.ESX.Shared contains (get accessors only)
- Job class (job related properties)
- Weapon class (use Shared.Weapon on clientside)
- InventoryItem class
- Account class (Bank, Money, Black)
Examples (Assume that you’ve set the references already and got the basic things)
ESX.RegisterServerCallback and ESX.TriggerServerCallback
Serverside script:
ESX.RegisterServerCallback("esx_testScript:testCallBack", new Action<int, CallbackDelegate, dynamic>(TestCallback));
private void TestCallback(int source, CallbackDelegate cb, dynamic args)
{
//You may do the same things here as in Lua, like prechecks etc.. then return something
var data = args; //parsed from the client (needless line tho)
Debug.WriteLine($"SERVER.TESTCALLBACK {source} {data.cucc[0]} {data.cucc[1]}"); //client parsed 'dynamic args' that contains 'cucc', lets write its value
//random things to test that every kind of sh!t can be passed to the callback
List<string> tempData = new List<string>();
tempData.Add("a");
tempData.Add("b");
tempData.Add("c");
//Lets call the client callback and pass whatever we want to
cb.Invoke(new //this will be a new dynamic value that will be parsed to the client
{
test = new[] { "testData", "128asua" }, //dynamic param.test
other = 15, //dynamic param.other
tempData //dynamic param.tempData[0] or param.tempData.Count etc.. its still a List<> so you can do whatever you can with a list
//and so on..
});
}
Clientside script:
private void TestTrigger(int source, List<object> args, string raw)
{
ESX.TriggerServerCallback("esx_testScript:testCallBack", new Action<dynamic>((param) =>//param is parsed from the server
{
Debug.WriteLine($"CLIENT.TESTCALLBACK {param.test[0]} {param.test[1]} {param.other} {param.tempData.Count}"); //test is the 'string[]', other is the 'int' and the tempData is the List that we've parsed
}), new {
cucc = new[] { "asd", "sad" } //data that we've parsed to the server (data.cucc[0], data.cucc[1])
});
}
xPlayer, xPlayer.TriggerEvent and Job
Serverside script:
private void JobInfo(int source, List<object> args, string raw)
{
xPlayer xPlayer = ESX.GetPlayerFromId(source);
Job Job = xPlayer.GetJob();
xPlayer.TriggerEvent("chat:addMessage", new
{
color = new[] { 255, 0, 0 },
args = new[] { "[JobInfo]", $"Your Job is {Job.name}. Your Grade Is {Job.grade_name}. Your Salary is {Job.grade_salary}" }
});
}
DialogMenu
private void DialogMenuTest(int source, List<object> args, string raw)
{
ESX.UI.Menu.CloseAll();
ESX.UI.Menu.Open("dialog", GetCurrentResourceName(), "dialog_menu", new ESX.UI.MenuData
{
title = "Dialog Menu Title"
}, new Action<dynamic, dynamic>((data, menu) => { //Submit
ESX.ShowNotification($"{data.value}");
}), new Action<dynamic, dynamic>((data, menu) => { //Cancel
menu.close();
}));
}
More clientside example
More serverside example
I’m not planning on creating any doc for this project because you can use the Lua version to understand what is what, unless its needed