Config File
Last updated
Last updated
Config = {
Locale = "en",
Discord = {
webhook = "https://discord.com/api/webhooks/1203097916907069440/7KzEpJ1iynGXrbVopAs5TmDjTUeP6V7mcoa5WOkdM1TkKcEAoBdLC-y2cdUkQIIcckde",
title = "Plate Changer",
color = "8D910B0B",
},
MinCharacter = 3, -- Update in html/index.html also
MaxCharacter = 7, -- Update in html/index.html also
Item = {
item = "change_plate",
JobRequired = false, -- {["police"] = true, []"mechanic"] = true} or false
RemoveItem = true,
}
}
-- Server Side change plate in database
Config.ChangePlateServer = function(src, oldplate, newplate)
local player_id = Ez_lib.Functions.GetPlayerUniqueIdentifier(src)
if Ez_lib.Shared.Framework == "qb-core" then
local vehexists = Ez_lib.Functions.ExecuteSql("SELECT * FROM player_vehicles WHERE plate = '"..oldplate.."' AND citizenid = '"..player_id.."'")
if vehexists[1] == nil then
Ez_lib.Shared.TriggerNotify(nil, Loc[Config.Locale].error["NotOwner"], 'error', src)
return false -- Not the owner
end
local platetaken = Ez_lib.Functions.ExecuteSql("SELECT * FROM player_vehicles WHERE plate = '"..newplate.."'")
if platetaken[1] ~= nil then
Ez_lib.Shared.TriggerNotify(nil, Loc[Config.Locale].error["PlateTaken"], 'error', src)
return false -- Plate already taken
end
local mods = json.decode(vehexists[1].mods)
mods.plate = newplate
Ez_lib.Functions.ExecuteSql("UPDATE player_vehicles SET mods = '"..json.encode(mods).."' WHERE plate = '"..oldplate.."' AND citizenid = '"..player_id.."'")
Ez_lib.Functions.ExecuteSql("UPDATE player_vehicles SET plate = '"..newplate.."' WHERE plate = '"..oldplate.."' AND citizenid = '"..player_id.."'")
return true -- Success
elseif Ez_lib.Shared.Framework == "es_extended" then
local vehexists = Ez_lib.Functions.ExecuteSql("SELECT * FROM owned_vehicles WHERE plate = '"..oldplate.."' AND owner = '"..player_id.."'")
if vehexists[1] == nil then
Ez_lib.Shared.TriggerNotify(nil, Loc[Config.Locale].error["NotOwner"], 'error', src)
return false
end
local platetaken = Ez_lib.Functions.ExecuteSql("SELECT * FROM owned_vehicles WHERE plate = '"..newplate.."'")
if platetaken[1] ~= nil then
Ez_lib.Shared.TriggerNotify(nil, Loc[Config.Locale].error["PlateTaken"], 'error', src)
return false
end
local vehicle = json.decode(vehexists[1].vehicle)
vehicle.plate = newplate
Ez_lib.Functions.ExecuteSql("UPDATE owned_vehicles SET vehicle = '"..json.encode(vehicle).."' WHERE plate = '"..oldplate.."' AND owner = '"..player_id.."'")
Ez_lib.Functions.ExecuteSql("UPDATE owned_vehicles SET plate = '"..newplate.."' WHERE plate = '"..oldplate.."' AND owner = '"..player_id.."'")
return true
else
-- Add your own framework here
print("Framework not supported")
return false
end
end
-- Client Side change plate in vehicle. Runs after server side change plate
Config.ChangePlateClient = function(newplate)
SetVehicleNumberPlateText(GetVehiclePedIsIn(PlayerPedId()), newplate)
if Ez_lib.Shared.Framework == "qb-core" then
local QBCore = exports['qb-core']:GetCoreObject()
TriggerEvent("vehiclekeys:client:SetOwner", newplate)
Ez_lib.Shared.TriggerNotify(nil, "Plate changed to "..newplate, "success")
local vehicleProps = QBCore.Functions.GetVehicleProperties(GetVehiclePedIsUsing(PlayerPedId()))
vehicleProps.plate = newplate
QBCore.Functions.SetVehicleProperties(GetVehiclePedIsUsing(PlayerPedId()), vehicleProps)
elseif Ez_lib.Shared.Framework == "es_extended" then
local ESX = exports['es_extended']:getSharedObject()
TriggerEvent("vehiclekeys:client:SetOwner", newplate)
Ez_lib.Shared.TriggerNotify(nil, "Plate changed to "..newplate, "success")
local vehicleProps = ESX.Game.GetVehicleProperties(GetVehiclePedIsIn(PlayerPedId()))
vehicleProps.plate = newplate
ESX.Game.SetVehicleProperties(GetVehiclePedIsIn(PlayerPedId()), vehicleProps)
else
-- Add your own framework here
print("Framework not supported")
end
end
-- DO NOT TOUCH BELOW THIS LINE
ResourceName = GetCurrentResourceName()