feat(server/comands): claim veh command

This commit is contained in:
Andyyy7666
2025-01-18 14:41:41 +01:00
parent fe922e1b98
commit 9d4708f6d9
2 changed files with 56 additions and 2 deletions

View File

@@ -356,8 +356,9 @@ AddStateBagChangeHandler("locked", nil, function(bagName, key, value, reserved,
end) end)
end) end)
lib.callback.register("ND_Vehicles:getProps", function(netId) local function getProps(veh)
local veh = getVehFromNetId(netId) if not veh or not DoesEntityExist(veh) then return end
local props = lib.getVehicleProperties(veh) local props = lib.getVehicleProperties(veh)
local colorPrimary, colorSecondary = GetVehicleColours(veh) local colorPrimary, colorSecondary = GetVehicleColours(veh)
if not props then return end if not props then return end
@@ -368,7 +369,18 @@ lib.callback.register("ND_Vehicles:getProps", function(netId)
props.className = vehicleClassNames[GetVehicleClass(veh)] props.className = vehicleClassNames[GetVehicleClass(veh)]
props.makeName = GetLabelText(GetMakeNameFromVehicleModel(props.model)) props.makeName = GetLabelText(GetMakeNameFromVehicleModel(props.model))
props.modelName = GetLabelText(GetDisplayNameFromVehicleModel(props.model)) props.modelName = GetLabelText(GetDisplayNameFromVehicleModel(props.model))
return props return props
end
lib.callback.register("ND_Vehicles:getProps", function(netId)
local veh = getVehFromNetId(netId)
return getProps(veh)
end)
lib.callback.register("ND_Vehicles:getPropsFromCurrentVeh", function()
local veh = GetVehiclePedIsIn(cache.ped)
return getProps(veh)
end) end)
lib.callback.register("ND_Vehicles:getVehicleModelMakeLabel", function(model) lib.callback.register("ND_Vehicles:getVehicleModelMakeLabel", function(model)

View File

@@ -450,3 +450,45 @@ lib.addCommand("vehicle", {
Wait(100) Wait(100)
end end
end) end)
lib.addCommand("claim-veh", {
help = "Admin command, add a copy of the vehicle you're inside to players garage.",
restricted = "group.admin",
params = {
{
name = "target",
type = "playerId",
help = "Target player's server id"
}
}
}, function(source, args, raw)
local player = NDCore.getPlayer(source)
if not player then return end
local targetPlayer = NDCore.getPlayer(args.target)
if not targetPlayer then
return player.notify({
title = "Player not found!",
description = "Target player not found, make sure they select a charcter!",
type = "error"
})
end
local properties = lib.callback.await("ND_Vehicles:getPropsFromCurrentVeh", source)
if not properties then
return player.notify({
title = "Vehicle data not found!",
description = "The vehicle properties data was not found!",
type = "error"
})
end
NDCore.setVehicleOwned(targetPlayer.id, properties, true)
player.notify({
title = "Vehicle added!",
description = ("The vehicle has now been added to %s's garage!"):format(targetPlayer.name),
type = "success"
})
end)