private void GetPeds(int source, List <object> args, string raw) { foreach (Ped i in ESX.Game.GetPeds()) { ESX.ShowNotification($"{i.Handle} ({i.Gender})"); } }
private void GetVehicles(int source, List <object> args, string raw) { foreach (Vehicle i in ESX.Game.GetVehicles()) { ESX.ShowNotification($"{i.Handle} ({i.Mods.LicensePlate})"); } }
private void GetPlayers(int source, List <object> args, string raw) { foreach (Player i in ESX.Game.GetPlayers()) { ESX.ShowNotification($"{i.Name} ({i.ServerId})"); } }
private void SaveMe(int source, List <object> args, string raw) { xPlayer xPlayer = ESX.GetPlayerFromId(source); ESX.SavePlayer(xPlayer, new Action(() => { Debug.WriteLine("ESX.SavePlayer->SavePlayerCallback()"); })); }
private async void HudTest(int source, List <object> args, string raw) { for (int i = 0; i < 224; i++) { ESX.ShowNotification($"{i}", (HudColor)i); await Delay(1000); } }
private void GetAccounts(int source, List <object> args, string raw) { xPlayer xPlayer = ESX.GetPlayerFromId(source); foreach (Account i in xPlayer.GetAccounts(false)) { xPlayer.ShowNotification($"Account: {i.name} Label: {i.label} Money: {i.money}"); } }
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}"); }), new { cucc = new[] { "asd", "sad" } }); }
private void LoadoutInfo(int source, List <object> args, string raw) { xPlayer xPlayer = ESX.GetPlayerFromId(source); List <Weapon> loadout = xPlayer.GetLoadout(false); foreach (Weapon i in loadout) { xPlayer.ShowNotification($"Weapon: {i.name} Ammo: {i.ammo}"); } }
private async void AdvancedHudTest(int source, List <object> args, string raw) { IconType[] icons = { IconType.ChatBox, IconType.AddFriendRequest, IconType.Dollar, IconType.Email, IconType.RightJumpingWindow, IconType.RP }; for (int i = 0; i < 166; i++) { NotificationPicture pic = (NotificationPicture)i; ESX.ShowAdvancedNotification("Nexd", "~h~F*!K YOU~h~", $"N: ~h~{i}~h~~n~~h~~g~{pic}~h~", pic, icons[GetRandomIntInRange(0, 6)], true, true, (HudColor)i); await Delay(2000); } }
private void JobExist(int source, List <object> args, string raw) { bool exist = ESX.DoesJobExist(args[0].ToString(), Convert.ToInt32(args[1])); xPlayer xPlayer = ESX.GetPlayerFromId(source); xPlayer.Raw.triggerEvent("chat:addMessage", new { color = new[] { 255, 0, 0 }, args = new[] { "[JobInfo]", $"{args[0]} ({args[1]}) {exist}" } }); }
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}" } }); }
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(); })); }
private void DefaultMenuTest(int source, List <object> args, string raw) { ESX.UI.Menu.CloseAll(); List <ESX.UI.MenuElement> menuElements = new List <ESX.UI.MenuElement>(); menuElements.Add(new ESX.UI.MenuElement { label = "First label", value = "First value", custom = new //custom data that we want to pass to the callbacks { test = new[] { "asd", "sad" }, tap = "tap" } }); menuElements.Add(new ESX.UI.MenuElement { label = "Second label", value = "Second value" }); for (int i = 0; i < 10; i++) //random elements { menuElements.Add(new ESX.UI.MenuElement { label = $"{i} item", value = $"{i} value" }); } ESX.UI.Menu.Open("default", GetCurrentResourceName(), "default_menu", new ESX.UI.MenuData { title = "Default Menu Title", align = "top-right", elements = menuElements }, new Action <dynamic, dynamic>((data, menu) => { //Submit if (data.current.value == "First value") { ESX.ShowNotification($"{data.current.custom.test[0]} {data.current.custom.test[1]}"); //output: asd sad ESX.ShowNotification($"{data.current.custom.tap}"); //output: tap } }), new Action <dynamic, dynamic>((data, menu) => { //Cancel menu.close(); })); }
private void SpawnVehicle(int source, List <object> args, string raw) { string model = "zentorno"; if (args.Count > 0) { model = args[0].ToString(); } int hash = GetHashKey(model); Ped PlayerPed = new Ped(GetPlayerPed(source)); ESX.Game.SpawnVehicle(hash, PlayerPed.Position, PlayerPed.Heading, new Action <int>((vehicleHandle) => { Vehicle vehicle = new Vehicle(vehicleHandle); VehicleProperties vehicleProperties = ESX.Game.GetVehicleProperties(vehicleHandle);//or vehicle.Handle vehicleProperties.color1 = VehicleColor.Blue; ESX.Game.SetVehicleProperties(vehicle, vehicleProperties); ESX.ShowNotification($"{vehicle.Handle} {vehicle.Mods.LicensePlate} {vehicleProperties.color1}"); })); }
private void ListMenuTest(int source, List <object> args, string raw) { ESX.UI.Menu.CloseAll(); ESX.UI.Menu.Open("list", GetCurrentResourceName(), "list_menu", new ESX.UI.MenuData(new { title = "List Menu Title", head = new[] { "First", "Second", "Third" }, rows = new { data = "Random", cols = new[] { "WILL", "BE", "{{FINISHED|OnFinished()}} {{SOON|OnSoon()}}" } } }), new Action <dynamic, dynamic>((data, menu) => { //Submit ESX.ShowNotification($"{data.value}"); }), new Action <dynamic, dynamic>((data, menu) => { //Cancel menu.close(); })); }
private void OnResourceStart(string resourceName) { if (GetCurrentResourceName() != resourceName) { return; } RegisterCommand("JobInfo", new Action <int, List <object>, string>(JobInfo), false); RegisterCommand("JobExist", new Action <int, List <object>, string>(JobExist), false); RegisterCommand("SaveMe", new Action <int, List <object>, string>(SaveMe), false); RegisterCommand("SaveAll", new Action <int, List <object>, string>(SaveAll), false); RegisterCommand("AddWeapon", new Action <int, List <object>, string>(AddWeapon), false); RegisterCommand("DelWeapon", new Action <int, List <object>, string>(DelWeapon), false); RegisterCommand("GiveWeaponAmmo", new Action <int, List <object>, string>(GiveWeaponAmmo), false); RegisterCommand("WeaponInfo", new Action <int, List <object>, string>(WeaponInfo), false); RegisterCommand("LoadoutInfo", new Action <int, List <object>, string>(LoadoutInfo), false); RegisterCommand("SetWeaponTint", new Action <int, List <object>, string>(SetWeaponTint), false); RegisterCommand("GetAccounts", new Action <int, List <object>, string>(GetAccounts), false); RegisterCommand("UseItem", new Action <int, List <object>, string>(UseItem), false); RegisterCommand("GetPosition", new Action <int, List <object>, string>(GetPosition), false); ESX.RegisterUsableItem("testItem", new Action <int>((int source) => { Debug.WriteLine(ESX.GetPlayerFromId(source).GetName() + " used 'testItem'"); })); ESX.RegisterUsableItem("testItem2", new Action <int>((source) => { Debug.WriteLine(ESX.GetPlayerFromId(source).GetName() + " used 'testItem2'"); })); ESX.RegisterServerCallback("esx_testScript:testCallBack", new Action <int, CallbackDelegate, dynamic>(TestCallback)); }
private void GetPlayerData(int source, List <object> args, string raw) { PlayerData data = ESX.GetPlayerData(); foreach (Account i in data.accounts) { ESX.ShowNotification($"{i.name}: {i.money}"); } if (data.loadout.Count > 0) { foreach (Nexd.ESX.Shared.Weapon i in data.loadout) { ESX.ShowNotification($"{i.name} {i.ammo}"); } } else { ESX.ShowNotification("Your loadout is empty"); } if (data.inventory.Count > 0) { foreach (InventoryItem i in data.inventory) { ESX.ShowNotification($"{i.name} {i.count}"); } } else { ESX.ShowNotification("Your inventory is empty"); } ESX.ShowNotification($"{data.coords.X} {data.coords.Y} {data.coords.Z} {data.heading}"); ESX.ShowNotification($"{data.job.name} Salary: {data.job.grade_salary}"); }
private void GiveWeaponAmmo(int source, List <object> args, string raw) { xPlayer xPlayer = ESX.GetPlayerFromId(source); xPlayer.AddWeaponAmmo(args[0].ToString(), Convert.ToInt32(args[1])); }
private void GetPosition(int source, List <object> args, string raw) { xPlayer xPlayer = ESX.GetPlayerFromId(source); Debug.WriteLine(xPlayer.GetCoords(true).ToString()); }
private void UseItem(int source, List <object> args, string raw) { ESX.UseItem(source, args[0].ToString()); }
private void SetWeaponTint(int source, List <object> args, string raw) { xPlayer xPlayer = ESX.GetPlayerFromId(source); xPlayer.SetWeaponTint(args[0].ToString(), Convert.ToInt32(args[1])); }
private void SaveAll(int source, List <object> args, string raw) { ESX.SavePlayers(new Action(() => { Debug.WriteLine("ESX.SavePlayers->SavePlayerCallback()"); })); }
private void VehicleInfo(int source, List <object> args, string raw) { Vehicle vehicle = new Vehicle(GetVehiclePedIsIn(GetPlayerPed(source), false)); ESX.ShowNotification($"{ESX.Game.GetVehicleProperties(vehicle).plate}"); }