Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3.0.9: fix(wraithv2) Showing invalid on plate scan, feat(vehreg) Dynamic vehicle & char info #24

Merged
merged 8 commits into from
Dec 31, 2024
11 changes: 10 additions & 1 deletion sonorancad/configuration/vehreg_config.dist.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ local config = {
enabled = false,
pluginName = "vehreg", -- name your plugin here
pluginAuthor = "Jordan.#2139", -- author
configVersion = "1.1",
configVersion = "1.2",

reigsterCommand = "reg", -- Command to register car
defaultRegExpire = '01/02/2030', -- The default date that all registrations will expire
Expand All @@ -28,6 +28,15 @@ local config = {
{{LAST}} = The first name of the charactes currently active in CAD
]]
successReg = "Vehicle ({{PLATE}}) successfully registered to ^2{{FIRST}} {{LAST}}"
},
-- If you have changed your field UID's in CAD please update the corresponding values here. (Field UID goes in the quotes on the right)
recordData = {
colorUid = "color",
plateUid = "plate",
typeUid = "type",
modelUid = "model",
statusUid = "status",
expiresUid = "_imtoih149",
}
}

Expand Down
2 changes: 1 addition & 1 deletion sonorancad/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ games {'gta5'}

author 'Sonoran CAD'
description 'Sonoran CAD FiveM Integration'
version '3.0.8'
version '3.0.9'

