From 74e4ccc2de7ad8a9d745dbc0d5db28368f8597bd Mon Sep 17 00:00:00 2001 From: Andyyy7666 <86536434+Andyyy7666@users.noreply.github.com> Date: Mon, 15 Jan 2024 19:48:24 +0100 Subject: [PATCH] feat: police vehicle callsigns mod --- server/vehicle.lua | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/server/vehicle.lua b/server/vehicle.lua index d6b0347..54d6849 100644 --- a/server/vehicle.lua +++ b/server/vehicle.lua @@ -90,6 +90,9 @@ function NDCore.getVehicle(entity) if saveProperties and self.id and self.owner then local properties = lib.callback.await("ND_Vehicles:getProps", NetworkGetEntityOwner(entity), self.netId) if properties then + if self.properties?.callsign then + properties.callsign = true + end MySQL.query("UPDATE nd_vehicles SET properties = ? WHERE id = ?", {json.encode(properties), self.id}) end end @@ -102,6 +105,11 @@ function NDCore.getVehicle(entity) if not DoesEntityExist(entity) then return end local properties = type(props) == "string" and json.decode(props) or props local state = Entity(entity).state + + if self.properties?.callsign then + properties.callsign = true + end + state.props = properties self.properties = properties @@ -406,11 +414,27 @@ function NDCore.spawnOwnedVehicle(source, vehicleId, coords, heading) if not vehicle or not vehicle.available or vehicle.owner ~= player.id then return end MySQL.query.await("UPDATE nd_vehicles SET stored = ? WHERE id = ?", {0, vehicleId}) + + local properties = vehicle.properties + if properties.callsign then + local callsign = player.getMetadata("callsign") + if not callsign or callsign == "" then goto skip end + + callsign = tostring(callsign) + if not callsign or callsign:len() ~= 3 then goto skip end + + properties.modFender = tonumber(callsign:sub(1, 1)) + properties.modRightFender = tonumber(callsign:sub(2, 2)) + properties.modRoof = tonumber(callsign:sub(3, 3)) + end + + ::skip:: + return NDCore.createVehicle({ owner = player.id, - model = vehicle.properties.model, + model = properties.model, coords = vec4(coords.x, coords.y, coords.z, coords.w or coords.heading or heading), - properties = vehicle.properties, + properties = properties, vehicleId = vehicleId, source = source })