fixing it
This commit is contained in:
@@ -0,0 +1,167 @@
|
||||
local colorNames = {
|
||||
[0] = "Metallic Black",
|
||||
[1] = "Metallic Graphite",
|
||||
[2] = "Metallic Black Steel",
|
||||
[3] = "Metallic Dark Silver",
|
||||
[4] = "Metallic Silver",
|
||||
[5] = "Metallic Blue Silver",
|
||||
[6] = "Metallic Steel Gray",
|
||||
[7] = "Metallic Shadow Silver",
|
||||
[8] = "Metallic Stone Silver",
|
||||
[9] = "Metallic Midnight Silver",
|
||||
[10] = "Metallic Gun Metal",
|
||||
[11] = "Matte Black",
|
||||
[12] = "Matte Gray",
|
||||
[13] = "Matte Light Grey",
|
||||
[14] = "Util Black",
|
||||
[15] = "Util Black Poly",
|
||||
[16] = "Util Dark Silver",
|
||||
[17] = "Util Silver",
|
||||
[18] = "Util Gun Metal",
|
||||
[19] = "Util Shadow Silver",
|
||||
[20] = "Metallic Red",
|
||||
[21] = "Metallic Torino Red",
|
||||
[22] = "Metallic Formula Red",
|
||||
[23] = "Metallic Blaze Red",
|
||||
[24] = "Metallic Graceful Red",
|
||||
[25] = "Metallic Garnet Red",
|
||||
[26] = "Metallic Desert Red",
|
||||
[27] = "Metallic Cabernet Red",
|
||||
[28] = "Metallic Candy Red",
|
||||
[29] = "Metallic Sunrise Orange",
|
||||
[30] = "Metallic Classic Gold",
|
||||
[31] = "Metallic Orange",
|
||||
[32] = "Matte Red",
|
||||
[33] = "Matte Dark Red",
|
||||
[34] = "Matte Orange",
|
||||
[35] = "Metallic Dark Green",
|
||||
[36] = "Metallic Racing Green",
|
||||
[37] = "Metallic Sea Green",
|
||||
[38] = "Metallic Olive Green",
|
||||
[39] = "Metallic Green",
|
||||
[40] = "Metallic Gasoline Blue Green",
|
||||
[41] = "Matte Lime Green",
|
||||
[42] = "Dark Green",
|
||||
[43] = "Matte Green",
|
||||
[44] = "Worn Green",
|
||||
[45] = "Metallic Electric Blue",
|
||||
[46] = "Metallic Dark Blue",
|
||||
[47] = "Metallic Midnight Blue",
|
||||
[48] = "Metallic Saxon Blue",
|
||||
[49] = "Metallic Blue",
|
||||
[50] = "Metallic Mariner Blue",
|
||||
[51] = "Metallic Harbor Blue",
|
||||
[52] = "Metallic Diamond Blue",
|
||||
[53] = "Bright Green",
|
||||
[54] = "Metallic Nautical Blue",
|
||||
[55] = "Metallic Bright Blue",
|
||||
[56] = "Metallic Purple Blue",
|
||||
[57] = "Metallic Spinnaker Blue",
|
||||
[58] = "Metallic Ultra Blue",
|
||||
[59] = "Metallic Bright Purple",
|
||||
[60] = "Metallic Cream",
|
||||
[61] = "Metallic Ice White",
|
||||
[62] = "Metallic Frost White",
|
||||
[63] = "Metallic Saxon Blue",
|
||||
[64] = "Blue",
|
||||
[65] = "Mariner Blue",
|
||||
[66] = "Harbor Blue",
|
||||
[67] = "Diamond Blue",
|
||||
[68] = "Surf Blue",
|
||||
[69] = "Nautical Blue",
|
||||
[70] = "Ultra Blue",
|
||||
[71] = "Schafter Purple",
|
||||
[72] = "Spinnaker Purple",
|
||||
[73] = "Racing Blue",
|
||||
[74] = "Light Blue",
|
||||
[75] = "Util Dark Blue",
|
||||
[76] = "Util Midnight Blue",
|
||||
[77] = "Util Blue",
|
||||
[78] = "Util Sea Foam Blue",
|
||||
[79] = "Util Lightning blue",
|
||||
[80] = "Util Maui Blue Poly",
|
||||
[81] = "Util Bright Blue",
|
||||
[82] = "Matte Dark Blue",
|
||||
[83] = "Matte Blue",
|
||||
[84] = "Matte Midnight Blue",
|
||||
[85] = "Worn Dark blue",
|
||||
[86] = "Worn Blue",
|
||||
[87] = "Worn Light blue",
|
||||
[88] = "Metallic Taxi Yellow",
|
||||
[89] = "Metallic Race Yellow",
|
||||
[90] = "Metallic Bronze",
|
||||
[91] = "Metallic Yellow Bird",
|
||||
[92] = "Metallic Lime",
|
||||
[93] = "Metallic Champagne",
|
||||
[94] = "Metallic Pueblo Beige",
|
||||
[95] = "Metallic Dark Ivory",
|
||||
[96] = "Metallic Choco Brown",
|
||||
[97] = "Metallic Golden Brown",
|
||||
[98] = "Metallic Light Brown",
|
||||
[99] = "Metallic Straw Beige",
|
||||
[100] = "Metallic Moss Brown",
|
||||
[101] = "Metallic Biston Brown",
|
||||
[102] = "Metallic Beechwood",
|
||||
[103] = "Metallic Dark Beechwood",
|
||||
[104] = "Metallic Choco Orange",
|
||||
[105] = "Metallic Beach Sand",
|
||||
[106] = "Metallic Sun Bleeched Sand",
|
||||
[107] = "Metallic Cream",
|
||||
[108] = "Util Brown",
|
||||
[109] = "Util Medium Brown",
|
||||
[110] = "Util Light Brown",
|
||||
[111] = "Metallic White",
|
||||
[112] = "Metallic Frost White",
|
||||
[113] = "Worn Honey Beige",
|
||||
[114] = "Worn Brown",
|
||||
[115] = "Worn Dark Brown",
|
||||
[116] = "Worn straw beige",
|
||||
[117] = "Brushed Steel",
|
||||
[118] = "Brushed Black steel",
|
||||
[119] = "Brushed Aluminium",
|
||||
[120] = "Chrome",
|
||||
[121] = "Worn Off White",
|
||||
[122] = "Util Off White",
|
||||
[123] = "Worn Orange",
|
||||
[124] = "Worn Light Orange",
|
||||
[125] = "Metallic Securicor Green",
|
||||
[126] = "Worn Taxi Yellow",
|
||||
[127] = "police car blue",
|
||||
[128] = "Matte Green",
|
||||
[129] = "Matte Brown",
|
||||
[130] = "Worn Orange",
|
||||
[131] = "Matte White",
|
||||
[132] = "Worn White",
|
||||
[133] = "Worn Olive Army Green",
|
||||
[134] = "Pure White",
|
||||
[135] = "Hot Pink",
|
||||
[136] = "Salmon Pink",
|
||||
[137] = "Pfister Pink",
|
||||
[138] = "Bright Orange",
|
||||
[139] = "Red",
|
||||
[140] = "Dark Red",
|
||||
[141] = "Midnight Blue",
|
||||
[142] = "Midnight Purple",
|
||||
[143] = "Wine Red",
|
||||
[144] = "Matte Black",
|
||||
[145] = "Matte Gray",
|
||||
[146] = "Light Gray",
|
||||
[147] = "Util Black",
|
||||
[148] = "Util Silver",
|
||||
[149] = "Util Gun Metal",
|
||||
[150] = "Util Shadow Silver",
|
||||
[151] = "Worn Black",
|
||||
[152] = "Worn Graphite",
|
||||
[153] = "Worn Silver Grey",
|
||||
[154] = "Worn Silver",
|
||||
[155] = "Worn Blue Silver",
|
||||
[156] = "Worn Shadow Silver",
|
||||
[157] = "Metallic Red"
|
||||
|
||||
-- Add more colors as needed
|
||||
}
|
||||
|
||||
function GetVehicleColorName(vehicle)
|
||||
local primaryColor, _ = GetVehicleColours(vehicle)
|
||||
return colorNames[primaryColor] or "Unknown"
|
||||
end
|
||||
@@ -0,0 +1,152 @@
|
||||
local vehicleMakes = {
|
||||
["ADDER"] = "Truffade",
|
||||
["AIRBUS"] = "Jobuilt",
|
||||
["AIRTUG"] = "Stanley",
|
||||
["AKUMA"] = "Dinka",
|
||||
["ALPHA"] = "Albany",
|
||||
["AMBULANCE"] = "Brute",
|
||||
["ANNIHILATOR"] = "Nagasaki",
|
||||
["ARMYTANKER"] = "HVY",
|
||||
["ASEA"] = "Declasse",
|
||||
["ASTEROPE"] = "Karin",
|
||||
["BAGGER"] = "Western",
|
||||
["BALLER"] = "Gallivanter",
|
||||
["BANSHEE"] = "Bravado",
|
||||
["BARRACKS"] = "HVY",
|
||||
["BATI"] = "Pegassi",
|
||||
["BENSON"] = "Vapid",
|
||||
["BESRA"] = "Western",
|
||||
["BESTIAGTS"] = "Grotti",
|
||||
["BF400"] = "Nagasaki",
|
||||
["BFINJECTION"] = "BF",
|
||||
["BIFTA"] = "BF",
|
||||
["BISON"] = "Bravado",
|
||||
["BLAZER"] = "Nagasaki",
|
||||
["BLAZER3"] = "Nagasaki",
|
||||
["BLAZER4"] = "Nagasaki",
|
||||
["BLAZER5"] = "Nagasaki",
|
||||
["BLIMP"] = "Atomic",
|
||||
["BOBCATXL"] = "Vapid",
|
||||
["BODHI2"] = "Canis",
|
||||
["BOXVILLE"] = "Brute",
|
||||
["BRIOSO"] = "Grotti",
|
||||
["BTYPE"] = "Albany",
|
||||
["BUCCANEER"] = "Albany",
|
||||
["BUFFALO"] = "Bravado",
|
||||
["BULLET"] = "Vapid",
|
||||
["BURRITO"] = "Declasse",
|
||||
["BUS"] = "Brute",
|
||||
["CADDY"] = "Nagasaki",
|
||||
["CAMPER"] = "Brute",
|
||||
["CARBONIZZARE"] = "Grotti",
|
||||
["CARBONRS"] = "Nagasaki",
|
||||
["CAVALCADE"] = "Albany",
|
||||
["CHEETAH"] = "Grotti",
|
||||
["CHINO"] = "Vapid",
|
||||
["COGNOSCENTI"] = "Enus",
|
||||
["COMET"] = "Pfister",
|
||||
["COQUETTE"] = "Invetero",
|
||||
["CRUISER"] = "Bike",
|
||||
["CRUSADER"] = "Canis",
|
||||
["CUBAN800"] = "Western Company",
|
||||
["DILETTANTE"] = "Karin",
|
||||
["DOMINATOR"] = "Vapid",
|
||||
["DUKES"] = "Imponte",
|
||||
["DUMP"] = "HVY",
|
||||
["DUNE"] = "Nagasaki",
|
||||
["DUSTER"] = "Western Company",
|
||||
["ELEGY"] = "Annis",
|
||||
["EMPEROR"] = "Albany",
|
||||
["ENTITYXF"] = "Overflod",
|
||||
["EXEMPLAR"] = "Dewbauchee",
|
||||
["F620"] = "Ocelot",
|
||||
["FAGGIO"] = "Pegassi",
|
||||
["FELON"] = "Lampadati",
|
||||
["FELTZER"] = "Benefactor",
|
||||
["FIRETRUK"] = "MTL",
|
||||
["FORKLIFT"] = "HVY",
|
||||
["FQ2"] = "Fathom",
|
||||
["FUROREGT"] = "Lampadati",
|
||||
["FUGITIVE"] = "Cheval",
|
||||
["GAUNTLET"] = "Bravado",
|
||||
["HEXER"] = "LCC",
|
||||
["HOTKNIFE"] = "Vapid",
|
||||
["HUNTLEY"] = "Enus",
|
||||
["INFERNUS"] = "Pegassi",
|
||||
["INTRUDER"] = "Karin",
|
||||
["ISSI2"] = "Weeny",
|
||||
["JACKAL"] = "Ocelot",
|
||||
["JB700"] = "Dewbauchee",
|
||||
["JESTER"] = "Dinka",
|
||||
["KHAMELION"] = "Hijak",
|
||||
["KURUMA"] = "Karin",
|
||||
["LANDSTALKER"] = "Dundreary",
|
||||
["LURCHER"] = "Albany",
|
||||
["LUXOR"] = "Buckingham",
|
||||
["MAMBA"] = "Declasse",
|
||||
["MANANA"] = "Albany",
|
||||
["MASSACRO"] = "Dewbauchee",
|
||||
["MESA"] = "Canis",
|
||||
["MINIVAN"] = "Vapid",
|
||||
["MONROE"] = "Pegassi",
|
||||
["NEMESIS"] = "Principe",
|
||||
["NINEF"] = "Obey",
|
||||
["OMNIS"] = "Obey",
|
||||
["ORACLE"] = "Ubermacht",
|
||||
["OSIRIS"] = "Pegassi",
|
||||
["PATRIOT"] = "Mammoth",
|
||||
["PENUMBRA"] = "Maibatsu",
|
||||
["PEYOTE"] = "Vapid",
|
||||
["PHANTOM"] = "Jobuilt",
|
||||
["PHOENIX"] = "Imponte",
|
||||
["PICADOR"] = "Cheval",
|
||||
["PIGALLE"] = "Lampadati",
|
||||
["PRAIRIE"] = "Bollokan",
|
||||
["PRIMO"] = "Albany",
|
||||
["RADI"] = "Vapid",
|
||||
["RAPIDGT"] = "Dewbauchee",
|
||||
["REBEL"] = "Annis",
|
||||
["REGINA"] = "Dundreary",
|
||||
["RENTALBUS"] = "Dashound",
|
||||
["RUFFIAN"] = "Pegassi",
|
||||
["RUMPO"] = "Bravado",
|
||||
["SABREGT"] = "Declasse",
|
||||
["SADLER"] = "Vapid",
|
||||
["SANCHEZ"] = "Maibatsu",
|
||||
["SCHAFTER"] = "Benefactor",
|
||||
["SEASHARK"] = "Speedophile",
|
||||
["SENTINEL"] = "Ubermacht",
|
||||
["SERRANO"] = "Benefactor",
|
||||
["SLAMVAN"] = "Vapid",
|
||||
["SOVEREIGN"] = "Western",
|
||||
["SQUALO"] = "Shitzu",
|
||||
["STANIER"] = "Vapid",
|
||||
["STINGER"] = "Grotti",
|
||||
["STRATUM"] = "Zirconium",
|
||||
["STRETCH"] = "Dundreary",
|
||||
["SULTAN"] = "Karin",
|
||||
["SUPERD"] = "Enus",
|
||||
["SURANO"] = "Benefactor",
|
||||
["SURFER"] = "BF",
|
||||
["T20"] = "Progen",
|
||||
["TAMPA"] = "Declasse",
|
||||
["THRUST"] = "Dinka",
|
||||
["TORNADO"] = "Declasse",
|
||||
["TROPHYTRUCK"] = "Vapid",
|
||||
["TURISMOR"] = "Grotti",
|
||||
["VACCA"] = "Pegassi",
|
||||
["VIGERO"] = "Declasse",
|
||||
["VIRGO"] = "Albany",
|
||||
["VOODOO"] = "Declasse",
|
||||
["WASHINGTON"] = "Albany",
|
||||
["WINDSOR"] = "Enus",
|
||||
["ZENTORNO"] = "Pegassi",
|
||||
["ZION"] = "Ubermacht",
|
||||
["ZTYPE"] = "Truffade",
|
||||
-- Add more as needed
|
||||
}
|
||||
|
||||
|
||||
function GetVehicleMakeName(vehicleModelName)
|
||||
return vehicleMakes[vehicleModelName] or nil
|
||||
end
|
||||
@@ -0,0 +1 @@
|
||||
https://docs.imperialcad.app/api-and-integrations/fivem-installation
|
||||
@@ -0,0 +1,77 @@
|
||||
Config = {}
|
||||
|
||||
--This literally will just flood anything helpful for debugging, If your not debugging dont use it.
|
||||
Config.debug = false
|
||||
Config.DisableVersionCheck = false -- Why would you even do this? It disbales the version check on resource start
|
||||
|
||||
--Make it so the tablet only can be accessed inside of a emergency vehicle?
|
||||
Config.tabletCarRestriction = false
|
||||
|
||||
----QB Core Frame work, and its configuration - This is meant for base QBCore events, and functions.
|
||||
Config.isQB = false -- Vehicles, Characters
|
||||
Config.QBRegCurrent = false -- Literally will register a character when a previous is loaded (not created/deleted), as long as that unique citizen ID isnt already in the CAD.
|
||||
|
||||
--Nat2K15 Frame work, and its configuration
|
||||
Config.isNAT2K15 = false
|
||||
Config.resourceName = "framework"
|
||||
|
||||
----QBX Core Frame work, and its configuration - This is meant for base QBCore events, and functions.
|
||||
Config.isQBX = false
|
||||
|
||||
--ERS Integration / Support - Simply tells our ImperialCAD resource to listen for the ERS events and integrations. (This required the Advanced plan or higher)
|
||||
Config.ERSsupport = true
|
||||
Config.UseERSPulloverEnded = true -- This often results in premature call closes and isnt recommended, but if set to true we will close your current call if ERS says your pullover is ended.
|
||||
Config.UseERSCalloutEnded = true -- This may results in premature call closes, but if set to true we will close your current call if ERS says your callout has ended.
|
||||
Config.UseERSCalloutCompletedSuccesfully = true -- This may results in premature call closes, but if set to true we will close your current call if ERS says your callout was completed.
|
||||
Config.ImperialDutySync = true -- ImperialDuty will sync with the event ERS transmit based on shift toggles.
|
||||
|
||||
--Enable livemap support? (This requires a Premium plan)
|
||||
Config.livemap = true
|
||||
|
||||
--This will mark them off duty once they leave the game. (Requires a verfified discord ID, and they must be active within your community on the CAD)
|
||||
Config.cadkickonleave = true
|
||||
|
||||
--simply requires them to do /verify to ensure there discord ID matches a verified account within ImperialCAD
|
||||
Config.requireVerify = false -- NOT FINISHED
|
||||
|
||||
-- This will determine how often ImperialLocation will update each users current postal, city, and county for ImperialCAD API calls. (Only change this if you are experincing performance issues.)
|
||||
Config.locationFrequency = 2000
|
||||
|
||||
Config.DisableDutyCommand = false -- Enabling this basically just listens for its events to mark users duty for in-game notis and prevents our command from registering
|
||||
|
||||
Config.GiveLEOWeapons = true -- If you want to give weapons to the players who go on duty as LEO
|
||||
|
||||
Config.LEOWeapons = {
|
||||
"WEAPON_COMBATPISTOL",
|
||||
"WEAPON_STUNGUN",
|
||||
"WEAPON_NIGHTSTICK",
|
||||
"WEAPON_FLASHLIGHT",
|
||||
"WEAPON_CARBINERIFLE",
|
||||
"WEAPON_FIREEXTINGUISHER",
|
||||
"WEAPON_PUMPSHOTGUN"
|
||||
}
|
||||
|
||||
Config.GiveFIREWeapons = true -- If you want to give weapons to the players who go on duty as FIRE
|
||||
|
||||
Config.FIREWeapons = {
|
||||
"WEAPON_FIREEXTINGUISHER",
|
||||
}
|
||||
|
||||
Config.SendWebhook = false -- If you want to send a webhook when someone goes on/off duty
|
||||
|
||||
Config.WebhookURL = "https://elite-gaming.gg" -- Webhook URL
|
||||
|
||||
--Should these chat commands exist:
|
||||
Config.TsThroughChat = true
|
||||
Config.PlateThroughChat = true -- Allows users to run a plate using the /rplate command
|
||||
Config.AttachThroughChat = true
|
||||
Config.Allow911Command = true -- This will allow /a911 for Anonymous calls and /911 for normal calls that trys to send a caller based on active civ or username, if you dont need it, disable it.
|
||||
|
||||
--Should a radius style blip appear on the map for new 911 calls? (This works with ImperialDuty)
|
||||
Config.callBlip = true
|
||||
Config.callBlipDuration = 5 --In minutes
|
||||
|
||||
--Traffic Stop command Related config (This is useless if your "Config.TsThroughChat" is false)
|
||||
Config.trafficsnature = "Traffic Stop"
|
||||
Config.trafficspriority = "3"
|
||||
Config.trafficsstatus = "ACTIVE"
|
||||
@@ -0,0 +1,87 @@
|
||||
[
|
||||
{
|
||||
"city": "Vinewood",
|
||||
"x": 254.06,
|
||||
"y": 338.64
|
||||
},
|
||||
{
|
||||
"city": "Mirror Park",
|
||||
"x": 1174.81,
|
||||
"y": -532.5
|
||||
},
|
||||
{
|
||||
"city": "La Mesa",
|
||||
"x": 1063.63,
|
||||
"y": -1828.26
|
||||
},
|
||||
{
|
||||
"city": "La Puerta",
|
||||
"x": -642.25,
|
||||
"y": -2028.5
|
||||
},
|
||||
{
|
||||
"city": "Little Seoul",
|
||||
"x": -681.31,
|
||||
"y": -838.61
|
||||
},
|
||||
{
|
||||
"city": "Del Perro",
|
||||
"x": -1438.16,
|
||||
"y": -754.28
|
||||
},
|
||||
{
|
||||
"city": "Rockford",
|
||||
"x": -894.57,
|
||||
"y": -319.58
|
||||
},
|
||||
{
|
||||
"city": "Mount Chiliad",
|
||||
"x": 496.2,
|
||||
"y": 5585.61
|
||||
},
|
||||
{
|
||||
"city": "Mount Chiliad Wilderness",
|
||||
"x": -934.75,
|
||||
"y": 4841.97
|
||||
},
|
||||
{
|
||||
"city": "Mount Josiah",
|
||||
"x": -1207.62,
|
||||
"y": 3850.77
|
||||
},
|
||||
{
|
||||
"city": "Stab City",
|
||||
"x": 62.29,
|
||||
"y": 3684.16
|
||||
},
|
||||
{
|
||||
"city": "Harmony",
|
||||
"x": 285.86,
|
||||
"y": 2642.28
|
||||
},
|
||||
{
|
||||
"city": "San Chianski",
|
||||
"x": 3433.83,
|
||||
"y": 4167.18
|
||||
},
|
||||
{
|
||||
"city": "Grapeseed",
|
||||
"x": 2031.42,
|
||||
"y": 4917.24
|
||||
},
|
||||
{
|
||||
"city": "Sandy Shores",
|
||||
"x": 1829.39,
|
||||
"y": 3689.42
|
||||
},
|
||||
{
|
||||
"city": "Paleto Bay",
|
||||
"x": -177.71,
|
||||
"y": 6363
|
||||
},
|
||||
{
|
||||
"city": "Fort Zancudo",
|
||||
"x": -2188.65,
|
||||
"y": 3148.58
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"county": "Los Angeles County",
|
||||
"x": 147.96,
|
||||
"y": 2589.43
|
||||
},
|
||||
{
|
||||
"county": "Los Angeles County",
|
||||
"x": -404.79,
|
||||
"y": 1186.31
|
||||
},
|
||||
{
|
||||
"county": "Los Angeles County",
|
||||
"x": -317.87,
|
||||
"y": 8035.01
|
||||
}
|
||||
]
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,47 @@
|
||||
--[[
|
||||
Imperial Export for FiveM
|
||||
DO NOT EDIT THIS FILE UNLESS YOU KNOW WHAT YOUR DOING! Ripping or repurposing this script is not allowed.
|
||||
]]--
|
||||
|
||||
fx_version 'cerulean'
|
||||
game 'gta5'
|
||||
|
||||
author 'Zippy OFC'
|
||||
description 'Imperial CAD FiveM integration'
|
||||
version '1.2.4'
|
||||
|
||||
ui_page 'plugins/ImperialTablet/html/index.html'
|
||||
|
||||
server_script {
|
||||
'utils/imperialEmergency.lua',
|
||||
'utils/imperialCharacter.lua',
|
||||
'main/sv.lua',
|
||||
'utils/framework.lua',
|
||||
'utils/misc.lua',
|
||||
'plugins/**/sv_*.lua',
|
||||
'main/sv_calls.lua',
|
||||
--'plugins/**/sv_*.js',
|
||||
}
|
||||
|
||||
client_script {
|
||||
'main/cl.lua',
|
||||
--'plugins/**/cl_*.js',
|
||||
'plugins/**/cl_*.lua',
|
||||
'utils/cl_fw.lua'
|
||||
}
|
||||
|
||||
shared_script {
|
||||
'config.lua',
|
||||
'Library/colors.lua', -- Colors library (This list may require more colors!)
|
||||
'Library/vehicles.lua', -- vehicles library (Update addon vehicles as needed)
|
||||
'@ox_lib/init.lua',
|
||||
}
|
||||
|
||||
dependencies {
|
||||
'ox_lib'
|
||||
}
|
||||
|
||||
files {
|
||||
'plugins/ImperialTablet/html/index.html',
|
||||
'plugins/ImperialTablet/html/script.js',
|
||||
}
|
||||
@@ -0,0 +1,262 @@
|
||||
--[[
|
||||
Imperial Export for FiveM
|
||||
DO NOT EDIT THIS FILE UNLESS YOU KNOW WHAT YOUR DOING!
|
||||
]]--
|
||||
|
||||
local callTimer = 0
|
||||
local blips = {}
|
||||
local isPanic = false
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
Citizen.Wait(1000)
|
||||
if callTimer > 0 then
|
||||
callTimer = callTimer - 1
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
if Config.Allow911Command then
|
||||
TriggerEvent('chat:addSuggestion', '/911', 'Call Emergency Services', {
|
||||
{ name = "Information", help = "Description of your call." }
|
||||
})
|
||||
|
||||
RegisterCommand('911', function(source, args)
|
||||
local message = table.concat(args, " ")
|
||||
local playerPed = PlayerPedId()
|
||||
local coords = GetEntityCoords(playerPed)
|
||||
local streetHash, crossStreetHash = GetStreetNameAtCoord(coords.x, coords.y, coords.z)
|
||||
|
||||
local name = exports["ImperialCAD"]:GetStoredName()
|
||||
|
||||
if name == nil or name == "" then
|
||||
name = GetPlayerName(PlayerId())
|
||||
end
|
||||
|
||||
if message == nil or message == "" then
|
||||
Notify("You need to include the ~o~call information ~w~first before calling ~r~Emergency Services.")
|
||||
return
|
||||
end
|
||||
|
||||
if callTimer > 0 then
|
||||
Notify("You must wait ~o~" .. callTimer .. " seconds ~w~before calling ~r~emergency services ~w~again.")
|
||||
return
|
||||
end
|
||||
|
||||
local callData = {
|
||||
name = name,
|
||||
street = GetStreetNameFromHashKey(streetHash),
|
||||
crossStreet = GetStreetNameFromHashKey(crossStreetHash) or "N/A",
|
||||
postal = GetImperialPostal(),
|
||||
city = GetImperialCity(),
|
||||
county = GetImperialCounty(),
|
||||
info = message,
|
||||
coords = coords
|
||||
}
|
||||
|
||||
TriggerServerEvent('ImperialCAD:New911', callData)
|
||||
|
||||
end, false)
|
||||
|
||||
TriggerEvent('chat:addSuggestion', '/a911', 'Call Emergency Services but Anonymously', {
|
||||
{ name = "Information", help = "Description of your call." }
|
||||
})
|
||||
|
||||
RegisterCommand('a911', function(source, args)
|
||||
local message = table.concat(args, " ")
|
||||
local playerPed = PlayerPedId()
|
||||
local coords = GetEntityCoords(playerPed)
|
||||
local streetHash, crossStreetHash = GetStreetNameAtCoord(coords.x, coords.y, coords.z)
|
||||
|
||||
if message == nil or message == "" then
|
||||
Notify("You need to include the ~o~call information ~w~first before calling ~r~Emergency Services.")
|
||||
return
|
||||
end
|
||||
|
||||
if callTimer > 0 then
|
||||
Notify("You must wait ~o~" .. callTimer .. " seconds ~w~before calling ~r~emergency services ~w~again.")
|
||||
return
|
||||
end
|
||||
|
||||
local callData = {
|
||||
name = "Anonymous Caller",
|
||||
street = GetStreetNameFromHashKey(streetHash),
|
||||
crossStreet = GetStreetNameFromHashKey(crossStreetHash) or "N/A",
|
||||
postal = GetImperialPostal(),
|
||||
city = GetImperialCity(),
|
||||
county = GetImperialCounty(),
|
||||
info = message,
|
||||
coords = coords
|
||||
}
|
||||
|
||||
TriggerServerEvent('ImperialCAD:New911', callData)
|
||||
|
||||
end, false)
|
||||
|
||||
end
|
||||
|
||||
if Config.PlateThroughChat then
|
||||
|
||||
TriggerEvent('chat:addSuggestion', '/rplate', 'Run vehicle plate', {
|
||||
{ name = "plate", help = "the plate to search" }
|
||||
})
|
||||
|
||||
RegisterCommand('rplate', function(source, args, rawCommand)
|
||||
local plate = table.concat(args, " ")
|
||||
|
||||
if plate == nil or plate == "" then
|
||||
print('plate not in command')
|
||||
TriggerEvent('ox_lib:alertDialog', {
|
||||
header = "No Last Idea",
|
||||
content = "There is no last idea stored.",
|
||||
centered = true,
|
||||
cancel = false,
|
||||
size = 'md'
|
||||
})
|
||||
return
|
||||
end
|
||||
|
||||
local callData = {
|
||||
plate = plate
|
||||
}
|
||||
|
||||
if Config.debug then
|
||||
print("[Rplate] Sending a plate check to the server side.")
|
||||
end
|
||||
|
||||
TriggerServerEvent('ImperialCAD:CheckPlate', callData)
|
||||
print("[Rplate] Sent a plate check to the server side.")
|
||||
end, false)
|
||||
end
|
||||
|
||||
RegisterCommand('panic', function()
|
||||
|
||||
local playerPed = PlayerPedId()
|
||||
local coords = GetEntityCoords(playerPed)
|
||||
local streetHash, crossStreetHash = GetStreetNameAtCoord(coords.x, coords.y, coords.z)
|
||||
|
||||
local callData = {
|
||||
postal = GetImperialPostal(),
|
||||
street = GetStreetNameFromHashKey(streetHash)
|
||||
}
|
||||
|
||||
if isPanic then
|
||||
isPanic = false
|
||||
|
||||
print("[Imperial-Panic] Clearing panic, Panic was true")
|
||||
|
||||
TriggerServerEvent('ImperialCAD:ClearPanic', callData)
|
||||
else
|
||||
isPanic = true
|
||||
|
||||
print("[Imperial-Panic] Triggering panic, Panic was false")
|
||||
|
||||
TriggerServerEvent('ImperialCAD:Panic', callData)
|
||||
end
|
||||
end, false)
|
||||
|
||||
if Config.TsThroughChat then
|
||||
|
||||
TriggerEvent('chat:addSuggestion', '/ts', 'Create a traffic stop in ImperialCAD', {
|
||||
{ name = "Information", help = "Description of your traffic stop." }
|
||||
})
|
||||
|
||||
RegisterCommand('ts', function(source, args, rawCommand)
|
||||
local message = table.concat(args, " ")
|
||||
local playerPed = PlayerPedId()
|
||||
local coords = GetEntityCoords(playerPed)
|
||||
local streetHash, crossStreetHash = GetStreetNameAtCoord(coords.x, coords.y, coords.z)
|
||||
|
||||
|
||||
if message == "" then
|
||||
message = "Traffic Stop Initiated"
|
||||
end
|
||||
|
||||
local callData = {
|
||||
street = GetStreetNameFromHashKey(streetHash),
|
||||
cross_street = GetStreetNameFromHashKey(crossStreetHash),
|
||||
postal = GetImperialPostal(),
|
||||
city = GetImperialCity(),
|
||||
county = GetImperialCounty(),
|
||||
info = message
|
||||
}
|
||||
|
||||
TriggerServerEvent('ImperialCAD:TrafficStop', callData)
|
||||
end, false)
|
||||
end
|
||||
|
||||
if Config.AttachThroughChat then
|
||||
TriggerEvent('chat:addSuggestion', '/attach', 'Attach to a ImperialCAD call', {
|
||||
{ name = "callnum", help = "Call number to attach" }
|
||||
})
|
||||
|
||||
RegisterCommand('attach', function(source, args, rawCommand)
|
||||
local message = args[1]
|
||||
|
||||
local callData = {
|
||||
callnum = message
|
||||
}
|
||||
|
||||
TriggerServerEvent('ImperialCAD:AttachCall', callData)
|
||||
end, false)
|
||||
end
|
||||
|
||||
RegisterNetEvent("ImperialCAD:Client:Notify")
|
||||
AddEventHandler("ImperialCAD:Client:Notify", function(messages)
|
||||
Notify(messages)
|
||||
end)
|
||||
|
||||
function Notify(message)
|
||||
local fullMessage = "[IMPERIAL] " .. message
|
||||
BeginTextCommandThefeedPost("STRING");
|
||||
AddTextComponentSubstringPlayerName(fullMessage);
|
||||
EndTextCommandThefeedPostMessagetext("CHAR_CALL911", "CHAR_CALL911", true, 1, "Imperial911", "Emergency Services");
|
||||
end
|
||||
|
||||
RegisterNetEvent("Imperial:911BlipForOnduty")
|
||||
AddEventHandler("Imperial:911BlipForOnduty", function(coords)
|
||||
local name = GetPlayerName(PlayerId())
|
||||
local blipId = math.random(100000, 999999)
|
||||
local offsetX = math.random(-50, 50)
|
||||
local offsetY = math.random(-50, 50)
|
||||
|
||||
local newX = coords.x + offsetX
|
||||
local newY = coords.y + offsetY
|
||||
|
||||
local radiusBlip = AddBlipForRadius(newX, newY, coords.z, 500.0)
|
||||
SetBlipHighDetail(radiusBlip, true)
|
||||
SetBlipColour(radiusBlip, 1)
|
||||
SetBlipAlpha(radiusBlip, 128)
|
||||
SetBlipSprite(radiusBlip, 3)
|
||||
|
||||
local coordBlip = AddBlipForCoord(newX, newY, coords.z)
|
||||
SetBlipSprite(coordBlip, 2)
|
||||
SetBlipDisplay(coordBlip, 2)
|
||||
SetBlipScale(coordBlip, 0.8)
|
||||
SetBlipColour(coordBlip, 1)
|
||||
SetBlipAsShortRange(coordBlip, true)
|
||||
|
||||
BeginTextCommandSetBlipName("STRING")
|
||||
AddTextComponentString("911 - " .. name )
|
||||
EndTextCommandSetBlipName(coordBlip)
|
||||
|
||||
blips[blipId] = {radiusBlip = radiusBlip, coordBlip = coordBlip, x = newX, y = newY, z = coords.z}
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
Citizen.Wait(Config.callBlipDuration * 60000)
|
||||
if blips[blipId] then
|
||||
if blips[blipId].radiusBlip then RemoveBlip(blips[blipId].radiusBlip) end
|
||||
if blips[blipId].coordBlip then RemoveBlip(blips[blipId].coordBlip) end
|
||||
blips[blipId] = nil
|
||||
if Config.debug then print("Blip ID " .. blipId .. " has been automatically removed after 5 minutes.") end
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
lib.callback.register('ImperialCAD:getNearestStreets', function(coords)
|
||||
local streetHash, crossStreetHash = GetStreetNameAtCoord(coords.x, coords.y, coords.z)
|
||||
local street = GetStreetNameFromHashKey(streetHash)
|
||||
local crossStreet = GetStreetNameFromHashKey(crossStreetHash)
|
||||
local response = {street = street, crossStreet = crossStreet}
|
||||
return response
|
||||
end)
|
||||
@@ -0,0 +1,509 @@
|
||||
--[[
|
||||
Imperial Export for FiveM
|
||||
DO NOT EDIT THIS FILE UNLESS YOU KNOW WHAT YOUR DOING!
|
||||
]]--
|
||||
|
||||
local function getVersionFromManifest()
|
||||
local path = GetResourcePath(GetCurrentResourceName()) .. '/fxmanifest.lua'
|
||||
local file = io.open(path, "r")
|
||||
if file then
|
||||
local content = file:read("*a")
|
||||
file:close()
|
||||
|
||||
for line in string.gmatch(content, "[^\r\n]+") do
|
||||
local value = string.match(line, "^version%s+'(.+)'$")
|
||||
if value then
|
||||
return value
|
||||
end
|
||||
end
|
||||
end
|
||||
return 'unknown'
|
||||
end
|
||||
|
||||
local versionUrl = 'https://raw.githubusercontent.com/Zippy01/ImperialCAD/main/version.json'
|
||||
local latestVersion = "0.0.0.0"
|
||||
|
||||
local function checkForUpdates()
|
||||
local currentVersion = getVersionFromManifest()
|
||||
local debugMode = Config.debug and "^2Enabled^7" or "^1Disabled^7"
|
||||
|
||||
local function checkConvarStatus(name)
|
||||
local value = GetConvar(name, "")
|
||||
if not value or value == "" then
|
||||
return "^1Missing^7"
|
||||
elseif #value < 15 then
|
||||
return "^3Present (Possibly Invalid)^7"
|
||||
else
|
||||
return "^2Present (Appears Valid)^7"
|
||||
end
|
||||
end
|
||||
|
||||
local commIdStatus = checkConvarStatus("imperial_community_id")
|
||||
local apiKeyStatus = checkConvarStatus("imperialAPI")
|
||||
|
||||
PerformHttpRequest(versionUrl, function(err, responseText, headers)
|
||||
local status = "Unknown"
|
||||
local updateAvailable = false
|
||||
local latest = "Unknown"
|
||||
|
||||
if err == 200 and responseText and responseText:match("{") then
|
||||
local success, data = pcall(json.decode, responseText)
|
||||
if success and data and data.latestVersion then
|
||||
latestVersion = data.latestVersion
|
||||
latest = latestVersion
|
||||
|
||||
if latestVersion ~= currentVersion then
|
||||
status = "^1Update Available^7"
|
||||
updateAvailable = true
|
||||
else
|
||||
status = "^2Up to Date^7"
|
||||
end
|
||||
else
|
||||
status = "^3Version Check Failed^7"
|
||||
end
|
||||
else
|
||||
status = "^1Failed to Reach Update Server^7"
|
||||
end
|
||||
|
||||
print("\n^4=======================[ ImperialCAD ]=======================^7")
|
||||
print(" ^5Current Version:^7 " .. currentVersion)
|
||||
print(" ^5Latest Version:^7 " .. latest)
|
||||
print(" ^5Update Status:^7 " .. status)
|
||||
print(" ^5Debug Mode:^7 " .. debugMode)
|
||||
print(" ^5Community ID:^7 " .. commIdStatus)
|
||||
print(" ^5API Key:^7 " .. apiKeyStatus)
|
||||
print("^4============================================================\n^7")
|
||||
|
||||
if updateAvailable then
|
||||
print("^3[ImperialCAD]^7 Visit ^4https://github.com/Zippy01/ImperialCAD^7 to download the latest version.")
|
||||
end
|
||||
end, 'GET', '')
|
||||
end
|
||||
|
||||
AddEventHandler('onResourceStart', function(resourceName)
|
||||
if resourceName ~= GetCurrentResourceName() then return end
|
||||
|
||||
if GetCurrentResourceName() ~= "ImperialCAD" then
|
||||
print("[^1ImperialCAD^7] Invalid script name. This script MUST be named ^3'ImperialCAD'^7 to work properly!")
|
||||
return
|
||||
end
|
||||
|
||||
print('[ImperialCAD] Hello World!')
|
||||
|
||||
if Config.DisableVersionCheck then return end
|
||||
|
||||
Wait(5000)
|
||||
checkForUpdates()
|
||||
end)
|
||||
|
||||
if Config.cadkickonleave then
|
||||
AddEventHandler('playerDropped', function(reason, resourceName, clientDropReason)
|
||||
local playerName = GetPlayerName(source)
|
||||
print('Player' .. playerName .. ' dropped, telling ImperialCAD to cleanup')
|
||||
|
||||
local discordId = getDiscordId(source)
|
||||
if not discordId then
|
||||
print("^3[WARN]^7 Discord ID not found for " .. playerName .. "Cannot attempt cleanup")
|
||||
else
|
||||
if Config.debug then
|
||||
print("Attempting to mark "..playerName.." off duty in cad, using the discord id "..discordId)
|
||||
end
|
||||
|
||||
exports["ImperialCAD"]:Booter({
|
||||
users_discordID = discordId
|
||||
}, function(success, resultData)
|
||||
if success then
|
||||
local apires = json.decode(resultData)
|
||||
if Config.debug then
|
||||
print("[ImperialCleanup] Player was successfully marked off duty, and cleaned up in the CAD")
|
||||
end
|
||||
else
|
||||
if Config.debug then
|
||||
print("[ImperialCleanup] Unable to mark user off duty, This player might not be logged in")
|
||||
end
|
||||
end
|
||||
end)
|
||||
end end)
|
||||
end
|
||||
|
||||
RegisterNetEvent('ImperialCAD:New911')
|
||||
AddEventHandler('ImperialCAD:New911', function(callData)
|
||||
|
||||
if not callData.name or not callData.street or not callData.crossStreet or not callData.postal or not callData.info then
|
||||
print("[Imperial911] Missing required call data to create a new 911 call, Will not create.")
|
||||
return
|
||||
end
|
||||
local player = source
|
||||
local coords = callData.coords
|
||||
|
||||
exports["ImperialCAD"]:Create911Call({
|
||||
name = callData.name,
|
||||
street = callData.street,
|
||||
crossStreet = callData.crossStreet,
|
||||
info = callData.info,
|
||||
postal = callData.postal,
|
||||
city = callData.city,
|
||||
county = callData.county
|
||||
}, function(success, resultData)
|
||||
if success then
|
||||
local apires = json.decode(resultData)
|
||||
if not apires or not apires.response or not apires.response.callId then
|
||||
print("^1[API_ERROR]^7 Invalid response or call ID not found")
|
||||
return false
|
||||
end
|
||||
|
||||
local callNum = apires.response.callnum
|
||||
print("[Imperial911] 911 Call was successfully created")
|
||||
|
||||
TriggerEvent('Imperial:911ChatMessage', callData.name, callData.street, callData.info, callData.crossStreet, callData.postal, callNum)
|
||||
|
||||
if Config.callBlip then
|
||||
TriggerEvent("ImperialCAD:911Blip", coords)
|
||||
end
|
||||
|
||||
TriggerClientEvent('ImperialCAD:Client:Notify', player, "Your call was successfully sent to emergency services.")
|
||||
|
||||
else
|
||||
|
||||
TriggerClientEvent('ImperialCAD:Client:Notify', player, "Looks like dispatch is having trouble, We let officers know tho.")
|
||||
TriggerEvent('Imperial:911ChatMessage', callData.name, callData.street, callData.info, callData.crossStreet, callData.postal)
|
||||
if Config.callBlip then
|
||||
TriggerEvent("ImperialCAD:911Blip", coords)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
function Notify(message, playerId)
|
||||
if playerId and message then
|
||||
if Config.debug then print("[ImperialCAD] Trying to notify player: "..playerId) end
|
||||
TriggerClientEvent('chat:addMessage', playerId, {
|
||||
color = {255, 0, 0},
|
||||
multiline = true,
|
||||
args = {"ImperialCAD", message}
|
||||
})
|
||||
elseif not message then
|
||||
print("[IMPERIAL_SV_NOTIFY] No message provided")
|
||||
elseif not playerId then
|
||||
print("[IMPERIAL_SV_NOTIFY] No playerId provided")
|
||||
else
|
||||
print("[IMPERIAL_SV_NOTIFY] Couldnt send message")
|
||||
end
|
||||
end
|
||||
|
||||
if Config.PlateThroughChat then
|
||||
RegisterNetEvent('ImperialCAD:CheckPlate')
|
||||
AddEventHandler('ImperialCAD:CheckPlate', function(callData)
|
||||
local src = source
|
||||
|
||||
if Config.debug then
|
||||
print("[ImperialRplate] Checking plate: " .. callData.plate.." on the server side")
|
||||
end
|
||||
|
||||
if not callData.plate then
|
||||
print("[ImperialRplate] Request made without plate, killing early")
|
||||
return
|
||||
end
|
||||
|
||||
exports["ImperialCAD"]:CheckPlate({
|
||||
plate = callData.plate
|
||||
}, function(success, resultData)
|
||||
if not success or not resultData then
|
||||
Notify(""..callData.plate.." Was ran without a successful result, is it registered?", src)
|
||||
end
|
||||
|
||||
local data = json.decode(resultData)
|
||||
if not data then
|
||||
print("[ImperialRplate] Invalid API response, Killing early")
|
||||
return
|
||||
end
|
||||
|
||||
local response = data.response
|
||||
local messages = {}
|
||||
|
||||
if success and resultData then
|
||||
Notify("The following flags/alerts where found for plate: " .. response.plate, src) -- @TODO
|
||||
end
|
||||
|
||||
if not success or not resultData then
|
||||
table.insert(messages, "Could not find vehicle with the plate: "..callData.plate)
|
||||
end
|
||||
|
||||
if success then -- If api returns success then check the actual return
|
||||
|
||||
if response.stolen then
|
||||
table.insert(messages, "Stolen Vehicle")
|
||||
end
|
||||
|
||||
if not response.insurance then
|
||||
table.insert(messages, "No Insurance")
|
||||
end
|
||||
|
||||
if response.insurance and response.insurance_status ~= "ACTIVE" then
|
||||
table.insert(messages, "Invalid Insurance")
|
||||
end
|
||||
|
||||
if response.business then
|
||||
table.insert(messages, "Commercial Vehicle")
|
||||
end
|
||||
|
||||
if response.reg_status ~= "ACTIVE" then
|
||||
table.insert(messages, "Invalid Vehicle registration")
|
||||
end
|
||||
|
||||
if response.owner_wanted then
|
||||
table.insert(messages, "Owner Wanted")
|
||||
end
|
||||
|
||||
if response.owner_dl_status ~= "ACTIVE" then
|
||||
table.insert(messages, "Invalid license")
|
||||
end
|
||||
|
||||
end -- end of the addtional checks
|
||||
|
||||
if #messages > 0 then
|
||||
print("It should work btw "..src)
|
||||
TriggerClientEvent('ImperialCAD:Client:Notify', src, json.encode(messages))
|
||||
end
|
||||
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
RegisterNetEvent('ImperialCAD:TrafficStop')
|
||||
AddEventHandler('ImperialCAD:TrafficStop', function(callData)
|
||||
local player = source
|
||||
|
||||
exports["ImperialCAD"]:CreateCall({
|
||||
users_discordID = getDiscordId(source),
|
||||
street = callData.street,
|
||||
cross_street = callData.crossStreet,
|
||||
postal = callData.postal,
|
||||
city = callData.city,
|
||||
county = callData.county,
|
||||
info = callData.info,
|
||||
nature = Config.trafficsnature,
|
||||
status = Config.trafficsstatus,
|
||||
priority = Config.trafficspriority
|
||||
}, function(success, resultData)
|
||||
if success then
|
||||
local apires = json.decode(resultData)
|
||||
if not apires or not apires.response or not apires.response.callId then
|
||||
if Config.debug then print("^1[ERROR]^7 Invalid response or call ID not found") end
|
||||
Notify("[TS] Unable to create traffic stop", player)
|
||||
return
|
||||
end
|
||||
local callnum = apires.response.callnum
|
||||
if Config.debug then print("Traffic Stop created successfully: Call ID -", callnum) end
|
||||
Notify("[TS] Traffic stop created succesfully, Call Number: "..callnum, player)
|
||||
else
|
||||
Notify("[TS] Unable to create traffic stop", player)
|
||||
print(resultData)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('ImperialCAD:AttachCall')
|
||||
AddEventHandler('ImperialCAD:AttachCall', function(callData)
|
||||
local player = source
|
||||
exports["ImperialCAD"]:AttachCall({
|
||||
users_discordID = getDiscordId(source),
|
||||
callnum = callData.callnum
|
||||
}, function(success, resultData)
|
||||
local result = json.decode(resultData)
|
||||
local status = result.status
|
||||
local message = result.message
|
||||
local response = result.response
|
||||
|
||||
if success and status ~= "success" then success = false end
|
||||
|
||||
if status == "NOT_RUN" then
|
||||
status = "Unkown error and status"
|
||||
elseif status == "BUSY" then
|
||||
status = "You must be on duty and available to accept new calls"
|
||||
elseif status == "NoSelfDisp" then
|
||||
status = "Disptach has marked emergency calls as dispatch only, Please check your cad or reference dispatch"
|
||||
end
|
||||
|
||||
if not success then
|
||||
Notify(string.format("[Attach] Unable to attach you, reason: %s", status), player)
|
||||
elseif success then
|
||||
Notify("[Attach] Attached to call number "..response.callnum, player)
|
||||
elseif not success and Config.debug then
|
||||
Notify(string.format("[Attach - Debug] Unable to attach you, Status: %s | Reason: %", status, message), player)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('ImperialCAD:CloseCall')
|
||||
AddEventHandler('ImperialCAD:CloseCall', function(callData)
|
||||
|
||||
exports["ImperialCAD"]:DeleteCall({
|
||||
discordid = getDiscordId(source),
|
||||
callId = callData.callId,
|
||||
}, function(success, resultData)
|
||||
end)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('ImperialCAD:Panic')
|
||||
AddEventHandler('ImperialCAD:Panic', function(callData)
|
||||
|
||||
exports["ImperialCAD"]:Panic({
|
||||
users_discordID = getDiscordId(source),
|
||||
postal = callData.postal,
|
||||
street = callData.street
|
||||
}, function(success, resultData)
|
||||
if success then
|
||||
print("Panic was triggered")
|
||||
else
|
||||
print("Unable to trigger panic")
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('ImperialCAD:ClearPanic')
|
||||
AddEventHandler('ImperialCAD:ClearPanic', function()
|
||||
|
||||
exports["ImperialCAD"]:ClearPanic(function(success, resultData)
|
||||
if success then
|
||||
print("Panic was cleared")
|
||||
else
|
||||
print("Unable to clear community panic")
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
RegisterNetEvent("ImperialCAD:Server:NewNotify")
|
||||
AddEventHandler("ImperialCAD:Server:NewNotify", function(callData)
|
||||
|
||||
local d = callData or {}
|
||||
if not d then print("ImperialCAD Could not create a new dispatch, No callData was found. Returning early") return false end
|
||||
local street = d.street or "Unknown"
|
||||
local crossStreet = d.crossStreet or "N/A"
|
||||
local postal = d.postal or "00000"
|
||||
local city = d.city or "N/A"
|
||||
local county = d.county or "N/A"
|
||||
local nature = d.nature or "No Nature Provided"
|
||||
local status = d.status or "ACTIVE"
|
||||
local priority = d.priority or 2
|
||||
if not d.cords or d.cords == "" then
|
||||
print("ImperialCAD Could not create a new dispatch, No cords were found. Returning early")
|
||||
return false
|
||||
end
|
||||
local cords = d.cords
|
||||
local message = d.message or "No information provided"
|
||||
local cmessage = d.cmessage or "No Information provided"
|
||||
local job = d.job or "Unknown"
|
||||
|
||||
exports["ImperialCAD"]:CreateCall({
|
||||
users_discordID = "",
|
||||
street = street,
|
||||
crossStreet = crossStreet,
|
||||
postal = postal,
|
||||
city = city,
|
||||
county = county,
|
||||
info = message,
|
||||
nature = nature,
|
||||
status = status,
|
||||
priority = priority
|
||||
}, function(success, resultData)
|
||||
if success then
|
||||
local apires = json.decode(resultData)
|
||||
if not apires or not apires.response or not apires.response.callId then
|
||||
print("^1[API_ERROR]^7 Invalid response or call ID not found")
|
||||
return false
|
||||
end
|
||||
|
||||
local callNum = apires.response.callnum
|
||||
print("New Dispatch CAD Call created successfully: Call ID -", callNum)
|
||||
|
||||
local chatMessage = {
|
||||
multiline = true,
|
||||
args = {
|
||||
"^8(ImperialCAD - New Call For Service)",
|
||||
"^7\nPostal: ^3" .. postal ..
|
||||
"^7\nStreet: ^3" .. street ..
|
||||
"^7\nCross Street: ^3" .. crossStreet ..
|
||||
"^7\nInformation: ^3" .. cmessage ..
|
||||
"^7\nCall Number: ^3" .. callNum
|
||||
}
|
||||
}
|
||||
|
||||
local successDuty, onDutyUnits = pcall(function()
|
||||
if job == "LEO" then
|
||||
return exports["ImperialCAD"]:GetOnDutyLEOUnits()
|
||||
elseif job == "FIRE" then
|
||||
return exports["ImperialCAD"]:GetOnDutyFireUnits()
|
||||
else
|
||||
return exports["ImperialCAD"]:GetOnDutyUnits()
|
||||
end
|
||||
end)
|
||||
|
||||
if successDuty and onDutyUnits then
|
||||
for _, playerId in ipairs(onDutyUnits) do
|
||||
TriggerClientEvent("chat:addMessage", playerId, chatMessage)
|
||||
TriggerClientEvent("Imperial:911BlipForOnduty", playerId, cords)
|
||||
end
|
||||
if Config.debug then print("Blips and messages sent to on-duty units.") end
|
||||
else
|
||||
TriggerClientEvent("chat:addMessage", -1, chatMessage)
|
||||
if Config.debug then print("Duty unit fetch failed. Message sent to all.") end
|
||||
end
|
||||
|
||||
else
|
||||
print("New Imperial Dispatch call failed: "..resultData)
|
||||
end
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
|
||||
RegisterNetEvent("Imperial:911ChatMessage")
|
||||
AddEventHandler("Imperial:911ChatMessage", function(name, street, message, crossStreet, postal, callNum)
|
||||
if not callNum then callNum = "ERROR" end
|
||||
local chatMessage = {
|
||||
multiline = true,
|
||||
args = {"^8(ImperialCAD - New Call For Service)",
|
||||
"\nName: ^3" .. name .. "^7\nPostal: ^3" .. postal .. "^7\nStreet: ^3" .. street ..
|
||||
"^7\nCross Street: ^3" .. crossStreet .. "^7\nInformation: ^3" .. message .. "^7\nCall Number: ^3" .. callNum
|
||||
}
|
||||
}
|
||||
|
||||
local success, onDutyUnits = pcall(function()
|
||||
return exports["ImperialCAD"]:GetOnDutyUnits()
|
||||
end)
|
||||
|
||||
if success and onDutyUnits then
|
||||
for _, playerId in ipairs(onDutyUnits) do
|
||||
TriggerClientEvent("chat:addMessage", playerId, chatMessage)
|
||||
end
|
||||
else
|
||||
TriggerClientEvent("chat:addMessage", -1, chatMessage)
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent("ImperialCAD:911Blip")
|
||||
AddEventHandler("ImperialCAD:911Blip", function(coords)
|
||||
|
||||
local success, OnDutyUnitsFound = pcall(function()
|
||||
return exports["ImperialCAD"]:GetOnDutyUnits()
|
||||
end)
|
||||
|
||||
if success then
|
||||
for _, playerId in ipairs(OnDutyUnitsFound) do
|
||||
|
||||
if Config.debug then
|
||||
print("We found ImperialDuty, Proceeding with blips")
|
||||
end
|
||||
|
||||
TriggerClientEvent("Imperial:911BlipForOnduty", playerId, coords)
|
||||
end
|
||||
else
|
||||
|
||||
if Config.debug then
|
||||
print("Couldnt find ImperialDuty, proceeding without blip.")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end)
|
||||
@@ -0,0 +1,34 @@
|
||||
callsBySrc = {} -- { [src] = callNo }
|
||||
|
||||
local function _asNumberOrString(v)
|
||||
return tonumber(v) or v
|
||||
end
|
||||
|
||||
function addCall(src, callNo)
|
||||
if Config.debug then print('Adding call num: '..callNo..' to player: '..src) end
|
||||
callNo = _asNumberOrString(callNo)
|
||||
if not callNo then return false end
|
||||
callsBySrc[src] = callNo
|
||||
return true
|
||||
end
|
||||
|
||||
function getCall(src)
|
||||
return callsBySrc[src] or nil
|
||||
end
|
||||
|
||||
function removeCall(src)
|
||||
if Config.deubg then print('[ImperialCAD_calls] Removing call '..callsBySrc[src]..' from player '..src) end
|
||||
callsBySrc[src] = nil
|
||||
end
|
||||
|
||||
AddEventHandler('playerDropped', function()
|
||||
if Config.deubg then print('[ImperialCAD_calls] Player dropped, clearing last stored call') end
|
||||
callsBySrc[source] = nil
|
||||
end)
|
||||
|
||||
--[[ I may make this a thing later on..
|
||||
exports('AddCallForSource', addCall)
|
||||
exports('GetCallForSource', getCall)
|
||||
exports('GetLastCallForSource', getLastCall)
|
||||
exports('RemoveCallForSource', removeCall)
|
||||
]]
|
||||
@@ -0,0 +1,122 @@
|
||||
local communityid = GetConvar("imperial_community_id", "")
|
||||
|
||||
local function Notify(message)
|
||||
local fullMessage = "[IMPERIAL] " .. message
|
||||
SetNotificationTextEntry("STRING")
|
||||
AddTextComponentString(fullMessage)
|
||||
DrawNotification(false, true)
|
||||
end
|
||||
|
||||
AddEventHandler('playerSpawned', function()
|
||||
local ssn = GetResourceKvpString("civ_ssn")
|
||||
local name = GetResourceKvpString("civ_name")
|
||||
local age = GetResourceKvpString("civ_age")
|
||||
local address = GetResourceKvpString("civ_address")
|
||||
local commId = GetResourceKvpString("commId")
|
||||
|
||||
if (ssn and #ssn > 8) and name and age and address and (commId == communityid) then
|
||||
Notify("Your active civilian profile: " .. name)
|
||||
else
|
||||
Notify("You do not have an active civilian profile. Use /setciv to set one.")
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent("ImperialCAD:setActiveCiv")
|
||||
AddEventHandler("ImperialCAD:setActiveCiv", function(data)
|
||||
if data.ssn then
|
||||
SetResourceKvp("civ_ssn", data.ssn)
|
||||
SetResourceKvp("civ_name", data.name)
|
||||
SetResourceKvp("civ_age", data.age)
|
||||
SetResourceKvp("civ_address", data.address)
|
||||
SetResourceKvp("commId", communityid)
|
||||
|
||||
Notify("Civilian profile activated: " .. data.name)
|
||||
else
|
||||
Notify("Data reception error. Please check server logs.")
|
||||
DeleteResourceKvp("civ_ssn")
|
||||
DeleteResourceKvp("civ_name")
|
||||
DeleteResourceKvp("civ_age")
|
||||
DeleteResourceKvp("civ_address")
|
||||
DeleteResourceKvp("commId")
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterCommand("setciv", function(source, args, rawCommand)
|
||||
local ssn = args[1]
|
||||
if ssn and #ssn > 8 then
|
||||
TriggerServerEvent("ImperialCAD:getCivData", ssn)
|
||||
else
|
||||
Notify("Invalid SSN provided, Please check and try again.")
|
||||
end
|
||||
end, false)
|
||||
|
||||
RegisterCommand("getciv", function(source, args, rawCommand)
|
||||
local name = GetResourceKvpString("civ_name")
|
||||
local age = GetResourceKvpString("civ_age")
|
||||
local commId = GetResourceKvpString("commId")
|
||||
|
||||
if name and age then
|
||||
Notify("Current Civilian: Name - " .. name .. ", Age - " .. age .. ", Community ID - " .. commId)
|
||||
else
|
||||
Notify("No active civilian profile.")
|
||||
end
|
||||
end, false)
|
||||
|
||||
RegisterCommand("clearciv", function(source, args, rawCommand)
|
||||
DeleteResourceKvp("civ_ssn")
|
||||
DeleteResourceKvp("civ_name")
|
||||
DeleteResourceKvp("civ_age")
|
||||
DeleteResourceKvp("civ_address")
|
||||
DeleteResourceKvp("commId")
|
||||
|
||||
Notify("Active civilian profile has been cleared.")
|
||||
end, false)
|
||||
|
||||
RegisterCommand("regveh", function(source, args, rawCommand)
|
||||
local ped = PlayerPedId()
|
||||
if IsPedSittingInAnyVehicle(ped) then
|
||||
local ssn = GetResourceKvpString("civ_ssn")
|
||||
if ssn then
|
||||
local vehicle = GetVehiclePedIsIn(ped, false)
|
||||
local vehicleHash = GetEntityModel(vehicle)
|
||||
local vehicleModelName = GetDisplayNameFromVehicleModel(vehicleHash)
|
||||
local plate = GetVehicleNumberPlateText(vehicle)
|
||||
|
||||
local colorName = GetVehicleColorName(vehicle)
|
||||
local makeName = GetVehicleMakeName(string.upper(vehicleModelName))
|
||||
|
||||
if vehicleModelName == "CARNOTFOUND" or vehicleModelName == nil then
|
||||
vehicleModelName = "UNKNOWN"
|
||||
Notify("Model Unknown, Proceeding anyways...")
|
||||
end
|
||||
|
||||
local primaryColor, _ = GetVehicleColours(vehicle)
|
||||
|
||||
if Config.debug then
|
||||
print("Color ID for this request is " .. primaryColor)
|
||||
end
|
||||
TriggerServerEvent("ImperialCAD:registerVehicleToCAD", ssn, vehicleModelName, plate, colorName, makeName)
|
||||
Notify("Registration has been sent to the DMV.")
|
||||
else
|
||||
Notify("You must set an active civilian before registering a vehicle.")
|
||||
end
|
||||
else
|
||||
Notify("You must be in a vehicle to register it.")
|
||||
end
|
||||
end, false)
|
||||
|
||||
function GetStoredSSN()
|
||||
return GetResourceKvpString("civ_ssn")
|
||||
end
|
||||
|
||||
exports('GetStoredSSN', GetStoredSSN)
|
||||
print ()
|
||||
|
||||
|
||||
function GetStoredName()
|
||||
return GetResourceKvpString("civ_name")
|
||||
end
|
||||
|
||||
exports('GetStoredName', GetStoredName)
|
||||
print ()
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
RegisterNetEvent("ImperialCAD:getCivData")
|
||||
AddEventHandler("ImperialCAD:getCivData", function(ssn)
|
||||
local src = source
|
||||
local headers = {
|
||||
["Content-Type"] = "application/json",
|
||||
["APIKEY"] = GetConvar("imperialAPI", ""),
|
||||
}
|
||||
local url = "https://imperialcad.app/api/1.1/wf/getcivdata"
|
||||
local data = {
|
||||
ssn = ssn,
|
||||
commId = GetConvar("imperial_community_id", "")
|
||||
}
|
||||
|
||||
local jsonData = json.encode(data)
|
||||
|
||||
PerformHttpRequest(url, function(statusCode, response, headers)
|
||||
if statusCode == 200 then
|
||||
local responseData = json.decode(response)
|
||||
if responseData and responseData.ssn then
|
||||
TriggerClientEvent("ImperialCAD:setActiveCiv", src, responseData)
|
||||
SetActiveCiv({users_discordID = getDiscordId(src), ssn = ssn}, false)
|
||||
else
|
||||
print("No SSN found in the data. Response: " .. response)
|
||||
TriggerClientEvent("notify", src, "No civilian found with this SSN.")
|
||||
end
|
||||
else
|
||||
print("Failed to retrieve data with status code: " .. statusCode)
|
||||
TriggerClientEvent("notify", src, "Failed to retrieve data. Check logs.")
|
||||
end
|
||||
end, "POST", jsonData, headers)
|
||||
end)
|
||||
|
||||
RegisterNetEvent("ImperialCAD:updateCivilianStatus")
|
||||
AddEventHandler("ImperialCAD:updateCivilianStatus", function(data)
|
||||
if data.status == "deleted" and data.ssn == GetResourceKvpString("civ_ssn") then
|
||||
DeleteResourceKvp("civ_ssn")
|
||||
DeleteResourceKvp("civ_name")
|
||||
DeleteResourceKvp("civ_age")
|
||||
DeleteResourceKvp("civ_address")
|
||||
TriggerEvent("notify", "Your active civilian profile has been deleted externally.")
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent("ImperialCAD:registerVehicleToCAD")
|
||||
AddEventHandler("ImperialCAD:registerVehicleToCAD", function(ssn, vehicleModelName, plate, colorName, makeName, year)
|
||||
local src = source
|
||||
local commId = GetConvar("imperial_community_id", "")
|
||||
local apiKey = GetConvar("imperialAPI", "")
|
||||
|
||||
if not commId or commId == "" then
|
||||
TriggerClientEvent("notify", src, "Community ID is not set. Cannot proceed with registration.")
|
||||
return
|
||||
end
|
||||
|
||||
if not apiKey or apiKey == "" then
|
||||
TriggerClientEvent("notify", src, "API Key is not set. Cannot proceed with registration.")
|
||||
return
|
||||
end
|
||||
|
||||
local data = {
|
||||
ssn = ssn,
|
||||
vehicleModel = vehicleModelName or "UNKNOWN",
|
||||
plate = plate or "UNKNOWN",
|
||||
commId = commId,
|
||||
year = year or "UNKNOWN",
|
||||
make = makeName or "UNKNOWN",
|
||||
color = colorName or "UNKNOWN"
|
||||
}
|
||||
|
||||
local jsonData = json.encode(data)
|
||||
|
||||
local headers = {
|
||||
["Content-Type"] = "application/json",
|
||||
["APIKEY"] = apiKey
|
||||
}
|
||||
|
||||
PerformHttpRequest("https://imperialcad.app/api/1.1/wf/registerVehicle",
|
||||
function(statusCode, response, headers)
|
||||
if statusCode == 200 then
|
||||
local responseData = json.decode(response)
|
||||
if responseData and responseData.success then
|
||||
TriggerClientEvent("notify", src, "Vehicle registered successfully to CAD.")
|
||||
end
|
||||
else
|
||||
TriggerClientEvent("notify", src, "Failed to register vehicle. Status Code: " .. statusCode)
|
||||
end
|
||||
end,
|
||||
"POST", jsonData, headers)
|
||||
end)
|
||||
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
local onduty = false
|
||||
local leoweapons = Config.LEOWeapons
|
||||
local fireweapons = Config.FIREWeapons
|
||||
|
||||
local weapons = {}
|
||||
|
||||
local disabled = Config.DisableDutyCommand
|
||||
|
||||
if disabled then return end
|
||||
|
||||
TriggerEvent('chat:addSuggestion', '/duty', 'Toggle your duty status for better ImperialCAD notifications', {
|
||||
{ name="JOB", help="Specify the job you want to go on-duty as or blank for off duty" },
|
||||
})
|
||||
|
||||
RegisterCommand("duty", function(source, args)
|
||||
local received = args[1] or nil
|
||||
local job = received and string.upper(received) or nil
|
||||
|
||||
if onduty then
|
||||
|
||||
onduty = false
|
||||
TriggerServerEvent("Imperial:RemoveUnitOnDuty", job)
|
||||
ShowNotification("You are now ~r~off-duty~w~.", job)
|
||||
TriggerEvent("Imperial:Client:UnSuitUnit")
|
||||
|
||||
else
|
||||
print(received, job)
|
||||
if received == nil or (job ~= "LEO" and job ~= "FIRE") then
|
||||
ShowNotification("You need to specify a valid job. (LEO or FIRE)", "Imperial Duty")
|
||||
return
|
||||
end
|
||||
|
||||
onduty = true
|
||||
TriggerServerEvent("Imperial:AddUnitOnDuty", job)
|
||||
TriggerEvent('Imperial:Client:SuitNewUnit', job)
|
||||
ShowNotification("You are now ~g~on-duty~w~.", job)
|
||||
end
|
||||
end, false)
|
||||
|
||||
RegisterNetEvent("Imperial:Client:SuitNewUnit")
|
||||
AddEventHandler("Imperial:Client:SuitNewUnit", function(job)
|
||||
SetPedArmour(PlayerPedId(), 100)
|
||||
TriggerEvent('ImperialCAD:livemap:client:ToggleTracking', true)
|
||||
|
||||
if job == "LEO" and Config.GiveLEOWeapons then
|
||||
weapons = leoweapons
|
||||
elseif job == "FIRE" and Config.GiveFIREWeapons then
|
||||
weapons = fireweapons
|
||||
else
|
||||
weapons = {}
|
||||
end
|
||||
|
||||
for _, weapon in ipairs(weapons) do
|
||||
GiveWeaponToPed(PlayerPedId(), GetHashKey(weapon), 250, false, true)
|
||||
SetPedAmmo(PlayerPedId(), GetHashKey(weapon), 250)
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent("Imperial:Client:UnSuitUnit")
|
||||
AddEventHandler("Imperial:Client:UnSuitUnit", function()
|
||||
for _, weapon in ipairs(weapons) do
|
||||
RemoveWeaponFromPed(PlayerPedId(), GetHashKey(weapon))
|
||||
end
|
||||
weapons = {} or nil
|
||||
TriggerEvent('ImperialCAD:livemap:client:ToggleTracking', false)
|
||||
end)
|
||||
|
||||
function ShowNotification(message, job)
|
||||
BeginTextCommandThefeedPost("STRING")
|
||||
AddTextComponentSubstringPlayerName(message)
|
||||
EndTextCommandThefeedPostMessagetext("CHAR_CHAT_CALL", "CHAR_CHAT_CALL", true, 1, "ImperialCAD", job)
|
||||
end
|
||||
@@ -0,0 +1,256 @@
|
||||
local OnDutyUnits = {}
|
||||
local OnDutyLEOUnits = {}
|
||||
local OnDutyFireUnits = {}
|
||||
|
||||
local sendWebhook = Config.SendWebhook
|
||||
local webhookURL = Config.WebhookURL
|
||||
|
||||
local disabled = Config.DisableDutyCommand
|
||||
|
||||
RegisterNetEvent("Imperial:AddUnitOnDuty")
|
||||
AddEventHandler("Imperial:AddUnitOnDuty", function(job, target)
|
||||
local serverId = target or source
|
||||
table.insert(OnDutyUnits, serverId)
|
||||
local jobName = "Unkown"
|
||||
|
||||
if job == "LEO" then
|
||||
table.insert(OnDutyLEOUnits, serverId)
|
||||
jobName = "Law Enforcement Officer"
|
||||
elseif job == "FIRE" then
|
||||
table.insert(OnDutyFireUnits, serverId)
|
||||
jobName = "Fire/Medical"
|
||||
end
|
||||
|
||||
if sendWebhook then
|
||||
local playerName = GetPlayerName(serverId)
|
||||
local webhookData = {
|
||||
["embeds"] = {
|
||||
{
|
||||
["color"] = 16711680,
|
||||
["title"] = "Player went On-Duty",
|
||||
["description"] = "Player: "..playerName.."\nJob: "..jobName,
|
||||
["footer"] = {
|
||||
["text"] = "ImperialCAD - ImperialDuty | In-game"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PerformHttpRequest(webhookURL, function(err, text, headers)
|
||||
if err ~= 204 then
|
||||
print("^1[ImperialDuty] Error sending webhook: HTTP "..tostring(err).."^0")
|
||||
if text then print("^1[ImperialDuty] Response: "..text.."^0") end
|
||||
else
|
||||
print("^2[ImperialDuty] Webhook sent successfully.^0")
|
||||
end
|
||||
end, 'POST', json.encode(webhookData), { ['Content-Type'] = 'application/json' })
|
||||
end
|
||||
|
||||
print("Added to OnDuty Units: "..GetPlayerName(serverId).." Job: "..job)
|
||||
end)
|
||||
|
||||
RegisterNetEvent("Imperial:RemoveUnitOnDuty")
|
||||
AddEventHandler("Imperial:RemoveUnitOnDuty", function(job, target)
|
||||
local serverId = target or source
|
||||
local jobName = "Unkown"
|
||||
|
||||
for i, unitId in ipairs(OnDutyUnits) do
|
||||
if unitId == serverId then
|
||||
table.remove(OnDutyUnits, i)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if job == "LEO" then
|
||||
jobName = "Law Enforcement Officer"
|
||||
for i, unitId in ipairs(OnDutyLEOUnits) do
|
||||
if unitId == serverId then
|
||||
table.remove(OnDutyLEOUnits, i)
|
||||
break
|
||||
end
|
||||
end
|
||||
elseif job == "FIRE" then
|
||||
jobName = "Fire/Medical"
|
||||
for i, unitId in ipairs(OnDutyFireUnits) do
|
||||
if unitId == serverId then
|
||||
table.remove(OnDutyFireUnits, i)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if sendWebhook then
|
||||
local playerName = GetPlayerName(serverId)
|
||||
local webhookData = {
|
||||
["embeds"] = {
|
||||
{
|
||||
["color"] = 16711680,
|
||||
["title"] = "Player Went Off-Duty",
|
||||
["description"] = "Player: "..playerName.."\nJob: "..jobName,
|
||||
["footer"] = {
|
||||
["text"] = "ImperialCAD - ImperialDuty | In-game"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PerformHttpRequest(webhookURL, function(err, text, headers)
|
||||
if err ~= 204 then
|
||||
print("^1[ImperialDuty] Error sending webhook: HTTP "..tostring(err).."^0")
|
||||
if text then print("^1[ImperialDuty] Response: "..text.."^0") end
|
||||
else
|
||||
print("^2[ImperialDuty] Webhook sent successfully.^0")
|
||||
end
|
||||
end, 'POST', json.encode(webhookData), { ['Content-Type'] = 'application/json' })
|
||||
end
|
||||
|
||||
print("Removed from OnDuty Units: " .. GetPlayerName(serverId))
|
||||
end)
|
||||
|
||||
RegisterNetEvent("playerDropped")
|
||||
AddEventHandler("playerDropped", function(reason)
|
||||
local serverId = source
|
||||
local playerName = GetPlayerName(serverId)
|
||||
|
||||
for i, unitId in ipairs(OnDutyUnits) do
|
||||
if unitId == serverId then
|
||||
table.remove(OnDutyUnits, i)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
local jobName = "Unknown"
|
||||
local jobType = nil
|
||||
|
||||
for i, unitId in ipairs(OnDutyLEOUnits) do
|
||||
if unitId == serverId then
|
||||
table.remove(OnDutyLEOUnits, i)
|
||||
jobName = "Law Enforcement Officer"
|
||||
jobType = "LEO"
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
for i, unitId in ipairs(OnDutyFireUnits) do
|
||||
if unitId == serverId then
|
||||
table.remove(OnDutyFireUnits, i)
|
||||
jobName = "Fire/Medical"
|
||||
jobType = "FIRE"
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
print("[ImperialDuty] Player " .. serverId .. " disconnected. Removed from duty: " .. jobName)
|
||||
|
||||
if sendWebhook and jobType then
|
||||
local webhookData = {
|
||||
["embeds"] = {
|
||||
{
|
||||
["color"] = 16711680,
|
||||
["title"] = "Player Disconnected While On-Duty",
|
||||
["description"] = "**Player:** " .. playerName .. "\n**Job:** " .. jobName .. "\n**Reason:** " ..(reason),
|
||||
["footer"] = { ["text"] = "ImperialCAD - ImperialDuty | In-game" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PerformHttpRequest(webhookURL, function(err, text, headers)
|
||||
if err ~= 204 then
|
||||
print("^1[ImperialDuty] Error sending webhook: HTTP " .. tostring(err) .. "^0")
|
||||
if text then print("^1[ImperialDuty] Response: " .. text .. "^0") end
|
||||
else
|
||||
print("^2[ImperialDuty] Disconnection webhook sent successfully.^0")
|
||||
end
|
||||
end, 'POST', json.encode(webhookData), { ['Content-Type'] = 'application/json' })
|
||||
end
|
||||
end)
|
||||
|
||||
function IsUnitOnDuty(serverId)
|
||||
for _, unitId in ipairs(OnDutyUnits) do
|
||||
if unitId == serverId then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
function GetOnDutyUnits()
|
||||
return OnDutyUnits
|
||||
end
|
||||
|
||||
function GetOnDutyLEOUnits()
|
||||
return OnDutyLEOUnits
|
||||
end
|
||||
|
||||
function GetOnDutyFireUnits()
|
||||
return OnDutyFireUnits
|
||||
end
|
||||
|
||||
function PrintTable(tbl)
|
||||
for k, v in pairs(tbl) do
|
||||
print(k, v)
|
||||
end
|
||||
end
|
||||
|
||||
if disabled then
|
||||
|
||||
RegisterNetEvent("Imperial:AddUnitOnDutydisabled")
|
||||
AddEventHandler("Imperial:AddUnitOnDutydisabled", function(serverId, job)
|
||||
|
||||
local job = job or "Unkown"
|
||||
|
||||
table.insert(OnDutyUnits, serverId)
|
||||
|
||||
if job == "LEO" then
|
||||
table.insert(OnDutyLEOUnits, serverId)
|
||||
elseif job == "FIRE" then
|
||||
table.insert(OnDutyFireUnits, serverId)
|
||||
end
|
||||
|
||||
print("Added to OnDuty Units: "..GetPlayerName(serverId).." Job: "..job)
|
||||
end)
|
||||
|
||||
RegisterNetEvent("Imperial:RemoveUnitOnDutydisabled")
|
||||
AddEventHandler("Imperial:RemoveUnitOnDutydisabled", function(serverId, job)
|
||||
|
||||
local job = job or "Unkown"
|
||||
|
||||
for i, unitId in ipairs(OnDutyUnits) do
|
||||
|
||||
if unitId == serverId then
|
||||
table.remove(OnDutyUnits, i)
|
||||
break
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if job == "LEO" then
|
||||
|
||||
for i, unitId in ipairs(OnDutyLEOUnits) do
|
||||
if unitId == serverId then
|
||||
table.remove(OnDutyLEOUnits, i)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
elseif job == "FIRE" then
|
||||
|
||||
for i, unitId in ipairs(OnDutyFireUnits) do
|
||||
if unitId == serverId then
|
||||
table.remove(OnDutyFireUnits, i)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
print("Removed from OnDuty Units: " .. GetPlayerName(serverId))
|
||||
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
exports('GetOnDutyUnits', GetOnDutyUnits)
|
||||
exports('GetOnDutyLEOUnits', GetOnDutyLEOUnits)
|
||||
exports('GetOnDutyFireUnits', GetOnDutyFireUnits)
|
||||
@@ -0,0 +1,4 @@
|
||||
if not Config.ERSsupport then return end
|
||||
|
||||
exports['night_ers']:SetERSVehicleInfoDisplay(false) -- Sets the display for vehicle information on traffic stops to true or false.
|
||||
exports['night_ers']:SetERSIDCardInfoDisplay(false) -- Sets the display for ID cards to true or false.
|
||||
@@ -0,0 +1,407 @@
|
||||
if not Config.ERSsupport then return end
|
||||
|
||||
print("Loading ImperialCAD ERS Integration..")
|
||||
|
||||
local function GetCivilianData(firstname, lastname, cb)
|
||||
|
||||
|
||||
GetCharacterAdvanced({
|
||||
firstname = firstname,
|
||||
lastname = lastname
|
||||
}, function(success, resultData)
|
||||
if success then
|
||||
local rData = resultData
|
||||
local status = rData.status
|
||||
if Config.debug then print("GetCharacter ERS DEBUG LINE:", status or rData) end
|
||||
if status == "success" then
|
||||
if Config.debug then print("[Imperial ERS] Received civilian data from CAD, Not registering the same civilian for ped") end
|
||||
cb(true)
|
||||
elseif status == "error" then
|
||||
if Config.debug then print("[Imperial ERS] Could not find civilian data in CAD, Registering a new civilian for ped") end
|
||||
cb(false)
|
||||
end
|
||||
else
|
||||
if Config.debug then print("[Imperial ERS] Could not preform CAD request, Will not not proceed with civilian ped") end
|
||||
cb(true)
|
||||
end
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
local function GetVehicleData(plate, cb)
|
||||
|
||||
CheckPlate({
|
||||
plate = plate
|
||||
}, function(success, resultData)
|
||||
if success then
|
||||
local rData = resultData
|
||||
local status = rData.status
|
||||
if Config.debug then print("CheckPlate ERS DEBUG LINE:", status or rData) end
|
||||
if Config.debug then print("[Imperial ERS] Vehicle already in cad, not registering again") end
|
||||
cb(true)
|
||||
else
|
||||
if Config.debug then print("[Imperial ERS] Vehicle not found in cad, attempting to register") end
|
||||
cb(false)
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
if Config.ImperialDutySync then
|
||||
RegisterNetEvent('ErsIntegration::OnToggleShift')
|
||||
AddEventHandler('ErsIntegration::OnToggleShift', function(source, isOnShift, serviceType)
|
||||
local job = nil
|
||||
|
||||
if serviceType == "police" then job = "LEO" elseif serviceType == "fire" then job = "FIRE" end
|
||||
|
||||
if job ~= nil and isOnShift then TriggerEvent("Imperial:AddUnitOnDuty", job, source) TriggerClientEvent('Imperial:Client:SuitNewUnit', source, job) end
|
||||
if job ~= nil and not isOnShift then TriggerEvent("Imperial:RemoveUnitOnDuty", job, source) TriggerClientEvent('Imperial:Client:UnSuitNewUnit', source) end
|
||||
end)
|
||||
end
|
||||
|
||||
RegisterNetEvent('ErsIntegration::OnFirstNPCInteraction')
|
||||
AddEventHandler('ErsIntegration::OnFirstNPCInteraction', function(source, data, context)
|
||||
if not IsUnitOnDuty(source) then if Config.debug then print(source, "unit is not on duty with imperial ignoring ers") end return end
|
||||
if Config.debug then print("Received ERS ped info", json.encode(data)) end
|
||||
local name = data.FirstName .. " " .. data.LastName
|
||||
|
||||
GetCivilianData(data.FirstName, data.LastName, function(pedRegistered)
|
||||
|
||||
if not pedRegistered then
|
||||
local pdata = data
|
||||
|
||||
local DLStatus = string.upper(pdata.License_Car)
|
||||
local CDLStatus = string.upper(pdata.License_Truck)
|
||||
|
||||
local licenseMap = {
|
||||
["VALID"] = "ACTIVE",
|
||||
["INTERNATIONAL LICENSE (VALID)"] = "ACTIVE",
|
||||
["REPORTED STOLEN (VALID)"] = "REVOKED",
|
||||
|
||||
["EXPIRED"] = "EXPIRED",
|
||||
["SUSPENDED"] = "SUSPENDED",
|
||||
["REVOKED"] = "REVOKED",
|
||||
|
||||
["NONE"] = "NONE",
|
||||
["N/A"] = "NONE",
|
||||
[""] = "NONE",
|
||||
}
|
||||
|
||||
local licenseStatus = licenseMap[DLStatus] or "NONE"
|
||||
local CLicenseStatus = licenseMap[CDLStatus] or "NONE"
|
||||
|
||||
NewCharacterAdvanced({
|
||||
commId = GetConvar("imperial_community_id", ""),
|
||||
Fname = pdata.FirstName,
|
||||
Mname = "", -- ERS doesn't provide middle name
|
||||
Lname = pdata.LastName,
|
||||
Birthdate = pdata.DOB,
|
||||
gender = pdata.Gender,
|
||||
race = string.upper(pdata.Nationality) or "nil",
|
||||
hairC = "nil", -- not provided
|
||||
eyeC = "nil", -- not provided
|
||||
height = "nil", -- not provided
|
||||
weight = "nil", -- not provided
|
||||
postal = pdata.PostalCode,
|
||||
address = pdata.Address,
|
||||
city = pdata.City,
|
||||
county = "nil",
|
||||
state = pdata.State,
|
||||
phonenum = pdata.PhoneNumber,
|
||||
licensedetails = {
|
||||
hasBoatLic = pdata.License_Boat_Is_Valid,
|
||||
hasCDL = pdata.License_Truck_Is_Valid,
|
||||
CDLNumber = GenerateRandomString(9), -- ERS doesn't provide, but we made a function
|
||||
CDLStatus = CLicenseStatus,
|
||||
hasDL = pdata.License_Car_Is_Valid,
|
||||
DLNumber = GenerateRandomString(9),
|
||||
DLStatus = licenseStatus,
|
||||
hasFirearmsCertification = false, -- not in ERS
|
||||
hasFishLic = false,
|
||||
hasHuntLic = false
|
||||
},
|
||||
misc = {
|
||||
missing = false
|
||||
}
|
||||
}
|
||||
, function(success, resultData)
|
||||
if success then
|
||||
|
||||
if Config.debug then
|
||||
print("[IMPERIAL_ERS] Ped created in cad:", json.encode(resultData))
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
if Config.debug then
|
||||
print("[IMPERIAL_ERS] Ped couldnt be created in cad:", json.encode(resultData))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end)
|
||||
else
|
||||
if Config.debug then print("[IMPERIAL_ERS] Here is the else statement meaning that this character should not be reg") end
|
||||
end
|
||||
|
||||
end) -- checking/handling trying to create saved char in cad
|
||||
|
||||
|
||||
|
||||
end) -- Checking ped registry
|
||||
|
||||
|
||||
RegisterNetEvent('ErsIntegration::OnFirstVehicleInteraction')
|
||||
AddEventHandler('ErsIntegration::OnFirstVehicleInteraction', function(source, data, context)
|
||||
if Config.debug then print("[IMPERIAL_ERS] Received ERS vehicle info", json.encode(data)) end
|
||||
if not IsUnitOnDuty(source) then if Config.debug then print(source, "unit is not on duty with imperial ignoring ers") end return end
|
||||
|
||||
local fullName = data.owner_name
|
||||
|
||||
-- Use pattern matching to split into first and last?? idk trying it tho
|
||||
local firstName, lastName = fullName:match("^(%S+)%s+(.*)$")
|
||||
|
||||
if Config.debug then
|
||||
print("[IMPERIAL_ERS] First name:", firstName)
|
||||
print("[IMPERIAL_ERS] Last name:", lastName)
|
||||
end
|
||||
|
||||
local vehicle = data
|
||||
local insuranceStatus = vehicle.insurance and "ACTIVE" or "EXPIRED"
|
||||
local regStatus = vehicle.tax and "ACTIVE" or "EXPIRED"
|
||||
|
||||
GetVehicleData(vehicle.license_plate, function(isReg)
|
||||
|
||||
if not isReg then
|
||||
|
||||
CreateVehicleAdvanced({
|
||||
vehicleData = {
|
||||
plate = vehicle.license_plate,
|
||||
model = vehicle.model,
|
||||
Make = vehicle.make,
|
||||
color = vehicle.color,
|
||||
year = tostring(vehicle.build_year),
|
||||
regStatus = regStatus,
|
||||
regExpDate = vehicle.registration_date,
|
||||
vin = GenerateRandomString(17),
|
||||
stolen = vehicle.stolen
|
||||
},
|
||||
vehicleInsurance = {
|
||||
hasInsurance = vehicle.insurance,
|
||||
insuranceStatus = insuranceStatus,
|
||||
insurancePolicyNum = GenerateRandomString(12)
|
||||
},
|
||||
vehicleOwner = {
|
||||
ownerSSN = "nil",
|
||||
ownerFirstName = firstName,
|
||||
ownerLastName = lastName,
|
||||
ownerGender = "nil",
|
||||
ownerAddress = "nil",
|
||||
ownerCity = "nil"
|
||||
}
|
||||
}, function(success, resultData)
|
||||
|
||||
if success then
|
||||
|
||||
if Config.debug then print("[IMPERIAL_ERS] Registered advanced vehicle") end
|
||||
|
||||
else
|
||||
|
||||
if Config.debug and resultData then print("[IMPERIAL_ERS] Could not register advanced vehicle:", json.encode(resultData)) end
|
||||
|
||||
if Config.debug and not resultData then print("[IMPERIAL_ERS] Could not register advanced vehicle: NO RESULT DATA AVAIL") end
|
||||
end
|
||||
|
||||
end) -- end function of creating advanced vehicle in cad
|
||||
|
||||
else
|
||||
|
||||
if Config.debug then print("[IMPERIAL_ERS] Cannot and will not register this ped vehicle") end
|
||||
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
RegisterNetEvent('ErsIntegration::OnAcceptedCalloutOffer')
|
||||
AddEventHandler('ErsIntegration::OnAcceptedCalloutOffer', function(callData)
|
||||
if Config.debug then print("Received accepeted calloutoffer from ERS") end
|
||||
if not IsUnitOnDuty(source) then if Config.debug then print(source, "unit is not on duty with imperial ignoring ers") end return end
|
||||
local ers = callData
|
||||
local src = source
|
||||
|
||||
local streetData = lib.callback.await('ImperialCAD:getNearestStreets', source, ers.Coordinates)
|
||||
|
||||
local street = streetData.street
|
||||
local crossStreet = streetData.crossStreet or nil
|
||||
|
||||
exports["ImperialCAD"]:CreateCall({
|
||||
users_discordID = getDiscordId(source),
|
||||
street = street,
|
||||
cross_street = crossStreet,
|
||||
postal = exports["ImperialCAD"]:getNearestPostalFromCoords(ers.Coordinates),
|
||||
city = exports["ImperialCAD"]:getNearestCityFromCoords(ers.Coordinates),
|
||||
county = exports["ImperialCAD"]:getNearestCountyFromCoords(ers.Coordinates),
|
||||
info = ers.Description,
|
||||
nature = ers.CalloutName,
|
||||
status = "ACTIVE",
|
||||
priority = "2"
|
||||
}, function(success, resultData)
|
||||
if success then
|
||||
local apires = json.decode(resultData)
|
||||
if not apires or not apires.response or not apires.response.callId then
|
||||
if Config.debug then print("^1[IMPERIAL_ERS_ERROR]^7 Invalid response or call ID not found") end
|
||||
return
|
||||
end
|
||||
local callnum = apires.response.callnum
|
||||
local callId = apires.response.callId
|
||||
if Config.debug then print("[IMPERIAL_ERS] Cad Call Created: Call num -", callnum) end
|
||||
addCall(src, callId)
|
||||
else
|
||||
if Config.debug then print(resultData) end
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('ErsIntegration::OnArrivedAtCallout')
|
||||
AddEventHandler('ErsIntegration::OnArrivedAtCallout', function(callData)
|
||||
if Config.debug then print("Received arrived at callout from ERS") end
|
||||
if not IsUnitOnDuty(source) then if Config.debug then print(source, "unit is not on duty with imperial ignoring ers") end return end
|
||||
end)
|
||||
|
||||
if Config.UseERSCalloutEnded then
|
||||
RegisterNetEvent('ErsIntegration::OnEndedACallout')
|
||||
AddEventHandler('ErsIntegration::OnEndedACallout', function()
|
||||
local src = source
|
||||
if Config.debug then print("Received ended a callout from ERS") end
|
||||
if not IsUnitOnDuty(src) then if Config.debug then print(src, "unit is not on duty with imperial ignoring ers") end return end
|
||||
local call = getCall(src)
|
||||
|
||||
if call then
|
||||
if Config.debug then print('There is a ers call number saved, trying to delete it') end
|
||||
exports["ImperialCAD"]:DeleteCall({
|
||||
callId = call,
|
||||
discordId = getDiscordId(src),
|
||||
}, function(success, resultData)
|
||||
if success then
|
||||
if Config.debug then print("^1[IMPERIAL_ERS]^7 Call deleted, call ended by ERS") end
|
||||
else
|
||||
if Config.debug then print("^1[IMPERIAL_ERS_error]^7 Unable to delete, call ended by ERS") end
|
||||
end
|
||||
end)
|
||||
removeCall(src)
|
||||
else
|
||||
if Config.debug then print('There is not a ers call number locally saved, not trying to delete it') end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
if Config.UseERSCalloutCompletedSuccesfully then
|
||||
RegisterServerEvent("ErsIntegration::OnCalloutCompletedSuccesfully")
|
||||
AddEventHandler("ErsIntegration::OnCalloutCompletedSuccesfully", function(calloutData)
|
||||
local src = source
|
||||
if Config.debug then print("Received ended a callout from ERS") end
|
||||
if not IsUnitOnDuty(src) then if Config.debug then print(src, "unit is not on duty with imperial ignoring ers") end return end
|
||||
local call = getCall(src)
|
||||
|
||||
if call then
|
||||
if Config.debug then print('There is a ers call number saved, trying to delete it then') end
|
||||
exports["ImperialCAD"]:DeleteCall({
|
||||
callId = call,
|
||||
discordId = getDiscordId(src),
|
||||
}, function(success, resultData)
|
||||
if success then
|
||||
if Config.debug then print("^1[IMPERIAL_ERS]^7 Call deleted, call ended by ERS") end
|
||||
else
|
||||
if Config.debug then print("^1[IMPERIAL_ERS_error]^7 Unable to delete, call ended by ERS") end
|
||||
end
|
||||
end)
|
||||
removeCall(src)
|
||||
else
|
||||
if Config.debug then print('There is not a ers call number locally saved, not trying to delete it') end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
RegisterServerEvent("ErsIntegration::OnPullover")
|
||||
AddEventHandler("ErsIntegration::OnPullover", function(pedData, vehicleData)
|
||||
local src = source
|
||||
|
||||
if Config.debug then print("Received started a pullover from ERS") end
|
||||
if not IsUnitOnDuty(src) then if Config.debug then print(src, "unit is not on duty with imperial ignoring ers") end return end
|
||||
|
||||
local ped = GetPlayerPed(src)
|
||||
local Coords
|
||||
|
||||
local vehicle = vehicleData
|
||||
|
||||
if ped and ped ~= 0 then
|
||||
Coords = GetEntityCoords(ped)
|
||||
if Config.debug then print(("Player %s coords: x=%.2f, y=%.2f, z=%.2f"):format(src, Coords.x, Coords.y, Coords.z)) end
|
||||
else
|
||||
if Config.debug then print("No ped found for player " .. src) end
|
||||
end
|
||||
|
||||
local streetData = lib.callback.await('ImperialCAD:getNearestStreets', src, Coords)
|
||||
|
||||
local street = streetData.street
|
||||
local crossStreet = streetData.crossStreet or nil
|
||||
|
||||
exports["ImperialCAD"]:CreateCall({
|
||||
users_discordID = getDiscordId(src),
|
||||
street = street,
|
||||
cross_street = crossStreet,
|
||||
postal = exports["ImperialCAD"]:getNearestPostalFromCoords(Coords),
|
||||
city = exports["ImperialCAD"]:getNearestCityFromCoords(Coords),
|
||||
county = exports["ImperialCAD"]:getNearestCountyFromCoords(Coords),
|
||||
info = ("Traffic stop on a %s %s %s (%s) with the license plate %s. (Bolo Desc: %s)"):format(vehicle.build_year, vehicle.color, vehicle.make, vehicle.model, vehicle.license_plate, vehicle.bolo_description),
|
||||
nature = Config.trafficsnature,
|
||||
status = "ACTIVE",
|
||||
priority = Config.trafficspriority
|
||||
}, function(success, resultData)
|
||||
if success then
|
||||
local apires = json.decode(resultData)
|
||||
if not apires or not apires.response or not apires.response.callId then
|
||||
if Config.debug then print("^1[IMPERIAL_ERS_ERROR]^7 Invalid response or call ID not found") end
|
||||
return
|
||||
end
|
||||
local callnum = apires.response.callnum
|
||||
local callId = apires.response.callId
|
||||
if Config.debug then print("[IMPERIAL_ERS] Cad Call Created: Call num -", callnum) end
|
||||
addCall(src, callId)
|
||||
else
|
||||
if Config.debug then print(resultData) end
|
||||
end
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
if Config.UseERSPulloverEnded then
|
||||
RegisterServerEvent("ErsIntegration::OnPulloverEnded")
|
||||
AddEventHandler("ErsIntegration::OnPulloverEnded", function(pedData, vehicleData)
|
||||
local src = source
|
||||
|
||||
if Config.debug then print("Received ended a pullover from ERS") end
|
||||
if not IsUnitOnDuty(src) then if Config.debug then print(src, "unit is not on duty with imperial ignoring ers") end return end
|
||||
local call = getCall(src)
|
||||
|
||||
if call then
|
||||
if Config.debug then print('There is a ers call number saved, trying to delete it then') end
|
||||
exports["ImperialCAD"]:DeleteCall({
|
||||
callId = call,
|
||||
discordId = getDiscordId(src),
|
||||
}, function(success, resultData)
|
||||
if success then
|
||||
if Config.debug then print("^1[IMPERIAL_ERS]^7 Call deleted, call ended by ERS") end
|
||||
else
|
||||
if Config.debug then print("^1[IMPERIAL_ERS_error]^7 Unable to delete, call ended by ERS") end
|
||||
end
|
||||
end)
|
||||
removeCall(src)
|
||||
else
|
||||
if Config.debug then print('There is not a ers call number locally saved, not trying to delete it') end
|
||||
end
|
||||
end)
|
||||
end
|
||||
@@ -0,0 +1,62 @@
|
||||
if not Config.livemap then return end
|
||||
|
||||
local x, y
|
||||
local lastSend = 0
|
||||
local SEND_INTERVAL = 10000
|
||||
local tracking = false
|
||||
|
||||
RegisterNetEvent('ImperialCAD:livemap:client:ToggleTracking', function(Atracking)
|
||||
tracking = Atracking
|
||||
end)
|
||||
|
||||
TriggerEvent('chat:addSuggestion', '/ToggleTracking', 'Toggle ImperialCAD live tracking')
|
||||
|
||||
RegisterCommand("ToggleTracking", function()
|
||||
if tracking then
|
||||
tracking = false
|
||||
if Config.debug then print("Tracking disabled") end
|
||||
else
|
||||
tracking = true
|
||||
if Config.debug then print("Tracking enabled") end
|
||||
end
|
||||
end, false)
|
||||
|
||||
CreateThread(function()
|
||||
while true do
|
||||
Wait(3500)
|
||||
|
||||
local ped = PlayerPedId()
|
||||
local coords = GetEntityCoords(ped)
|
||||
local veh = GetVehiclePedIsIn(ped, false)
|
||||
local speed = math.floor(GetEntitySpeed(ped) * 2.23694)
|
||||
|
||||
local status = "on_foot"
|
||||
if veh ~= 0 then
|
||||
local model = GetEntityModel(veh)
|
||||
if IsThisModelAHeli(model) or IsThisModelAPlane(model) then
|
||||
status = "aircraft"
|
||||
elseif IsThisModelABoat(model) then
|
||||
status = "boat"
|
||||
else
|
||||
status = "car"
|
||||
end
|
||||
end
|
||||
|
||||
local now = GetGameTimer()
|
||||
local moved = (x ~= coords.x) or (y ~= coords.y)
|
||||
local timeout = (now - lastSend) >= SEND_INTERVAL
|
||||
|
||||
if (moved or timeout) and tracking then
|
||||
TriggerServerEvent("ImperialCAD:livemap:send", {
|
||||
x = coords.x,
|
||||
y = coords.y,
|
||||
speed = speed,
|
||||
icon = status
|
||||
})
|
||||
|
||||
x = coords.x
|
||||
y = coords.y
|
||||
lastSend = now
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -0,0 +1,27 @@
|
||||
TriggerEvent('chat:addSuggestion', '/ToggleTracking', 'Toggle ImperialCAD live tracking')
|
||||
|
||||
RegisterCommand("ToggleUsersTracking", function(args)
|
||||
|
||||
end, false)
|
||||
|
||||
|
||||
RegisterServerEvent("ImperialCAD:livemap:send")
|
||||
AddEventHandler("ImperialCAD:livemap:send", function(data)
|
||||
local src = source
|
||||
local discord = getDiscordId(src)
|
||||
local communityId = GetConvar("imperial_community_id", "")
|
||||
|
||||
if not discord then return end
|
||||
--if not IsUnitOnDuty(src) then print("[Imperial LiveMap] Not Sending data, unit is off duty") TriggerClientEvent('ImperialCAD:livemap:client:ToggleTracking', src, false) return end
|
||||
if Config.debug then print("[Imperial LiveMap] Sending livemap data") end
|
||||
|
||||
PerformHttpRequest('https://map.imperial-solutions.net/livemap', function(err, text, headers) end, "POST", json.encode({
|
||||
version = 2,
|
||||
cid = communityId,
|
||||
discord = discord,
|
||||
x = data.x,
|
||||
y = data.y,
|
||||
speed = data.speed,
|
||||
icon = data.icon
|
||||
}), { ["Content-Type"] = "application/json" })
|
||||
end)
|
||||
@@ -0,0 +1,57 @@
|
||||
local currentPostal, currentCity, currentCounty
|
||||
|
||||
local function updateLocationData()
|
||||
local playerPed = PlayerPedId()
|
||||
local playerCoords = GetEntityCoords(playerPed)
|
||||
TriggerServerEvent('ImperialLocation:updateNearest', {x = playerCoords.x, y = playerCoords.y})
|
||||
end
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
updateLocationData()
|
||||
Citizen.Wait(Config.locationFrequency)
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterCommand("getlocation", function()
|
||||
local playerPed = PlayerPedId()
|
||||
local playerCoords = GetEntityCoords(playerPed)
|
||||
TriggerServerEvent('ImperialLocation:updateNearest', {x = playerCoords.x, y = playerCoords.y}, true)
|
||||
end, false)
|
||||
|
||||
RegisterNetEvent('ImperialLocation:PrintNearest')
|
||||
AddEventHandler('ImperialLocation:PrintNearest', function(nearestPostal, nearestCity, nearestCounty)
|
||||
local postalText = nearestPostal and nearestPostal.code or "None"
|
||||
local cityText = nearestCity and nearestCity.city or "None"
|
||||
local countyText = nearestCounty and nearestCounty.county or "None"
|
||||
TriggerEvent('chat:addMessage', {
|
||||
color = {255, 0, 0},
|
||||
multiline = true,
|
||||
args = {"Me", "Nearest Postal: " .. postalText .. ", City: " .. cityText .. ", County: " .. countyText}
|
||||
})
|
||||
end)
|
||||
|
||||
RegisterNetEvent('ImperialLocation:receiveNearest')
|
||||
AddEventHandler('ImperialLocation:receiveNearest', function(nearestPostal, nearestCity, nearestCounty)
|
||||
currentPostal = nearestPostal and nearestPostal.code or "None"
|
||||
currentCity = nearestCity and nearestCity.city or "None"
|
||||
currentCounty = nearestCounty and nearestCounty.county or "None"
|
||||
end)
|
||||
|
||||
function GetImperialPostal()
|
||||
return currentPostal or "None"
|
||||
end
|
||||
|
||||
exports('getPostal', GetImperialPostal)
|
||||
|
||||
function GetImperialCity()
|
||||
return currentCity or "None"
|
||||
end
|
||||
|
||||
exports('getCity', GetImperialCity)
|
||||
|
||||
function GetImperialCounty()
|
||||
return currentCounty or "None"
|
||||
end
|
||||
|
||||
exports('getCounty', GetImperialCounty)
|
||||
@@ -0,0 +1,117 @@
|
||||
local DATA_FOLDER = 'data'
|
||||
local POSTAL_FILE = DATA_FOLDER .. '/postals.json'
|
||||
local CITY_FILE = DATA_FOLDER .. '/cities.json'
|
||||
local COUNTY_FILE = DATA_FOLDER .. '/counties.json'
|
||||
|
||||
local playerLocationData = {}
|
||||
|
||||
local function loadData(fileName)
|
||||
local file = LoadResourceFile(GetCurrentResourceName(), fileName)
|
||||
if file then
|
||||
local data = json.decode(file)
|
||||
if data then
|
||||
print("Loaded " .. fileName .. " successfully with " .. #data .. " entries.")
|
||||
return data
|
||||
else
|
||||
print("[Error] JSON decoding failed for " .. fileName)
|
||||
return {}
|
||||
end
|
||||
else
|
||||
print("[Error] Failed to load " .. fileName)
|
||||
return {}
|
||||
end
|
||||
end
|
||||
|
||||
local postals, cities, counties = loadData(POSTAL_FILE), loadData(CITY_FILE), loadData(COUNTY_FILE)
|
||||
|
||||
local function calculateDistance(x1, y1, x2, y2)
|
||||
return math.sqrt((x2 - x1) ^ 2 + (y2 - y1) ^ 2)
|
||||
end
|
||||
|
||||
local function getNearestLocation(coords, locations)
|
||||
local nearest = nil
|
||||
local shortestDistance = math.huge
|
||||
for _, location in ipairs(locations) do
|
||||
local distance = calculateDistance(coords.x, coords.y, location.x, location.y)
|
||||
if distance < shortestDistance then
|
||||
nearest = location
|
||||
shortestDistance = distance
|
||||
end
|
||||
end
|
||||
return nearest
|
||||
end
|
||||
|
||||
RegisterNetEvent('ImperialLocation:updateNearest')
|
||||
AddEventHandler('ImperialLocation:updateNearest', function(playerCoords, shouldDisplay)
|
||||
local src = source
|
||||
local nearestPostal = getNearestLocation(playerCoords, postals)
|
||||
local nearestCity = getNearestLocation(playerCoords, cities)
|
||||
local nearestCounty = getNearestLocation(playerCoords, counties)
|
||||
|
||||
playerLocationData[src] = {
|
||||
postal = nearestPostal,
|
||||
city = nearestCity,
|
||||
county = nearestCounty
|
||||
}
|
||||
|
||||
TriggerClientEvent('ImperialLocation:receiveNearest', src, nearestPostal, nearestCity, nearestCounty)
|
||||
|
||||
if shouldDisplay then
|
||||
TriggerClientEvent('ImperialLocation:PrintNearest', src, nearestPostal, nearestCity, nearestCounty)
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterCommand("debugLocationData", function(src)
|
||||
print("^3[IMPERIAL DEBUG]^7 Dumping all player location data:")
|
||||
for playerId, data in pairs(playerLocationData) do
|
||||
print(("Player %s:"):format(playerId))
|
||||
print(" Postal:", data.postal and data.postal.code or "None")
|
||||
print(" City: ", data.city and data.city.city or "None")
|
||||
print(" County:", data.county and data.county.county or "None")
|
||||
end
|
||||
end, true)
|
||||
|
||||
RegisterCommand("debugCoordsLocation", function(src)
|
||||
local coords = { x = 1909.0826, y = 3654.7751 }
|
||||
local postal = exports["ImperialCAD"]:getNearestPostalFromCoords(coords)
|
||||
local city = exports["ImperialCAD"]:getNearestCityFromCoords(coords)
|
||||
local county = exports["ImperialCAD"]:getNearestCountyFromCoords(coords)
|
||||
|
||||
print("^3[IMPERIAL DEBUG]^7 Nearest location info for coords: x=" .. coords.x .. ", y=" .. coords.y)
|
||||
print(" Postal:", postal)
|
||||
print(" City: ", city)
|
||||
print(" County:", county)
|
||||
end, true)
|
||||
|
||||
exports('getPostal', function(playerId)
|
||||
return playerLocationData[playerId] and playerLocationData[playerId].postal.code or "Unkown"
|
||||
end)
|
||||
|
||||
exports('getCity', function(playerId)
|
||||
return playerLocationData[playerId] and playerLocationData[playerId].city.city or "Unkown"
|
||||
end)
|
||||
|
||||
exports('getCounty', function(playerId)
|
||||
return playerLocationData[playerId] and playerLocationData[playerId].county.county or "Unkown"
|
||||
end)
|
||||
|
||||
AddEventHandler('playerDropped', function()
|
||||
playerLocationData[source] = nil
|
||||
end)
|
||||
|
||||
exports('getNearestPostalFromCoords', function(coords)
|
||||
local location = getNearestLocation(coords, postals)
|
||||
return location and location.code or "Unknown"
|
||||
end)
|
||||
|
||||
exports('getNearestCityFromCoords', function(coords)
|
||||
local location = getNearestLocation(coords, cities)
|
||||
return location and location.city or "Unknown"
|
||||
end)
|
||||
|
||||
exports('getNearestCountyFromCoords', function(coords)
|
||||
local location = getNearestLocation(coords, counties)
|
||||
return location and location.county or "Unknown"
|
||||
end)
|
||||
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
local tabletVisible = false
|
||||
local tabletProp = nil
|
||||
|
||||
local function Notify(message)
|
||||
local fullMessage = "[IMPERIAL] " .. message
|
||||
SetNotificationTextEntry("STRING")
|
||||
AddTextComponentString(fullMessage)
|
||||
DrawNotification(false, true)
|
||||
end
|
||||
|
||||
local function closeTablet()
|
||||
local ped = GetPlayerPed(-1)
|
||||
|
||||
ClearPedTasks(ped)
|
||||
|
||||
if tabletProp and DoesEntityExist(tabletProp) then
|
||||
DeleteEntity(tabletProp)
|
||||
tabletProp = nil
|
||||
end
|
||||
|
||||
Citizen.Wait(100)
|
||||
|
||||
SetNuiFocus(false, false)
|
||||
SendNUIMessage({
|
||||
type = "HIDE_TABLET"
|
||||
})
|
||||
tabletVisible = false
|
||||
return { success = true, message = "Closed successfully" }
|
||||
end
|
||||
|
||||
AddEventHandler('onResourceStop', function(resourceName)
|
||||
|
||||
if (GetCurrentResourceName() ~= resourceName) then
|
||||
return
|
||||
end
|
||||
|
||||
closeTablet()
|
||||
|
||||
Citizen.Wait(100)
|
||||
print("Tablet resource stopped, closing and deleting tablet props")
|
||||
|
||||
if tabletProp and DoesEntityExist(tabletProp) then
|
||||
DeleteEntity(tabletProp)
|
||||
tabletProp = nil
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
RegisterNUICallback('closeTablet', function(data, cb)
|
||||
closeTablet()
|
||||
cb({success = true, message = "Tablet closed via JavaScript"})
|
||||
end)
|
||||
|
||||
RegisterCommand("tablet", function(source, args, rawCommand)
|
||||
local ped = GetPlayerPed(-1)
|
||||
local currentVehicle = GetVehiclePedIsIn(ped, false)
|
||||
|
||||
if Config.tabletCarRestriction and GetVehicleClass(currentVehicle) ~= 18 then Notify("You must be in a Emergency Vehicle to use your Imperial Tablet.") return end
|
||||
|
||||
if IsEntityPlayingAnim(ped, "amb@code_human_in_bus_passenger_idles@female@tablet@base", "base", 3) then
|
||||
closeTablet()
|
||||
else
|
||||
|
||||
RequestAnimDict("amb@code_human_in_bus_passenger_idles@female@tablet@base")
|
||||
while not HasAnimDictLoaded("amb@code_human_in_bus_passenger_idles@female@tablet@base") do
|
||||
Citizen.Wait(100)
|
||||
end
|
||||
|
||||
tabletProp = CreateObject(GetHashKey("prop_cs_tablet"), 0, 0, 0, true, true, true)
|
||||
AttachEntityToEntity(
|
||||
tabletProp, ped, GetPedBoneIndex(ped, 60309),
|
||||
0.03, 0.002, -0.02,
|
||||
0.0, 0.0, 0.0,
|
||||
true, true, false, true, 1, true
|
||||
)
|
||||
|
||||
TaskPlayAnim(ped, "amb@code_human_in_bus_passenger_idles@female@tablet@base", "base", 8.0, -8.0, -1, 50, 0, false, false, false)
|
||||
|
||||
Citizen.Wait(200)
|
||||
SetNuiFocus(true, true)
|
||||
SendNUIMessage({
|
||||
type = "DISPLAY_TABLET"
|
||||
})
|
||||
tabletVisible = true
|
||||
end
|
||||
end, false)
|
||||
|
||||
RegisterKeyMapping('Tablet', 'Open / close your tablet.', 'keyboard', 'PERIOD')
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
Citizen.Wait(0)
|
||||
if IsControlJustReleased(0, 200) then
|
||||
if tabletVisible then
|
||||
closeTablet()
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -0,0 +1,57 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Imperial CAD | Tablet</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
}
|
||||
.monitor {
|
||||
display: none;
|
||||
width: 1600px;
|
||||
height: 800px;
|
||||
background-color: #000;
|
||||
border: 15px solid #444;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
.background-text {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 1;
|
||||
font-size: 50px;
|
||||
font-family: 'Arial', sans-serif;
|
||||
color: rgba(255, 255, 255, 0.2);
|
||||
pointer-events: none;
|
||||
}
|
||||
.screen {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: none;
|
||||
position: absolute;
|
||||
z-index: 2;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="monitor">
|
||||
<div class="background-text">ImperialCAD</div>
|
||||
<iframe class="screen" src="https://imperialcad.app/auth?type=tablet" sandbox="allow-popups allow-scripts allow-same-origin allow-forms allow-modals allow-presentation"></iframe>
|
||||
</div>
|
||||
<script src="script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,35 @@
|
||||
let tabletVisible = false;
|
||||
|
||||
function toggleTablet(show) {
|
||||
const monitor = document.querySelector('.monitor');
|
||||
monitor.style.display = show ? 'block' : 'none';
|
||||
tabletVisible = show;
|
||||
|
||||
fetch(`https://${GetParentResourceName()}/setNuiFocus`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
focus: show,
|
||||
cursor: show
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
window.addEventListener('message', function(event) {
|
||||
if (event.data.type === "DISPLAY_TABLET") {
|
||||
toggleTablet(true);
|
||||
} else if (event.data.type === "HIDE_TABLET") {
|
||||
toggleTablet(false);
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener('keydown', function(e) {
|
||||
if (e.key === "Escape" && tabletVisible) {
|
||||
toggleTablet(false);
|
||||
fetch(`https://${GetParentResourceName()}/closeTablet`, {
|
||||
method: 'POST'
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,118 @@
|
||||
--[[
|
||||
DONT TOUCH THIS FILE UNLESS YOU KNOW WHAT YOUR DOING!
|
||||
--]]
|
||||
|
||||
if Config.isQB then
|
||||
|
||||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
RegisterNetEvent('qb-vehicleshop:client:buyShowroomVehicle')
|
||||
AddEventHandler('qb-vehicleshop:client:buyShowroomVehicle', function(vehicleModel, plate, source)
|
||||
|
||||
Citizen.Wait(2000)
|
||||
|
||||
local src = source
|
||||
|
||||
local ped = PlayerPedId()
|
||||
if IsPedSittingInAnyVehicle(ped) then
|
||||
local vehicle = GetVehiclePedIsIn(ped, false)
|
||||
local vehicleHash = GetEntityModel(vehicle)
|
||||
local vehicleModelName = GetDisplayNameFromVehicleModel(vehicleHash) -- Ensure this matches showroom model if needed
|
||||
local colorName = GetVehicleColorName(vehicle)
|
||||
local makeName = GetVehicleMakeName(vehicleModelName)
|
||||
|
||||
if vehicleModelName == "CARNOTFOUND" or vehicleModelName == nil then
|
||||
vehicleModelName = "UNKNOWN"
|
||||
TriggerEvent("notify", "Model Unknown, Proceeding anyways...")
|
||||
end
|
||||
|
||||
local data = {
|
||||
ssn = GetResourceKvpString("civ_ssn"),
|
||||
make = makeName or "UNKNOWN",
|
||||
color = colorName or "UNKNOWN",
|
||||
vehicle = vehicleModelName,
|
||||
plate = plate
|
||||
}
|
||||
|
||||
if Config.debug then
|
||||
print("Vehicle purchase detected: " .. vehicleModelName .. " | Plate: " .. plate .. " | Sending to the best cad in the world...")
|
||||
print(plate .. " " .. data.ssn)
|
||||
end
|
||||
|
||||
if data.ssn then
|
||||
TriggerServerEvent('ImperialCAD:CreateVehicle', data, src)
|
||||
TriggerEvent("notify", "Vehicle has been sent to the DMV.")
|
||||
if Config.debug then
|
||||
TriggerEvent("notify", vehicleModelName .. " has been sent to the DMV, " .. (colorName or "UNKNOWN") .. " is color and " .. (makeName or "UNKNOWN") .. " is make.")
|
||||
end
|
||||
else
|
||||
TriggerEvent("notify", "Couldn't register in DMV, No active civilian profile.")
|
||||
end
|
||||
else
|
||||
TriggerEvent("notify", "Unable to register this vehicle, Try '/regveh' instead")
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
end --end of qb
|
||||
|
||||
if Config.isQBX then
|
||||
|
||||
if Config.debug then print("Client FW script for qbx loaded") end
|
||||
|
||||
-- Very hacky lazy workaround - I need to improve this
|
||||
RegisterNetEvent('qbx_vehicleshop:imperial:client:boughtshowroomvehicle')
|
||||
AddEventHandler('qbx_vehicleshop:imperial:client:boughtshowroomvehicle', function()
|
||||
|
||||
if Config.debug then print("Client received showroom vehicle purchase event!") end
|
||||
Citizen.Wait(3000)
|
||||
TriggerEvent("notify", "Please do not leave your vehicle, Registering to ImperialCAD")
|
||||
|
||||
local src = source
|
||||
|
||||
local ped = PlayerPedId()
|
||||
if IsPedSittingInAnyVehicle(ped) then
|
||||
local vehicle = GetVehiclePedIsIn(ped, false)
|
||||
local vehicleHash = GetEntityModel(vehicle)
|
||||
local vehicleModelName = GetDisplayNameFromVehicleModel(vehicleHash) -- Ensure this matches showroom model if needed
|
||||
local colorName = GetVehicleColorName(vehicle) -- This global in in ImperialCAD, this could conflict with another resources global if misused
|
||||
local makeName = GetVehicleMakeName(vehicleModelName) -- This global in in ImperialCAD, this could conflict with another resources global if misused
|
||||
local plate = GetVehicleNumberPlateText(vehicle)
|
||||
|
||||
if vehicleModelName == "CARNOTFOUND" or vehicleModelName == nil then
|
||||
vehicleModelName = "UNKNOWN"
|
||||
TriggerEvent("notify", "Model Unknown, Proceeding anyways...")
|
||||
end
|
||||
|
||||
local data = {
|
||||
ssn = GetResourceKvpString("civ_ssn"),
|
||||
make = makeName or "UNKNOWN",
|
||||
color = colorName or "UNKNOWN",
|
||||
vehicle = vehicleModelName,
|
||||
plate = plate
|
||||
}
|
||||
|
||||
if Config.debug then
|
||||
print("? Vehicle purchase detected: " .. vehicleModelName .. " | Plate: " .. plate .. " | Sending to the best cad in the world...")
|
||||
print(plate .. " " .. data.ssn)
|
||||
end
|
||||
|
||||
if data.ssn then
|
||||
TriggerServerEvent('ImperialCAD:QBXFramework:CreateVehicle', data, src)
|
||||
TriggerEvent("notify", "Vehicle has been sent to the DMV.")
|
||||
if Config.debug then
|
||||
TriggerEvent("notify", vehicleModelName .. " has been sent to the DMV, " .. (colorName or "UNKNOWN") .. " is color and " .. (makeName or "UNKNOWN") .. " is make.")
|
||||
end
|
||||
else
|
||||
TriggerEvent("notify", "Couldn't register in DMV, No active civilian profile.")
|
||||
end
|
||||
else
|
||||
TriggerEvent("notify", "Unable to register this vehicle, Try '/regveh' instead")
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
|
||||
|
||||
end --end of qbx
|
||||
|
||||
@@ -0,0 +1,613 @@
|
||||
--[[
|
||||
Imperial Export for FiveM
|
||||
DO NOT EDIT THIS FILE UNLESS YOU KNOW WHAT YOUR DOING!
|
||||
]]--
|
||||
|
||||
local function getDiscordId(src)
|
||||
if src == nil then return false end
|
||||
local identifiers = GetPlayerIdentifiers(src)
|
||||
for _, v in pairs(identifiers) do
|
||||
if string.sub(v, 1, 8) == "discord:" then
|
||||
return string.gsub(v, "discord:", "")
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
if Config.isQB then
|
||||
|
||||
local QBCore = exports['qb-core']:GetCoreObject({'Functions'})
|
||||
|
||||
-- Hook into the player character load event
|
||||
RegisterNetEvent('qb-multicharacter:server:loadUserData')
|
||||
AddEventHandler('qb-multicharacter:server:loadUserData', function(cData)
|
||||
local src = source
|
||||
local discordId = getDiscordId(src)
|
||||
|
||||
if Config.debug then
|
||||
print("✅ QBCore Load User Detected, Loading Character Data: " .. json.encode(cData) .. " | Source: " .. src)
|
||||
end
|
||||
|
||||
local charinfo = cData.charinfo
|
||||
local fname = charinfo.firstname or "N?A"
|
||||
local lname = charinfo.lastname or "N?A"
|
||||
local gender = charinfo.gender or "N?A"
|
||||
local dob = charinfo.birthdate or "N?A"
|
||||
local phone = charinfo.phone or "N?A"
|
||||
|
||||
-- Extract required values
|
||||
local citizenid = cData.citizenid
|
||||
local commId = GetConvar("imperial_community_id", "")
|
||||
|
||||
if not citizenid or citizenid == "" then
|
||||
print("❌ ERROR: Citizen ID is missing!")
|
||||
return
|
||||
end
|
||||
|
||||
if not commId or commId == "" then
|
||||
print("❌ ERROR: Community ID is missing! Check your server config.")
|
||||
return
|
||||
end
|
||||
|
||||
-- Check if character exists in CAD
|
||||
exports["ImperialCAD"]:GetCharacter(citizenid, commId, function(success, resultData)
|
||||
if success then
|
||||
print("✅ Character Data Found in CAD for CitizenID: " .. citizenid)
|
||||
if Config.debug then
|
||||
print("Result Data: " .. json.encode(resultData))
|
||||
end
|
||||
|
||||
local data = {
|
||||
ssn = resultData.ssn,
|
||||
name = resultData.Name,
|
||||
address = resultData.address,
|
||||
age = resultData.age
|
||||
}
|
||||
|
||||
TriggerClientEvent('ImperialCAD:setActiveCiv', src, data)
|
||||
|
||||
else
|
||||
|
||||
if Config.QBRegCurrent then -- If QBRegCurrent is true then
|
||||
|
||||
if Config.debug then
|
||||
print("⚠️ Character NOT found in CAD. Creating new entry...")
|
||||
end
|
||||
|
||||
else -- If QBRegCurrent is not true then (false)
|
||||
|
||||
if Config.debug then
|
||||
print("⚠️ Character NOT found in CAD. Will not Create new entry config is set to false")
|
||||
end
|
||||
|
||||
return end
|
||||
|
||||
if gender == 0 then
|
||||
gender = "MALE"
|
||||
elseif gender == 1 then
|
||||
gender = "FEMALE"
|
||||
end
|
||||
|
||||
|
||||
-- If character isnt found, create a new one
|
||||
exports["ImperialCAD"]:NewCharacter({
|
||||
users_discordID = discordId,
|
||||
Fname = fname,
|
||||
Mname = "",
|
||||
Lname = lname,
|
||||
Birthdate = dob,
|
||||
race = "nil",
|
||||
hairC = "nil",
|
||||
eyeC = "nil",
|
||||
height = "6'",
|
||||
weight = "150",
|
||||
postal = nil,
|
||||
address = "nil",
|
||||
gender = gender,
|
||||
city = "nil",
|
||||
county = "nil",
|
||||
phonenum = phone,
|
||||
dlstatus = "VALID",
|
||||
citizenid = citizenid
|
||||
}, function(createSuccess, createResult)
|
||||
if createSuccess then
|
||||
print("✅ New Character Created in CAD for CitizenID: " .. citizenid)
|
||||
if Config.debug then
|
||||
print("Result Data: " .. json.encode(createResult))
|
||||
end
|
||||
|
||||
local eventdata = json.decode(createResult)
|
||||
|
||||
local data = {
|
||||
ssn = eventdata.response.ssn,
|
||||
name = eventdata.response.name,
|
||||
address = "Unkown Address",
|
||||
age = eventdata.response.age
|
||||
}
|
||||
|
||||
TriggerClientEvent('ImperialCAD:setActiveCiv', src, data)
|
||||
|
||||
else
|
||||
print("⚠️ ERROR: Failed to create character in CAD for CitizenID: " .. citizenid)
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
end)
|
||||
end)
|
||||
|
||||
-- Hook into the character creation event
|
||||
RegisterNetEvent('qb-multicharacter:server:createCharacter')
|
||||
AddEventHandler('qb-multicharacter:server:createCharacter', function(cData)
|
||||
local src = source
|
||||
local discordId = getDiscordId(src)
|
||||
|
||||
if Config.debug then
|
||||
print("Received Character Data (Pre-Delay): " .. json.encode(cData))
|
||||
end
|
||||
|
||||
-- Wait a few seconds for the data to be properly created
|
||||
Wait(3000) -- 3 seconds
|
||||
|
||||
-- Fetch the updated player data from QBCore
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
|
||||
if Player then
|
||||
local citizenid = Player.PlayerData.citizenid
|
||||
local charinfo = Player.PlayerData.charinfo
|
||||
local firstname = cData.firstname
|
||||
local lastname = cData.lastname
|
||||
local birthdate = cData.birthdate
|
||||
local gender = cData.gender
|
||||
local nationality = cData.nationality
|
||||
local phone = cData.phone
|
||||
local account = cData.account
|
||||
|
||||
if gender == 0 then
|
||||
gender = "MALE"
|
||||
elseif gender == 1 then
|
||||
gender = "FEMALE"
|
||||
end
|
||||
|
||||
if Config.debug then
|
||||
print("✅ Character Created After Delay:")
|
||||
print("Citizen ID: " .. citizenid)
|
||||
print("Discord ID: " .. discordId)
|
||||
print("First Name: " .. firstname)
|
||||
print("Last Name: " .. lastname)
|
||||
print("Birthdate: " .. birthdate)
|
||||
print("Gender: " .. gender)
|
||||
end
|
||||
|
||||
-- Call the NewCharacter function to send data to the API
|
||||
exports["ImperialCAD"]:NewCharacter({
|
||||
users_discordID = discordId,
|
||||
Fname = firstname,
|
||||
Mname = "",
|
||||
Lname = lastname,
|
||||
Birthdate = birthdate,
|
||||
race = "nil",
|
||||
hairC = "nil",
|
||||
eyeC = "nil",
|
||||
height = "6'",
|
||||
weight = "150",
|
||||
postal = nil,
|
||||
address = "nil",
|
||||
gender = gender,
|
||||
city = "nil",
|
||||
county = "nil",
|
||||
phonenum = phone,
|
||||
dlstatus = "VALID",
|
||||
citizenid = citizenid
|
||||
}, function(success, resultData)
|
||||
if success then
|
||||
print("✅ Character Created in CAD")
|
||||
if Config.debug then
|
||||
print("Result Data: " .. json.encode(resultData))
|
||||
end
|
||||
|
||||
local eventdate = json.decode(resultData)
|
||||
|
||||
local data = {
|
||||
ssn = eventdate.response.ssn,
|
||||
name = eventdate.response.name,
|
||||
address = "Unkown Address",
|
||||
age = eventdate.response.age
|
||||
}
|
||||
|
||||
TriggerClientEvent('ImperialCAD:setActiveCiv', src, data)
|
||||
|
||||
else
|
||||
print("⚠️ ERROR: Could not create character in CAD.")
|
||||
end
|
||||
end)
|
||||
else
|
||||
print("⚠️ ERROR: Could not retrieve player data after delay!")
|
||||
end
|
||||
end)
|
||||
|
||||
-- Hook into the character deletion event
|
||||
RegisterNetEvent('qb-multicharacter:server:deleteCharacter')
|
||||
AddEventHandler('qb-multicharacter:server:deleteCharacter', function(citizenid)
|
||||
local src = source
|
||||
local discordId = getDiscordId(src)
|
||||
|
||||
if Config.debug then
|
||||
print("Received Character Deletion Request: " .. citizenid)
|
||||
end
|
||||
|
||||
exports["ImperialCAD"]:DeleteCharacter({
|
||||
users_discordID = discordId,
|
||||
citizenid = citizenid
|
||||
}, function(success, resultData)
|
||||
if success then
|
||||
print("✅ Character was deleted in CAD")
|
||||
else
|
||||
print("⚠️ ERROR: Could not delete character in CAD.")
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('ImperialCAD:QBFramework:CreateVehicle')
|
||||
AddEventHandler('ImperialCAD:QBFramework:CreateVehicle', function(data, source)
|
||||
local src = source
|
||||
local discordId = getDiscordId(src)
|
||||
local vehicle = data.vehicle
|
||||
local plate = data.plate
|
||||
local color = data.color
|
||||
local make = data.make
|
||||
|
||||
if Config.debug then
|
||||
print("✅ Vehicle purchase recevied: " .. vehicle .. " Purchased by " .. data.ssn .. " | Plate: " .. plate .. " Color is " .. color .. " | make is " .. make)
|
||||
end
|
||||
|
||||
exports["ImperialCAD"]:CreateVehicle({
|
||||
ssn = data.ssn,
|
||||
model = data.vehicle,
|
||||
plate = data.plate,
|
||||
year = "2015",
|
||||
make = make,
|
||||
color = color
|
||||
}, function(success, resultData)
|
||||
if success then
|
||||
print("✅ Vehicle registered successfully to CAD.")
|
||||
end
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
-- NAT2K15 Integration
|
||||
if Config.isNAT2K15 then
|
||||
|
||||
FWN = Config.resourceName
|
||||
NAT = exports[FWN]:getServerFunctions()
|
||||
|
||||
-- Hook into the player character load event
|
||||
RegisterNetEvent("NAT2K15:CHECKSQL")
|
||||
AddEventHandler("NAT2K15:CHECKSQL", function(steam, discord, first_name, last_name, twt, dept, dob, gender, data, clientFramework)
|
||||
local src = source
|
||||
local discordId = getDiscordId(src)
|
||||
|
||||
if Config.debug then
|
||||
print("✅ NatFW Load User Detected, Loading Character Data: " .. json.encode(data) .. " | Source: " .. src)
|
||||
end
|
||||
|
||||
local charinfo = data
|
||||
local fname = first_name
|
||||
local lname = last_name
|
||||
local gender = gender
|
||||
local dob = dob
|
||||
local phone = ""
|
||||
|
||||
-- Extract required values
|
||||
local citizenid = data.char_id
|
||||
local commId = GetConvar("imperial_community_id", "")
|
||||
|
||||
if not citizenid or citizenid == "" then
|
||||
print("❌ ERROR: Citizen ID is missing!")
|
||||
return
|
||||
end
|
||||
|
||||
if not commId or commId == "" then
|
||||
print("❌ ERROR: Community ID is missing! Check your server config.")
|
||||
return
|
||||
end
|
||||
|
||||
-- Check if character exists in CAD
|
||||
|
||||
if Config.debug then
|
||||
print("Checking for character in CAD with CitizenID: " .. citizenid)
|
||||
end
|
||||
|
||||
exports["ImperialCAD"]:GetCharacter(citizenid, commId, function(success, resultData)
|
||||
if success then
|
||||
print("✅ Character Data Found in CAD for CitizenID: " .. citizenid)
|
||||
if Config.debug then
|
||||
print("Result Data: " .. json.encode(resultData))
|
||||
end
|
||||
else
|
||||
print("⚠️ Character NOT found in CAD. Creating new entry...")
|
||||
|
||||
if gender == "Male" then
|
||||
gender = "MALE"
|
||||
elseif gender == "Female" then
|
||||
gender = "FEMALE"
|
||||
end
|
||||
|
||||
|
||||
-- If character isnt found, create a new one
|
||||
exports["ImperialCAD"]:NewCharacter({
|
||||
users_discordID = discordId,
|
||||
Fname = fname,
|
||||
Mname = "",
|
||||
Lname = lname,
|
||||
Birthdate = dob,
|
||||
race = "nil",
|
||||
hairC = "nil",
|
||||
eyeC = "nil",
|
||||
height = "6'",
|
||||
weight = "150",
|
||||
postal = nil,
|
||||
address = "nil",
|
||||
gender = gender,
|
||||
city = "nil",
|
||||
county = "nil",
|
||||
phonenum = phone,
|
||||
dlstatus = "VALID",
|
||||
citizenid = citizenid
|
||||
}, function(createSuccess, createResult)
|
||||
if createSuccess then
|
||||
print("✅ New Character Created in CAD for CitizenID: " .. citizenid)
|
||||
if Config.debug then
|
||||
print("Result Data: " .. json.encode(createResult))
|
||||
end
|
||||
else
|
||||
print("⚠️ ERROR: Failed to create character in CAD for CitizenID: " .. citizenid)
|
||||
end
|
||||
end)
|
||||
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
-- Hook into the character deletion event
|
||||
RegisterNetEvent("NAT2K15:DELETEUSER")
|
||||
AddEventHandler("NAT2K15:DELETEUSER", function(data)
|
||||
local src = source
|
||||
local discordId = getDiscordId(src)
|
||||
|
||||
local citizenid = data.char_id
|
||||
|
||||
if Config.debug then
|
||||
print("Received Character Deletion Request: " .. citizenid)
|
||||
end
|
||||
|
||||
exports["ImperialCAD"]:DeleteCharacter({
|
||||
users_discordID = discordId,
|
||||
citizenid = citizenid
|
||||
}, function(success, resultData)
|
||||
if success then
|
||||
print("✅ Character was deleted in CAD")
|
||||
else
|
||||
print("⚠️ ERROR: Could not delete character in CAD.")
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
|
||||
end -- end of nat
|
||||
|
||||
if Config.isQBX then -- Start of QBX, nothing in this works if not QBX
|
||||
|
||||
-- Hook into the player character load event
|
||||
RegisterNetEvent('QBCore:Server:OnPlayerLoaded')
|
||||
AddEventHandler('QBCore:Server:OnPlayerLoaded', function()
|
||||
local src = source
|
||||
local discordId = getDiscordId(src)
|
||||
|
||||
if Config.debug then
|
||||
print("✅ QBXCore Load User Detected, Requesting Character Data for Source: "..src)
|
||||
end
|
||||
|
||||
local data = exports.qbx_core:GetPlayer(source)
|
||||
local cData = data.PlayerData
|
||||
|
||||
if Config.debug then
|
||||
print('Recieved character data for '..src.." character data is: "..json.encode(cData))
|
||||
end
|
||||
|
||||
if not cData or cData == nil then
|
||||
print("Uhmmm, no information was found or the script failed. Returning instead")
|
||||
return end
|
||||
|
||||
local charinfo = cData.charinfo
|
||||
local fname = charinfo.firstname or "N?A"
|
||||
local lname = charinfo.lastname or "N?A"
|
||||
local gender = charinfo.gender or "N?A"
|
||||
local dob = charinfo.birthdate or "N?A"
|
||||
local phone = charinfo.phone or "N?A"
|
||||
|
||||
-- Extract required values
|
||||
local citizenid = cData.citizenid
|
||||
local commId = GetConvar("imperial_community_id", "")
|
||||
|
||||
if not citizenid or citizenid == "" then
|
||||
print("❌ ERROR: Citizen ID is missing!")
|
||||
return
|
||||
end
|
||||
|
||||
if not commId or commId == "" then
|
||||
print("❌ ERROR: Community ID is missing! Check your server config.")
|
||||
return
|
||||
end
|
||||
|
||||
-- Check if character exists in CAD
|
||||
exports["ImperialCAD"]:GetCharacter(citizenid, commId, function(success, resultData)
|
||||
if success then
|
||||
print("✅ Character Data Found in CAD for CitizenID: " .. citizenid)
|
||||
if Config.debug then
|
||||
print("Result Data: " .. json.encode(resultData))
|
||||
end
|
||||
|
||||
local res = resultData.response
|
||||
local data = {
|
||||
ssn = res.ssn,
|
||||
name = res.Name,
|
||||
address = res.address,
|
||||
age = res.age
|
||||
}
|
||||
|
||||
TriggerClientEvent('ImperialCAD:setActiveCiv', src, data)
|
||||
|
||||
else
|
||||
|
||||
if Config.debug then
|
||||
print("⚠️ Character NOT found in CAD. Creating new entry...")
|
||||
end
|
||||
|
||||
if gender == 0 then
|
||||
gender = "MALE"
|
||||
elseif gender == 1 then
|
||||
gender = "FEMALE"
|
||||
end
|
||||
|
||||
-- If character isnt found, create a new one
|
||||
exports["ImperialCAD"]:NewCharacter({
|
||||
users_discordID = discordId,
|
||||
Fname = fname,
|
||||
Mname = "",
|
||||
Lname = lname,
|
||||
Birthdate = dob,
|
||||
race = "nil",
|
||||
hairC = "nil",
|
||||
eyeC = "nil",
|
||||
height = "6'",
|
||||
weight = "150",
|
||||
postal = nil,
|
||||
address = "nil",
|
||||
gender = gender,
|
||||
city = "nil",
|
||||
county = "nil",
|
||||
phonenum = phone,
|
||||
dlstatus = "VALID",
|
||||
citizenid = citizenid
|
||||
}, function(createSuccess, createResult)
|
||||
if createSuccess then
|
||||
print("New Character Created in CAD for CitizenID: " .. citizenid)
|
||||
if Config.debug then
|
||||
print("Result Data: " .. json.encode(createResult))
|
||||
end
|
||||
|
||||
local eventdata = json.decode(createResult)
|
||||
|
||||
local data = {
|
||||
ssn = eventdata.response.ssn,
|
||||
name = eventdata.response.name,
|
||||
address = "Unknown Address",
|
||||
age = eventdata.response.age
|
||||
}
|
||||
|
||||
TriggerClientEvent('ImperialCAD:setActiveCiv', src, data)
|
||||
|
||||
else
|
||||
print("⚠️ ERROR: Failed to create character in CAD for CitizenID: " .. citizenid)
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
end)
|
||||
end)
|
||||
|
||||
-- Hook into the character deletion event
|
||||
RegisterNetEvent('qbx_core:server:deleteCharacter')
|
||||
AddEventHandler('qbx_core:server:deleteCharacter', function(citizenid)
|
||||
local src = source
|
||||
local discordId = getDiscordId(src)
|
||||
|
||||
if Config.debug then
|
||||
print("Received Character Deletion Request: " .. citizenid)
|
||||
end
|
||||
|
||||
exports["ImperialCAD"]:DeleteCharacter({
|
||||
users_discordID = discordId,
|
||||
citizenid = citizenid
|
||||
}, function(success, resultData)
|
||||
if success then
|
||||
print("✅ Character was deleted in CAD")
|
||||
else
|
||||
print("⚠️ ERROR: Could not delete character in CAD.")
|
||||
end
|
||||
end)
|
||||
end)
|
||||
-- Very hacky lazy workaround - I need to improve this | Purchasing
|
||||
RegisterNetEvent('qbx_vehicleshop:server:buyShowroomVehicle')
|
||||
AddEventHandler('qbx_vehicleshop:server:buyShowroomVehicle', function()
|
||||
|
||||
if Config.debug then print("Received QBX create new vehicle, registering for "..source) end
|
||||
TriggerClientEvent('qbx_vehicleshop:imperial:client:boughtshowroomvehicle', source)
|
||||
|
||||
end)
|
||||
-- Very hacky lazy workaround - I need to improve this | Financing
|
||||
RegisterNetEvent('qbx_vehicleshop:server:financeVehicle')
|
||||
AddEventHandler('qbx_vehicleshop:server:financeVehicle', function(downPayment, paymentAmount, buyVehicle)
|
||||
if Config.debug then print("Received QBX create new vehicle, finance") end
|
||||
TriggerClientEvent('qbx_vehicleshop:imperial:client:boughtshowroomvehicle', source)
|
||||
|
||||
end)
|
||||
--Another lazy hacky method, but vehicle financed by sales guy?
|
||||
RegisterNetEvent('qbx_vehicleshop:server:sellfinanceVehicle')
|
||||
AddEventHandler('qbx_vehicleshop:server:sellfinanceVehicle', function(downPayment, paymentAmount, vehicle, playerId)
|
||||
if Config.debug then print("Received QBX create new vehicle, finance sell by player") end
|
||||
TriggerClientEvent('qbx_vehicleshop:imperial:client:boughtshowroomvehicle', playerId)
|
||||
|
||||
end)
|
||||
--Another lazy hacky method, but vehicle purchase by sales guy?
|
||||
RegisterNetEvent('qbx_vehicleshop:server:sellShowroomVehicle')
|
||||
AddEventHandler('qbx_vehicleshop:server:sellShowroomVehicle', function(vehicle, playerId)
|
||||
if Config.debug then print("Received QBX create new vehicle, purchase sell by player") end
|
||||
TriggerClientEvent('qbx_vehicleshop:imperial:client:boughtshowroomvehicle', playerId)
|
||||
|
||||
end)
|
||||
|
||||
RegisterNetEvent('ImperialCAD:QBXFramework:CreateVehicle')
|
||||
AddEventHandler('ImperialCAD:QBXFramework:CreateVehicle', function(data, source)
|
||||
local src = source
|
||||
local discordId = getDiscordId(src)
|
||||
local vehicle = data.vehicle
|
||||
local plate = data.plate
|
||||
local color = data.color
|
||||
local make = data.make
|
||||
|
||||
if Config.debug then
|
||||
print("✅ Vehicle purchase recevied: " .. vehicle .. " Purchased by " .. data.ssn .. " | Plate: " .. plate .. " Color is " .. color .. " | make is " .. make)
|
||||
end
|
||||
|
||||
exports["ImperialCAD"]:CreateVehicle({
|
||||
ssn = data.ssn,
|
||||
model = data.vehicle,
|
||||
plate = data.plate,
|
||||
year = "2015",
|
||||
make = make,
|
||||
color = color
|
||||
}, function(success, resultData)
|
||||
if success then
|
||||
print("✅ Vehicle registered successfully to CAD.")
|
||||
else
|
||||
print("Unable to register vehicle to cad for: "..source)
|
||||
end
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
end -- end QBX
|
||||
@@ -0,0 +1,355 @@
|
||||
--[[
|
||||
Imperial Export for FiveM
|
||||
DO NOT EDIT THIS FILE UNLESS YOU KNOW WHAT YOUR DOING!
|
||||
]]--
|
||||
|
||||
local function checkConvar(name, description)
|
||||
local value = GetConvar(name, "")
|
||||
if not value or value == "" then
|
||||
error(string.format("Could not find required Convar '%s' for %s.", name, description))
|
||||
end
|
||||
end
|
||||
|
||||
checkConvar("imperial_community_id", "ImperialCAD Community ID")
|
||||
checkConvar("imperialAPI", "Imperial API key")
|
||||
|
||||
local function performAPIRequest(url, method, data, headers, callback)
|
||||
method = method:upper()
|
||||
|
||||
if method == "GET" then
|
||||
data = ""
|
||||
else
|
||||
data = json.encode(data)
|
||||
end
|
||||
|
||||
PerformHttpRequest(url, function(errorCode, resultData, resultHeaders, errorData)
|
||||
if errorCode ~= 200 then
|
||||
|
||||
if errorCode == 500 then
|
||||
callback(false, "^1[IMPERIAL_API_CALLBACK]^7 request failed: Temporary Internal Error, Unable to retreive CAD data.")
|
||||
return
|
||||
end
|
||||
|
||||
if Config.debug then
|
||||
print("^1[IMPERIAL_API_ERROR]^7 HTTP Error Code:", errorCode)
|
||||
if errorData and errorData ~= "" then
|
||||
print("^1[IMPERIAL_API_ERROR]^7 Response: " .. errorData)
|
||||
elseif resultData and resultData ~= "" then
|
||||
print("^1[IMPERIAL_API_ERROR]^7 Result Data (fallback): " .. resultData)
|
||||
end
|
||||
end
|
||||
|
||||
if callback then
|
||||
if errorData and errorData ~= "" then
|
||||
local jsonPart = errorData:match("{.*}")
|
||||
if jsonPart then
|
||||
callback(false, jsonPart)
|
||||
else
|
||||
callback(false, errorData)
|
||||
end
|
||||
else
|
||||
callback(false, "^1[IMPERIAL_API_CALLBACK]^7 request failed: No response data")
|
||||
end
|
||||
end
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
local status
|
||||
if resultData and resultData ~= "" then
|
||||
local ok, body = pcall(json.decode, resultData)
|
||||
if ok and type(body) == "table" then
|
||||
status = body.status -- "error", "RATE_LIMIT", "success", "BUSY", "LIMIT_REACHED", "USER_LIMIT", "RESERVED"
|
||||
end
|
||||
end
|
||||
|
||||
if status and status ~= "success" then
|
||||
if Config.debug then
|
||||
print("^1[IMPERIAL_API_STATUS]^7 Non-success status in 200 response:", status)
|
||||
print("^1[IMPERIAL_API_STATUS]^7 Raw Result Data:", resultData)
|
||||
end
|
||||
|
||||
if callback then
|
||||
callback(false, resultData or ("Status: " .. tostring(status)))
|
||||
end
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if callback then
|
||||
if resultData and resultData ~= "" then
|
||||
callback(true, resultData)
|
||||
else
|
||||
callback(true, "^1[IMPERIAL_API_CALLBACK]^7 request succeeded, But No response data was returned")
|
||||
end
|
||||
end
|
||||
|
||||
if Config.debug then
|
||||
print("^1[IMPERIAL_API_DEBUG]^7 Result Data: " .. tostring(resultData))
|
||||
end
|
||||
|
||||
end, method, data, headers)
|
||||
end
|
||||
|
||||
function NewCharacter(data, callback)
|
||||
local requestData = {
|
||||
commId = GetConvar("imperial_community_id", ""),
|
||||
users_discordID = data.users_discordID,
|
||||
Fname = data.Fname,
|
||||
Mname = data.Mname,
|
||||
Lname = data.Lname,
|
||||
Birthdate = data.Birthdate,
|
||||
gender = data.gender,
|
||||
race = data.race,
|
||||
hairC = data.hairC,
|
||||
eyeC = data.eyeC,
|
||||
height = data.height,
|
||||
weight = data.weight,
|
||||
postal = data.postal,
|
||||
address = data.address,
|
||||
city = data.city,
|
||||
county = data.county,
|
||||
phonenum = data.phonenum,
|
||||
dlstatus = data.dlstatus,
|
||||
citizenid = data.citizenid
|
||||
}
|
||||
local headers = {
|
||||
["Content-Type"] = "application/json",
|
||||
["APIKEY"] = GetConvar("imperialAPI", "")
|
||||
}
|
||||
performAPIRequest("https://imperialcad.app/api/1.1/wf/NewCharacter", "POST", requestData, headers, callback)
|
||||
|
||||
if Config.debug then
|
||||
print("[ImperialExport] Attemping to create a new civilian CAD character!")
|
||||
end
|
||||
end
|
||||
|
||||
function NewCharacterAdvanced(data, callback)
|
||||
local requestData = {
|
||||
commId = GetConvar("imperial_community_id", ""),
|
||||
Fname = data.Fname,
|
||||
Mname = data.Mname,
|
||||
Lname = data.Lname,
|
||||
Birthdate = data.Birthdate,
|
||||
gender = data.gender,
|
||||
race = data.race,
|
||||
hairC = data.hairC,
|
||||
eyeC = data.eyeC,
|
||||
height = data.height,
|
||||
weight = data.weight,
|
||||
postal = data.postal,
|
||||
address = data.address,
|
||||
city = data.city,
|
||||
county = data.county,
|
||||
state = data.state,
|
||||
phonenum = data.phonenum,
|
||||
licensedetails = {
|
||||
hasBoatLic = data.licensedetails.hasBoatLic,
|
||||
hasCDL = data.licensedetails.hasCDL,
|
||||
CDLNumber = data.licensedetails.CDLNumber,
|
||||
CDLStatus = data.licensedetails.CDLStatus,
|
||||
hasDL = data.licensedetails.hasDL,
|
||||
DLNumber = data.licensedetails.DLNumber,
|
||||
DLStatus = data.licensedetails.DLStatus,
|
||||
hasFirearmsCertification = data.licensedetails.hasFirearmsCertification,
|
||||
hasFishLic = data.licensedetails.hasFishLic,
|
||||
hasHuntLic = data.licensedetails.hasHuntLic
|
||||
},
|
||||
misc = {
|
||||
missing = data.misc.missing
|
||||
}
|
||||
}
|
||||
local headers = {
|
||||
["Content-Type"] = "application/json",
|
||||
["APIKEY"] = GetConvar("imperialAPI", "")
|
||||
}
|
||||
performAPIRequest("https://imperialcad.app/api/1.1/wf/NewAdvancedCharacter", "POST", requestData, headers, callback)
|
||||
|
||||
if Config.debug then
|
||||
print("[ImperialExport] Attemping to create a new civilian CAD character!")
|
||||
end
|
||||
end
|
||||
|
||||
function DeleteCharacter(data, callback)
|
||||
local requestData = {
|
||||
commId = GetConvar("imperial_community_id", ""),
|
||||
users_discordID = data.users_discordID,
|
||||
citizenid = data.citizenid
|
||||
}
|
||||
local headers = {
|
||||
["Content-Type"] = "application/json",
|
||||
["APIKEY"] = GetConvar("imperialAPI", "")
|
||||
}
|
||||
performAPIRequest("https://imperialcad.app/api/1.1/wf/DeleteCharacter", "POST", requestData, headers, callback)
|
||||
|
||||
if Config.debug then
|
||||
print("[ImperialExport] Attemping to delete civilian CAD character!")
|
||||
end
|
||||
end
|
||||
|
||||
function GetCharacter(charid, commId, callback)
|
||||
|
||||
if not charid or charid == "" then
|
||||
print("Invalid Character ID. It must not be empty.")
|
||||
if callback then callback(false, "Invalid Character ID") end
|
||||
return
|
||||
end
|
||||
|
||||
if not commId or commId == "" then
|
||||
print("Invalid Community ID. It must not be empty.")
|
||||
if callback then callback(false, "Invalid Community ID") end
|
||||
return
|
||||
end
|
||||
|
||||
local url = string.format(
|
||||
"http://imperialcad.app/api/1.1/wf/GetCharacter?charid=%s&commId=%s",
|
||||
charid,
|
||||
commId
|
||||
)
|
||||
|
||||
performAPIRequest(url, "GET", nil, nil, function(success, response)
|
||||
if response then
|
||||
local data = json.decode(response)
|
||||
if data.status == "success" then
|
||||
print("Character retrieved: " .. json.encode(data))
|
||||
if callback then callback(true, data) end
|
||||
else
|
||||
print("Character not found.")
|
||||
if callback then callback(false, "Character not found.") end
|
||||
end
|
||||
else
|
||||
print("API Request Failed: " .. response)
|
||||
if callback then callback(false, response) end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function GetCharacterAdvanced(Character, callback)
|
||||
|
||||
local firstname = Character.firstname
|
||||
local lastname = Character.lastname
|
||||
local commId = GetConvar("imperial_community_id", "")
|
||||
|
||||
if not firstname or not lastname then
|
||||
print("Invalid Character table. It must not be empty and must contain a firstname and lastname.")
|
||||
if callback then callback(false, "Invalid table") end
|
||||
return
|
||||
end
|
||||
|
||||
if not commId or commId == "" then
|
||||
print("Invalid Community ID. It must not be empty.")
|
||||
if callback then callback(false, "Invalid Community ID") end
|
||||
return
|
||||
end
|
||||
|
||||
local url = string.format(
|
||||
"http://imperialcad.app/api/1.1/wf/GetCharacterAdvanced?firstname=%s&lastname=%s&commId=%s",
|
||||
firstname,
|
||||
lastname,
|
||||
commId
|
||||
)
|
||||
|
||||
performAPIRequest(url, "GET", nil, nil, function(success, response)
|
||||
if response then
|
||||
local data = json.decode(response)
|
||||
if data.status == "success" then
|
||||
print("[ADVANCED] Character retrieved: " .. json.encode(data.response))
|
||||
if callback then callback(true, data) end
|
||||
elseif data.status == "error" then
|
||||
print("[ADVANCED] Character not found.")
|
||||
if callback then callback(true, data) end
|
||||
else
|
||||
print("[ADVANCED] Character not found, Not an expected result")
|
||||
if callback then callback(false, "Character not found.") end
|
||||
end
|
||||
else
|
||||
print("API Request Failed: " .. response)
|
||||
if callback then callback(false, response) end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function CreateVehicle(data, callback)
|
||||
local requestData = {
|
||||
commId = GetConvar("imperial_community_id", ""),
|
||||
ssn = data.ssn,
|
||||
vehicleModel = data.model,
|
||||
plate = data.plate,
|
||||
year = data.year or "2015",
|
||||
make = data.make or "UNKNOWN",
|
||||
color = data.color
|
||||
}
|
||||
local headers = {
|
||||
["Content-Type"] = "application/json",
|
||||
["APIKEY"] = GetConvar("imperialAPI", "")
|
||||
}
|
||||
performAPIRequest("https://imperialcad.app/api/1.1/wf/registerVehicle", "POST", requestData, headers, callback)
|
||||
|
||||
if Config.debug then
|
||||
print("[ImperialExport] Attemping to reigster " .. data.plate .. " to CAD!")
|
||||
end
|
||||
end
|
||||
|
||||
function SetActiveCiv(data, callback)
|
||||
local requestData = {
|
||||
commId = GetConvar("imperial_community_id", ""),
|
||||
users_discordID = data.users_discordID,
|
||||
ssn = data.ssn
|
||||
}
|
||||
local headers = {
|
||||
["Content-Type"] = "application/json",
|
||||
["APIKEY"] = GetConvar("imperialAPI", "")
|
||||
}
|
||||
performAPIRequest("https://imperialcad.app/api/1.1/wf/setActiveCivilian", "POST", requestData, headers, callback)
|
||||
|
||||
if Config.debug then
|
||||
print(string.format("[ImperialExport] Attemping to set ssn %s as active civ for %s in CAD!", data.ssn, data.users_discordID))
|
||||
end
|
||||
end
|
||||
|
||||
function CreateVehicleAdvanced(data, callback)
|
||||
local requestData = {
|
||||
commId = GetConvar("imperial_community_id", ""),
|
||||
vehicleData = {
|
||||
plate = data.vehicleData.plate,
|
||||
model = data.vehicleData.model,
|
||||
Make = data.vehicleData.Make,
|
||||
color = data.vehicleData.color,
|
||||
year = data.vehicleData.year,
|
||||
regState = data.vehicleData.regState,
|
||||
regStatus = data.vehicleData.regStatus,
|
||||
regExpDate = data.vehicleData.regExpDate,
|
||||
vin = data.vehicleData.vin,
|
||||
stolen = data.vehicleData.stolen
|
||||
},
|
||||
vehicleInsurance = {
|
||||
hasInsurance = data.vehicleInsurance.hasInsurance,
|
||||
insuranceStatus = data.vehicleInsurance.insuranceStatus,
|
||||
insurancePolicyNum = data.vehicleInsurance.insurancePolicyNum
|
||||
},
|
||||
vehicleOwner = {
|
||||
ownerSSN = data.vehicleOwner.ownerSSN,
|
||||
ownerFirstName = data.vehicleOwner.ownerFirstName,
|
||||
ownerLastName = data.vehicleOwner.ownerLastName,
|
||||
ownerGender = data.vehicleOwner.ownerGender,
|
||||
ownerAddress = data.vehicleOwner.ownerAddress,
|
||||
ownerCity = data.vehicleOwner.ownerCity
|
||||
}
|
||||
}
|
||||
local headers = {
|
||||
["Content-Type"] = "application/json",
|
||||
["APIKEY"] = GetConvar("imperialAPI", "")
|
||||
}
|
||||
performAPIRequest("https://imperialcad.app/api/1.1/wf/registeradvancedvehicle", "POST", requestData, headers, callback)
|
||||
|
||||
if Config.debug then
|
||||
print("[ImperialExport_AdvancedVehReg] Attemping to register " .. requestData.vehicleData.plate .. " to CAD!")
|
||||
end
|
||||
end
|
||||
|
||||
exports('GetCharacter', GetCharacter)
|
||||
exports('NewCharacter', NewCharacter)
|
||||
exports('DeleteCharacter', DeleteCharacter)
|
||||
exports('CreateVehicle', CreateVehicle)
|
||||
exports('CreateVehicleAdvanced', CreateVehicleAdvanced)
|
||||
exports('SetActiveCiv', SetActiveCiv)
|
||||
@@ -0,0 +1,286 @@
|
||||
--[[
|
||||
Imperial Export for FiveM
|
||||
DO NOT EDIT THIS FILE UNLESS YOU KNOW WHAT YOUR DOING!
|
||||
]]--
|
||||
|
||||
local function checkConvar(name, description)
|
||||
local value = GetConvar(name, "")
|
||||
if not value or value == "" then
|
||||
error(string.format("Could not find required Convar '%s' for %s.", name, description))
|
||||
end
|
||||
print(string.format("%s '%s' found.", description, name))
|
||||
end
|
||||
|
||||
checkConvar("imperial_community_id", "ImperialCAD Community ID")
|
||||
checkConvar("imperialAPI", "Imperial API key")
|
||||
|
||||
local function performAPIRequest(url, data, headers, callback)
|
||||
PerformHttpRequest(url, function(errorCode, resultData, resultHeaders, errorData)
|
||||
if errorCode ~= 200 then
|
||||
|
||||
if errorCode == 500 then
|
||||
callback(false, "^1[IMPERIAL_API_CALLBACK]^7 request failed: ImperialCAD is having trouble, Unable to retreive CAD data.")
|
||||
return
|
||||
end
|
||||
|
||||
if Config.debug then
|
||||
print("^1[IMPERIAL_API_ERROR]^7 HTTP Error Code:", errorCode)
|
||||
if errorData and errorData ~= "" then
|
||||
print("^1[IMPERIAL_API_ERROR]^7 Response: " .. errorData)
|
||||
elseif resultData and resultData ~= "" then
|
||||
print("^1[IMPERIAL_API_ERROR]^7 Result Data (fallback): " .. resultData)
|
||||
end
|
||||
end
|
||||
|
||||
if callback then
|
||||
if errorData and errorData ~= "" then
|
||||
local jsonPart = errorData:match("{.*}")
|
||||
if jsonPart then
|
||||
callback(false, jsonPart)
|
||||
else
|
||||
callback(false, errorData)
|
||||
end
|
||||
else
|
||||
callback(false, "^1[IMPERIAL_API_CALLBACK]^7 request failed: No response data")
|
||||
end
|
||||
end
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
local status
|
||||
if resultData and resultData ~= "" then
|
||||
local ok, body = pcall(json.decode, resultData)
|
||||
if ok and type(body) == "table" then
|
||||
status = body.status -- "error", "RATE_LIMIT", "success", "BUSY", "LIMIT_REACHED", "USER_LIMIT", "RESERVED", etc.
|
||||
end
|
||||
end
|
||||
|
||||
if status and status ~= "success" then
|
||||
if Config.debug then
|
||||
print("^1[IMPERIAL_API_STATUS]^7 Non-success Result Data:", resultData)
|
||||
end
|
||||
if callback then
|
||||
callback(false, resultData or ("Status: " .. tostring(status)))
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if callback then
|
||||
if resultData and resultData ~= "" then
|
||||
callback(true, resultData)
|
||||
else
|
||||
callback(true, "^1[IMPERIAL_API_CALLBACK]^7 request succeeded, But No response data was returned")
|
||||
end
|
||||
end
|
||||
|
||||
if Config.debug then
|
||||
print("^1[IMPERIAL_API_DEBUG]^7 Result Data: " .. tostring(resultData))
|
||||
end
|
||||
|
||||
end, 'POST', json.encode(data), headers)
|
||||
end
|
||||
|
||||
function Create911Call(data, callback)
|
||||
local data = {
|
||||
commId = GetConvar("imperial_community_id", ""),
|
||||
name = data.name,
|
||||
street = data.street,
|
||||
cross_street = data.crossStreet,
|
||||
info = data.info,
|
||||
postal = data.postal,
|
||||
city = data.city,
|
||||
county = data.county
|
||||
}
|
||||
local headers = {
|
||||
["Content-Type"] = "application/json",
|
||||
["APIKEY"] = GetConvar("imperialAPI", "")
|
||||
}
|
||||
performAPIRequest("https://imperialcad.app/api/1.1/wf/911", data, headers, callback)
|
||||
|
||||
if Config.debug then
|
||||
print("[Imperial_Export_Create911Call] Attemping to create a 911 call!")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function DeleteCall(data, callback)
|
||||
local data = {
|
||||
callId = data.callId,
|
||||
discordId = data.discordId,
|
||||
communityId = GetConvar("imperial_community_id", "")
|
||||
}
|
||||
local headers = {
|
||||
["Content-Type"] = "application/json",
|
||||
["APIKEY"] = GetConvar("imperialAPI", "")
|
||||
}
|
||||
performAPIRequest("https://imperialcad.app/api/1.1/wf/CallDelete", data, headers, callback)
|
||||
|
||||
if Config.debug then
|
||||
print("[Imperial_Export_DeleteCall] Attemping to delete a call!")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function CreateCall(data, callback)
|
||||
local data = {
|
||||
commId = GetConvar("imperial_community_id", ""),
|
||||
users_discordID = data.users_discordID,
|
||||
street = data.street,
|
||||
cross_street = data.crossStreet,
|
||||
postal = data.postal,
|
||||
city = data.city,
|
||||
county = data.county,
|
||||
info = data.info,
|
||||
nature = data.nature,
|
||||
status = data.status,
|
||||
priority = data.priority
|
||||
}
|
||||
local headers = {
|
||||
["Content-Type"] = "application/json",
|
||||
["APIKEY"] = GetConvar("imperialAPI", "")
|
||||
}
|
||||
performAPIRequest("https://imperialcad.app/api/1.1/wf/CallCreate", data, headers, callback)
|
||||
|
||||
if Config.debug then
|
||||
print("[Imperial_Export_CreateCall] Attemping to create a new call!")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function AttachCall(data, callback)
|
||||
local data = {
|
||||
commId = GetConvar("imperial_community_id", ""),
|
||||
users_discordID = data.users_discordID,
|
||||
callnum = data.callnum
|
||||
}
|
||||
local headers = {
|
||||
["Content-Type"] = "application/json",
|
||||
["APIKEY"] = GetConvar("imperialAPI", "")
|
||||
}
|
||||
performAPIRequest("https://imperialcad.app/api/1.1/wf/AttachCall", data, headers, callback)
|
||||
|
||||
if Config.debug then
|
||||
print("[Imperial_Export_AttachCall] Attemping to attach player "..source.." to call "..data.callnum)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function NewCallNote(data, callback)
|
||||
local data = {
|
||||
commId = GetConvar("imperial_community_id", ""),
|
||||
users_discordID = data.users_discordID,
|
||||
description = data.description
|
||||
}
|
||||
local headers = {
|
||||
["Content-Type"] = "application/json",
|
||||
["APIKEY"] = GetConvar("imperialAPI", "")
|
||||
}
|
||||
performAPIRequest("https://imperialcad.app/api/1.1/wf/callnote", data, headers, callback)
|
||||
|
||||
if Config.debug then
|
||||
print("[Imperial_Export_NewCallNote] Attemping to create a new call note!")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function Booter(data, callback)
|
||||
local data = {
|
||||
commId = GetConvar("imperial_community_id", ""),
|
||||
users_discordID = data.users_discordID,
|
||||
}
|
||||
local headers = {
|
||||
["Content-Type"] = "application/json",
|
||||
["APIKEY"] = GetConvar("imperialAPI", "")
|
||||
}
|
||||
if Config.debug then
|
||||
print("Discord ID:" .. data.users_discordID .. "Community ID:" .. data.commId)
|
||||
end
|
||||
|
||||
performAPIRequest("https://imperialcad.app/api/1.1/wf/offduty", data, headers, callback)
|
||||
|
||||
if Config.debug then
|
||||
print("[Imperial_Export_Booter] Attemping to boot a user from the cad!")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function Panic(data, callback)
|
||||
local data = {
|
||||
commId = GetConvar("imperial_community_id", ""),
|
||||
users_discordID = data.users_discordID,
|
||||
postal = data.postal,
|
||||
street = data.street
|
||||
}
|
||||
local headers = {
|
||||
["Content-Type"] = "application/json",
|
||||
["APIKEY"] = GetConvar("imperialAPI", "")
|
||||
}
|
||||
performAPIRequest("https://imperialcad.app/api/1.1/wf/panic", data, headers, callback)
|
||||
|
||||
if Config.debug then
|
||||
print("[Imperial_Export_Panic] Attemping to trigger a user panic in cad!")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function ClearPanic(callback)
|
||||
local data = {
|
||||
commId = GetConvar("imperial_community_id", "")
|
||||
}
|
||||
local headers = {
|
||||
["Content-Type"] = "application/json",
|
||||
["APIKEY"] = GetConvar("imperialAPI", "")
|
||||
}
|
||||
performAPIRequest("https://imperialcad.app/api/1.1/wf/clearpanic", data, headers, callback)
|
||||
|
||||
if Config.debug then
|
||||
print("[Imperial_Export_ClearPanic] Attemping to to clear a community panic")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function CheckPlate(data, callback)
|
||||
local data = {
|
||||
communityId = GetConvar("imperial_community_id", ""),
|
||||
plate = data.plate
|
||||
}
|
||||
local headers = {
|
||||
["Content-Type"] = "application/json",
|
||||
["APIKEY"] = GetConvar("imperialAPI", "")
|
||||
}
|
||||
performAPIRequest("https://imperialcad.app/api/1.1/wf/checkplate", data, headers, callback)
|
||||
|
||||
if Config.debug then
|
||||
print("[Imperial_Export_CheckPlate] Attempting to check the plate " .. data.plate)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function GetUnit(data, callback)
|
||||
local data = {
|
||||
communityId = GetConvar("imperial_community_id", ""),
|
||||
users_discordID = data.users_discordID
|
||||
}
|
||||
local headers = {
|
||||
["Content-Type"] = "application/json",
|
||||
["APIKEY"] = GetConvar("imperialAPI", "")
|
||||
}
|
||||
performAPIRequest("https://imperialcad.app/api/1.1/wf/GetUnit", data, headers, callback)
|
||||
|
||||
if Config.debug then
|
||||
print("[Imperial_Export_CheckPlate] Attempting to get unit" .. data.plate)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
exports('Create911Call', Create911Call)
|
||||
exports('DeleteCall', DeleteCall)
|
||||
exports('CreateCall', CreateCall)
|
||||
exports('AttachCall', AttachCall)
|
||||
exports('NewCallNote', NewCallNote)
|
||||
exports('Booter', Booter)
|
||||
exports('CheckPlate', CheckPlate)
|
||||
exports('Panic', Panic)
|
||||
exports('ClearPanic', ClearPanic)
|
||||
exports('GetUnit', GetUnit)
|
||||
@@ -0,0 +1,26 @@
|
||||
--[[
|
||||
Imperial Export for FiveM
|
||||
DO NOT EDIT THIS FILE UNLESS YOU KNOW WHAT YOUR DOING!
|
||||
]]--
|
||||
|
||||
function GenerateRandomString(length)
|
||||
local charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||
local result = ""
|
||||
for i = 1, length do
|
||||
local rand = math.random(1, #charset)
|
||||
result = result .. charset:sub(rand, rand)
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
--trys to find the discord ID
|
||||
function getDiscordId(src)
|
||||
if src == nil then return false end
|
||||
local identifiers = GetPlayerIdentifiers(src)
|
||||
for _, v in pairs(identifiers) do
|
||||
if string.sub(v, 1, 8) == "discord:" then
|
||||
return string.gsub(v, "discord:", "")
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"latestVersion": "1.2.4"
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user