Skip to content

Commit

Permalink
feat: police vehicle callsigns mod
Browse files Browse the repository at this point in the history
  • Loading branch information
Andyyy7666 committed Jan 15, 2024
1 parent 005effa commit b732ad8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
11 changes: 8 additions & 3 deletions client/menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,16 @@ local function getDealerVehicles(categoryVehicles)
goto skip
end

local index = #values+1
if vehicleInfo.label then
AddTextEntryByHash(model, vehicleInfo.label)
values[#values+1] = vehicleInfo.label
else
values[#values+1] = getVehicleLabel(model)
values[index] = vehicleInfo.label
elseif not vehicleInfo.menuLabel then
values[index] = getVehicleLabel(model)
end

if vehicleInfo.menuLabel then
values[index] = vehicleInfo.menuLabel
end
::skip::
end
Expand Down
13 changes: 10 additions & 3 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ local function getVehicleCategory(dealership, model, price)
for i=1, #vehicles do
local info = vehicles[i]
if info.model == model and info.price == price then
return category, info.price
return category, info
end
end
end
Expand Down Expand Up @@ -237,10 +237,12 @@ RegisterNetEvent("ND_Dealership:purchaseVehicle", function(stored, dealer, info)
local dealership = data.dealerships?[dealer]
if not info or not model or not properties or not dealership then return end

local category, price = getVehicleCategory(dealership, model, info.price)
local category, categoryInfo = getVehicleCategory(dealership, model, info.price)
if not category or not lib.table.contains(dealership.categories, category) then return end

local price = categoryInfo.price
local player = NDCore.getPlayer(src)

if price > 0 then
if not player or player.bank < price then
return player.notify({
Expand All @@ -254,7 +256,12 @@ RegisterNetEvent("ND_Dealership:purchaseVehicle", function(stored, dealer, info)
player.deductMoney("bank", price, "Vehicle purchase")
end

local vehicleId = NDCore.setVehicleOwned(player.id, json.decode(properties), true)
local vehicleProps = json.decode(properties)
if categoryInfo.callsign then
vehicleProps.callsign = true
end

local vehicleId = NDCore.setVehicleOwned(player.id, vehicleProps, true)
local spawns = dealership.spawns
local coords = spawns and getAvailableParking(spawns)
if not vehicleId or not coords then
Expand Down

0 comments on commit b732ad8

Please sign in to comment.