server_scripts {
'core/http.js'
Expand Down
207 changes: 73 additions & 134 deletions sonorancad/submodules/vehreg/sv_vehreg.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
CreateThread(function()
Config.LoadPlugin('vehreg', function(pluginConfig)
if pluginConfig.enabled then
local civData = {}
local notSetConfig = false
local placeholderReplace = function(message, placeholderTable)
for k, v in pairs(placeholderTable) do
message = message:gsub(k, v)
Expand All @@ -9,25 +11,6 @@ CreateThread(function()
end
RegisterNetEvent(GetCurrentResourceName() .. '::registerVeh', function(primary, plate, class, realName)
local source = source
local first = nil;
local last = nil;
local dob = nil;
local sex = nil;
local mi = nil;
local age = nil;
local aka = nil;
local residence = nil;
local zip = nil;
local occupation = nil;
local height = nil;
local weight = nil;
local skin = nil;
local hair = nil;
local eyes = nil;
local emergencyContact = nil;
local emergencyRelationship = nil;
local emergencyContactNumber = nil;
local img = nil;
exports['sonorancad']:registerApiType('NEW_RECORD', 'general')
exports['sonorancad']:registerApiType('GET_CHARACTERS', 'civilian')
exports['sonorancad']:performApiRequest({
Expand Down Expand Up @@ -81,128 +64,84 @@ CreateThread(function()
})
return;
end
if #res[1].sections < 2 then
TriggerClientEvent('chat:addMessage', source, {
color = {
255,
0,
0
},
multiline = true,
args = {
'[CAD - ERROR] ',
pluginConfig.language.noCharFound or "No character found. Please ensure you are logged in to a character."
}
})
return;
for iterator, table in pairs(res[1].sections) do
if table.category == 0 then
for iterator, field in pairs(table.fields) do
civData[field.uid] = field.value
end
end
end
if #res[1].sections[2].fields < 18 then
TriggerClientEvent('chat:addMessage', source, {
color = {
255,
0,
0
},
multiline = true,
args = {
'[CAD - ERROR] ',
pluginConfig.language.incompleteCharData or "Character data is incomplete. Please ensure you have all required data filled out in CAD. Unable to register vehicle."
}
})
return;
end
first = res[1].sections[2].fields[1].value or "Unknown"
last = res[1].sections[2].fields[2].value or "Unknown"
mi = res[1].sections[2].fields[3].value or "Unknown"
dob = res[1].sections[2].fields[4].value or "Unknown"
age = res[1].sections[2].fields[5].value or "Unknown"
sex = res[1].sections[2].fields[6].value or "Unknown"
aka = res[1].sections[2].fields[7].value or "Unknown"
residence = res[1].sections[2].fields[8].value or "Unknown"
zip = res[1].sections[2].fields[9].value or "Unknown"
occupation = res[1].sections[2].fields[10].value or "Unknown"
height = res[1].sections[2].fields[11].value or "Unknown"
weight = res[1].sections[2].fields[12].value or "Unknown"
skin = res[1].sections[2].fields[13].value or "Unknown"
hair = res[1].sections[2].fields[14].value or "Unknown"
eyes = res[1].sections[2].fields[15].value or "Unknown"
emergencyContact = res[1].sections[2].fields[16].value or "Unknown"
emergencyRelationship = res[1].sections[2].fields[17].value or "Unknown"
emergencyContactNumber = res[1].sections[2].fields[18].value or "Unknown"
img = res[1].sections[1].fields[1].value or "Unknown"
end
end)
Citizen.Wait(1000)
if first ~= nil and last ~= nil then
exports['sonorancad']:performApiRequest({
{
['user'] = GetIdentifiers(source)[Config.primaryIdentifier],
['useDictionary'] = true,
['recordTypeId'] = 5,
['replaceValues'] = {
['first'] = first,
['last'] = last,
['mi'] = mi,
['dob'] = dob,
['age'] = age,
['sex'] = sex,
['aka'] = aka,
['residence'] = residence,
['zip'] = zip,
['occupation'] = occupation,
['height'] = height,
['weight'] = weight,
['skin'] = skin,
['hair'] = hair,
['eyes'] = eyes,
['emergencyContact'] = emergencyContact,
['emergencyRelationship'] = emergencyRelationship,
['emergencyContactNumber'] = emergencyContactNumber,
['color'] = primary,
['plate'] = plate,
['type'] = class,
['model'] = realName,
['status'] = pluginConfig.defaultRegStatus,
['_imtoih149'] = pluginConfig.defaultRegExpire,
['img'] = img
if not pluginConfig.recordData then
notSetConfig = true
pluginConfig.recordData = {
colorUid = "color",
plateUid = "plate",
typeUid = "type",
modelUid = "model",
statusUid = "status",
expiresUid = "_imtoih149",
}
warnLog('Record data not found in configuration. Using default values. Please update your configuration using the vehreg_config.dist.lua file located in the configuration folder')
end
if notSetConfig then
warnLog('Record data not found in configuration. Using default values. Please update your configuration using the vehreg_config.dist.lua file located in the configuration folder')
end
local replaceValues = {
[pluginConfig.recordData.colorUid] = primary,
[pluginConfig.recordData.plateUid] = plate,
[pluginConfig.recordData.typeUid] = class,
[pluginConfig.recordData.modelUid] = realName,
[pluginConfig.recordData.statusUid] = pluginConfig.defaultRegStatus,
[pluginConfig.recordData.expiresUid] = pluginConfig.defaultRegExpire
}
for k, v in pairs(civData) do
replaceValues[k] = v
end
exports['sonorancad']:performApiRequest({
{
['user'] = GetIdentifiers(source)[Config.primaryIdentifier],
['useDictionary'] = true,
['recordTypeId'] = 5,
['replaceValues'] = replaceValues
}
}, 'NEW_RECORD', function(res)
res = tostring(res)
if string.find(res, 'taken') ~= nil then
TriggerClientEvent('chat:addMessage', source, {
color = {
255,
0,
0
},
multiline = true,
args = {
'[CAD - ERROR] ',
pluginConfig.language.plateAlrRegisted
}
})
else
local placeHolders = {
['{{PLATE}}'] = plate,
['{{FIRST}}'] = civData.first,
['{{LAST}}'] = civData.last
}
}, 'NEW_RECORD', function(res)
res = tostring(res)
if string.find(res, 'taken') ~= nil then
TriggerClientEvent('chat:addMessage', source, {
color = {
255,
0,
0
},
multiline = true,
args = {
'[CAD - ERROR] ',
pluginConfig.language.plateAlrRegisted
}
})
else
local placeHolders = {
['{{PLATE}}'] = plate,
['{{FIRST}}'] = first,
['{{LAST}}'] = last
TriggerClientEvent('chat:addMessage', source, {
color = {
0,
255,
0
},
multiline = true,
args = {
'[CAD - SUCCESS] ',
placeholderReplace(pluginConfig.language.successReg, placeHolders)
}
TriggerClientEvent('chat:addMessage', source, {
color = {
0,
255,
0
},
multiline = true,
args = {
'[CAD - SUCCESS] ',
placeholderReplace(pluginConfig.language.successReg, placeHolders)
}
})
end
end)
end
})
end
end)
end)
end
end)
Expand Down
36 changes: 14 additions & 22 deletions sonorancad/submodules/wraithv2/sv_wraithv2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -204,28 +204,20 @@ if pluginConfig.enabled then
TriggerClientEvent('pNotify:SendNotification', source,
{text = ('<b style=\'color:yellow\'>' .. camCapitalized .. ' ALPR</b><br/>Plate: %s<br/>Status: %s<br/>%sOwner: %s'):format(plate:upper(), status, expires, owner),
type = 'success', queue = 'alpr', timeout = pluginConfig.notificationTimers.validReg, layout = 'centerLeft'})
if #boloData > 0 then
local flags = table.concat(boloData, ',')
TriggerClientEvent('pNotify:SendNotification', source, {text = ('<b style=\'color:red\'>BOLO ALERT!<br/>Plate: %s<br/>Flags: %s'):format(plate:upper(), flags), type = 'error', queue = 'bolo',
timeout = pluginConfig.notificationTimers.bolo, layout = 'centerLeft'})
TriggerEvent('SonoranCAD::wraithv2:BoloAlert', plate, flags)
TriggerClientEvent('SonoranCAD::wraithv2:PlaySound', source, 'bolo')
end
if #warrantData > 0 then
local warrants = table.concat(warrantData, ',')
TriggerClientEvent('pNotify:SendNotification', source, {text = ('<b style=\'color:red\'>WARRANT ALERT!<br/>Plate: %s<br/>Flags: %s'):format(plate:upper(), warrants), type = 'error', queue = 'warrant',
timeout = pluginConfig.notificationTimers.warrant, layout = 'centerLeft'})
TriggerEvent('SonoranCAD::wraithv2:WarrantAlert', plate, warrants)
TriggerClientEvent('SonoranCAD::wraithv2:PlaySound', source, 'warrant')
end
else
if pluginConfig.alertNoRegistration then
TriggerClientEvent('pNotify:SendNotification', source,
{text = '<b style=\'color:yellow\'>' .. camCapitalized .. ' ALPR</b><br/>Plate: ' .. plate:upper() .. '<br/>Status: Not Registered', type = 'warning', queue = 'alpr',
timeout = pluginConfig.notificationTimers.noReg, layout = 'centerLeft'})
TriggerEvent('SonoranCAD::wraithv2:NoRegAlert', plate)
TriggerClientEvent('SonoranCAD::wraithv2:PlaySound', source, 'registration')
end
end
if #boloData > 0 then
local flags = table.concat(boloData, ',')
TriggerClientEvent('pNotify:SendNotification', source, {text = ('<b style=\'color:red\'>BOLO ALERT!<br/>Plate: %s<br/>Flags: %s'):format(plate:upper(), flags), type = 'error', queue = 'bolo',
timeout = pluginConfig.notificationTimers.bolo, layout = 'centerLeft'})
TriggerEvent('SonoranCAD::wraithv2:BoloAlert', plate, flags)
TriggerClientEvent('SonoranCAD::wraithv2:PlaySound', source, 'bolo')
end
if #warrantData > 0 then
local warrants = table.concat(warrantData, ',')
TriggerClientEvent('pNotify:SendNotification', source, {text = ('<b style=\'color:red\'>WARRANT ALERT!<br/>Plate: %s<br/>Flags: %s'):format(plate:upper(), warrants), type = 'error', queue = 'warrant',
timeout = pluginConfig.notificationTimers.warrant, layout = 'centerLeft'})
TriggerEvent('SonoranCAD::wraithv2:WarrantAlert', plate, warrants)
TriggerClientEvent('SonoranCAD::wraithv2:PlaySound', source, 'warrant')
end
else
if pluginConfig.alertNoRegistration then
Expand Down
4 changes: 2 additions & 2 deletions sonorancad/version.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"resource": "3.0.8",
"resource": "3.0.9",
"testedFxServerVersion": "5932",
"submoduleConfigs": {
"callcommands": {
Expand Down Expand Up @@ -95,7 +95,7 @@
"requiresPlugins": []
},
"vehreg": {
"version": "1.0",
"version": "1.2",
"requiresPlugins": []
},
"wraithv2": {
Expand Down
Loading