Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions sonorancad/configuration/tablet_config.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
--[[

Sonoran Plugins

tablet_config Plugin Configuration

Put all needed configuration in this file.

]]

local config = {
enabled = true,
configVersion = "1.0",
pluginName = "tablet_config", -- name your plugin here
pluginAuthor = "Bushcowboy", -- author
requiresPlugins = {}, -- required plugins for this plugin to work, separated by commas

-- Auto-hide and access settings
AutoHideOnVehicleExit = true, -- if true, the cad will automatically hide when the player exits a vehicle
AllowMiniCadOnFoot = false, -- if true, player can access the cad while on foot

AccessRestrictions = {
RequireTabletItem = true, -- if true, player must have the tablet item to access the cad
TabletItemName = "sonoran_tablet", -- name of the tablet item
RestrictByJob = true, -- if true, player must have a job in the allowed jobs list to access the cad
RestrictByVehicle = false, -- if true, player must be in a vehicle in the allowed vehicles list to access the cad
AllowedJobs = {
"lspd",
"sheriff",
"ambulance",
"fire"
},
AllowedVehicles = {
"police",
"police2",
"police3",
"police4",
"fbi",
"fbi2",
"ambulance",
"firetruk"
}
}

}

if config.enabled then
Config.RegisterPluginConfig(config.pluginName, config)
end
20 changes: 12 additions & 8 deletions sonorancad/configuration/vehreg_config.dist.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,22 @@

local config = {
enabled = false,
pluginName = "vehreg", -- name your plugin here
pluginName = "vehreg", -- name your plugin here
pluginAuthor = "Jordan.#2139", -- author
configVersion = "1.3",
configVersion = "1.4",

reigsterCommand = "reg", -- Command to register car
reigsterCommand = "reg", -- Command to register car
defaultRegExpire = '01/02/2030', -- The default date that all registrations will expire
defaultRegStatus = 'VALID', -- The default status that all registrations will have | MUST BE IN CAPS
defaultRegStatus = 'VALID', -- The default status that all registrations will have | MUST BE IN CAPS

language = {
notInVeh = "Player Not In Vehicle... Please Ensure You're In A Vehicle And Try Again!",
noApiId = "API ID NOT LINKED TO AN ACCOUNT IN THIS COMMUNITY",
plateAlrRegisted = "This plate has already been registered to another person",
helpMsg = 'Register your current vehicle in CAD',
noCharFound = "No character found. Please ensure you are logged in to a character.",
incompleteCharData = "Character data is incomplete. Please ensure you have all required data filled out in CAD. Unable to register vehicle.",
incompleteCharData =
"Character data is incomplete. Please ensure you have all required data filled out in CAD. Unable to register vehicle.",
--[[
Placeholders:
{{PLATE}} = The plate of the vehicle
Expand All @@ -35,15 +36,18 @@ local config = {
plateUid = "plate",
typeUid = "type",
modelUid = "model",
makeUid = "make",
yearUid = "year",
statusUid = "status",
expiresUid = "_imtoih149",
},
customData = {
{
spawncode = "adder",
["adder"] = {
model = "Adder",
make = "Truffade",
year = 2013
},
{
["blista"] = {
spawncode = "blista",
model = "Blista",
}
Expand Down
4 changes: 3 additions & 1 deletion sonorancad/submodules/vehreg/cl_vehreg.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ CreateThread(function() Config.LoadPlugin("vehreg", function(pluginConfig)
local realName, make, year
if override then
realName = override.model
make = override.make
year = override.year
else
realName = GetLabelText(displayCode) -- e.g. “Adder”
end
TriggerServerEvent(GetCurrentResourceName() .. "::registerVeh", primary, plate, class, realName)
TriggerServerEvent(GetCurrentResourceName() .. "::registerVeh", primary, plate, class, realName, make, year)
end
end)
TriggerEvent("chat:addSuggestion", "/" .. pluginConfig.reigsterCommand,
Expand Down
225 changes: 117 additions & 108 deletions sonorancad/submodules/vehreg/sv_vehreg.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,17 @@ CreateThread(function()
end
return message
end
RegisterNetEvent(GetCurrentResourceName() .. '::registerVeh', function(primary, plate, class, realName)
local source = source
exports['sonorancad']:registerApiType('NEW_RECORD', 'general')
exports['sonorancad']:registerApiType('GET_CHARACTERS', 'civilian')
exports['sonorancad']:performApiRequest({
{
['apiId'] = GetIdentifiers(source)[Config.primaryIdentifier]
}
}, 'GET_CHARACTERS', function(res, err)
if err == 404 then
TriggerClientEvent('chat:addMessage', source, {
color = {
255,
0,
0
},
multiline = true,
args = {
'[CAD - ERROR] ',
pluginConfig.language.noApiId
}
})
return;
else
res = json.decode(res)
if not res or type(res) ~= 'table' then
RegisterNetEvent(GetCurrentResourceName() .. '::registerVeh',
function(primary, plate, class, realName, make, year)
local source = source
exports['sonorancad']:registerApiType('NEW_RECORD', 'general')
exports['sonorancad']:registerApiType('GET_CHARACTERS', 'civilian')
exports['sonorancad']:performApiRequest({
{
['apiId'] = GetIdentifiers(source)[Config.primaryIdentifier]
}
}, 'GET_CHARACTERS', function(res, err)
if err == 404 then
TriggerClientEvent('chat:addMessage', source, {
color = {
255,
Expand All @@ -44,12 +29,96 @@ CreateThread(function()
multiline = true,
args = {
'[CAD - ERROR] ',
pluginConfig.language.noCharFound or "No character found. Please ensure you are logged in to a character."
pluginConfig.language.noApiId
}
})
return;
else
res = json.decode(res)
if not res or type(res) ~= 'table' 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;
end
if #res < 1 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;
end
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
end
if #res < 1 then
end)
Citizen.Wait(1000)
if not pluginConfig.recordData then
notSetConfig = true
pluginConfig.recordData = {
colorUid = "color",
plateUid = "plate",
typeUid = "type",
modelUid = "model",
makeUid = "make",
yearUid = "year",
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.makeUid] = make,
[pluginConfig.recordData.yearUid] = year,
[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,
Expand All @@ -59,90 +128,30 @@ CreateThread(function()
multiline = true,
args = {
'[CAD - ERROR] ',
pluginConfig.language.noCharFound or "No character found. Please ensure you are logged in to a character."
pluginConfig.language.plateAlrRegisted
}
})
return;
end
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
end
end)
Citizen.Wait(1000)
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
}
})
else
local placeHolders = {
['{{PLATE}}'] = plate,
['{{FIRST}}'] = civData.first,
['{{LAST}}'] = civData.last
}
TriggerClientEvent('chat:addMessage', source, {
color = {
0,
255,
0
},
multiline = true,
args = {
'[CAD - SUCCESS] ',
placeholderReplace(pluginConfig.language.successReg, placeHolders)
}
})
end
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)
2 changes: 1 addition & 1 deletion sonorancad/version.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"requiresPlugins": []
},
"vehreg": {
"version": "1.3",
"version": "1.4",
"requiresPlugins": []
},
"wraithv2": {
Expand Down
Loading