58 lines
2.6 KiB
Lua
58 lines
2.6 KiB
Lua
RegisterNetEvent("advancedgarages:client:spawnVehiclePlate")
|
|
AddEventHandler("advancedgarages:client:spawnVehiclePlate", function(sourcePlayer, vehicleModel, vehiclePlate, targetPlayerName, vehicleType)
|
|
local plate = string.upper(vehiclePlate)
|
|
|
|
if not CheckVehicleType(vehicleModel, vehicleType) then
|
|
Notification(i18n.t("give_vehicle.invalid_type"), "error")
|
|
return
|
|
end
|
|
|
|
if not (IsModelInCdimage(vehicleModel) and IsModelValid(vehicleModel)) then
|
|
Notification(i18n.t("give_vehicle.invalid_model"), "error")
|
|
return
|
|
end
|
|
|
|
if not targetPlayerName then
|
|
Notification(i18n.t("give_vehicle.no_player_online"), "error")
|
|
return
|
|
end
|
|
|
|
TriggerServerCallback("advancedgarages:server:isPlateTaken", function(isTaken)
|
|
if not isTaken then
|
|
SpawnGiveVehicle(vehicleModel, plate, sourcePlayer, targetPlayerName, vehicleType)
|
|
Notification(i18n.t("give_vehicle.info", { model = vehicleModel, plate = plate, player = targetPlayerName }), "success")
|
|
Debug("The vehicle: " .. vehicleModel .. " with license plate: " .. plate .. " was delivered to the player: " .. targetPlayerName)
|
|
else
|
|
Notification(i18n.t("give_vehicle.plate_in_use"), "error")
|
|
end
|
|
end, plate)
|
|
end)
|
|
|
|
RegisterNetEvent("advancedgarages:client:addcar")
|
|
AddEventHandler("advancedgarages:client:addcar", function(sourceServerId, vehicleType, targetPlayerName)
|
|
local playerPed = GetPlayerPed(GetPlayerFromServerId(sourceServerId))
|
|
local currentVehicle = GetVehiclePedIsIn(playerPed, false)
|
|
local vehicleModel = GetDisplayNameFromVehicleModel(GetEntityModel(currentVehicle))
|
|
local vehiclePlate = GetVehicleNumberPlateText(currentVehicle)
|
|
|
|
if not CheckVehicleType(vehicleModel, vehicleType) then
|
|
Notification(i18n.t("give_vehicle.invalid_type"), "error")
|
|
return
|
|
end
|
|
|
|
if not (IsModelInCdimage(vehicleModel) and IsModelValid(vehicleModel)) then
|
|
Notification(i18n.t("give_vehicle.invalid_model"), "error")
|
|
return
|
|
end
|
|
|
|
TriggerServerCallback("advancedgarages:server:isPlateTaken", function(isTaken)
|
|
if not isTaken then
|
|
SpawnGiveVehicle(vehicleModel, vehiclePlate, sourceServerId, targetPlayerName, vehicleType, true)
|
|
Notification(i18n.t("give_vehicle.info", { model = vehicleModel, plate = vehiclePlate, player = targetPlayerName }), "success")
|
|
Debug("The vehicle: " .. vehicleModel .. " with license plate: " .. vehiclePlate .. " was delivered to the player: ")
|
|
else
|
|
Notification(i18n.t("give_vehicle.plate_in_use"), "error")
|
|
end
|
|
end, vehiclePlate)
|
|
end)
|