m-Scripts
  • m-Scripts Documentation
  • QBCore
    • Jobs
      • 🚗[QB] TunerJob
        • 🛠️Installation
        • ❓Common Questions
        • 🗒️Config
      • 🍞[QB] BeanMachine
        • 🛠️Installation
        • 🗒️Config
      • 🍔[QB] Burgershot
        • 🛠️Installation
        • 🗒️Config
      • 🍈[QB] CoolBeans
        • 🛠️Installation
        • 🗒️Config
      • 🚚[QB] Deliveries
        • 🛠️Installation
        • 📃Config
          • 📃config_functions
      • 🍎[QB] Farming
        • 🛠️Installation
        • 🗒️Config
      • 🐟[QB] Fishing
        • 🛠️Installation
        • 🗒️Config
          • 📄config_diving
          • 📄config_fishingnet
          • 📄config_fishingrod
          • 📄config_functions
          • 📄config_language
          • 📄config_seashells
          • 📄config_tournament
          • 📄config_upgrades
      • 🚛[QB] Garbage
        • 🛠️Installation
        • 🗒️Config
      • 🗝️[QB] GoldRush
        • 🛠️Installation
        • 🗒️Config
      • ⛰️[QB] Hunting
        • 🛠️Installation
        • 🗒️Config
      • 🪵[QB] Lumberjack
        • 🛠️Installation
        • 🗒️Config
      • ⛏️[QB] Mining
        • 🛠️Installation
        • 🗒️Config
      • 🛢️[QB] Oil Factory
        • 🛠️Installation
        • ❓Common Questions
        • 🗒️Config
      • ☕[QB] Pond Coffee
        • 🛠️Installation
        • ❓Common Questions
        • 🗒️Config
      • 🚚[QB] Trucker
        • 🛠️Installation
        • 🗒️Config
          • 📄Functions
          • 📄Language
      • 🥃[QB] Vanilla
        • 🛠️Installation
        • 🗒️Config
      • 🛻[QB] Mechanic Run
        • 🛠️Installation
        • 🗒️Config
      • 🥃[QB] Bahamas
        • 🛠️Installation
        • 📄Config
      • 🔫[QB] Ammunation
        • 🛠️Installation
        • 📄Config
      • 🐟[QB] Pearls
        • 🛠️Installation
        • 📄Config
      • 🔓[QB] Impound
        • 🛠️Installation
        • 📄Config
        • ✅Garages
      • 🚘[QB] Vehicleshop
        • 🛠️Installation
        • 📄Config
          • Functions
          • Job
          • Language
        • ❓Common Questions
    • General
      • 🏕️[QB] Camping
        • 🛠️Installation
        • 🗒️Config
          • Consumables
          • Language
      • 🎄[QB] Christmas
        • 🛠️Installation
        • 🗒️Config
      • 🎃[QB] Halloween
        • 🛠️Installation
        • 🗒️Config
      • 📔[QB] Insurance
        • 🛠️Installation
        • 🖥️Compatibilities
        • 🗒️Config
        • 🔁Server-Exports
      • 🏘️[QB] Vespucci
        • 🛠️Installation
        • 🗒️Config
          • Brewery
          • Digital Den
          • Masquerade
          • Pro Bikes
      • 🏖️[QB] Beach Activities
        • 🛠️Installation
        • 🗒️Config
      • 🚘[QB] Car Rental
        • 🛠️Installation
        • 📄Config
        • 🖥️Compatibilities
      • ✈️[QB] Sky Racing
        • 🛠️Installation
        • 📄Config
      • 🚘[QB] Car Wash
        • 🛠️Installation
        • 📄Config
      • 🪨[QB] Grinder
        • 🛠️Installation
        • 📄Config
      • 📹[QB] SpyCams & CCTV's
        • 🛠️Installation
        • 📄Config
      • 🏠[QB] Motel
        • 🛠️Installation
        • 📄Config
        • 🖥️Compatibilities
      • 🏚️[QB] Job Center
        • 📄Config
      • 🛠️[QB] Crafting
        • 🛠️Installation
        • 📄Config
          • Functions
          • Language
    • Illegal
      • 🔫[QB] Gangs
        • 🛠️Installation
        • 🗒️Config
      • 🔔[QB] Drug Selling
        • 🗒️Config
      • 🌱[QB] Drugs
        • 🛠️Installation
        • 🗒️Config
      • 🍯[QB] Craft Potion
        • 🛠️Installation
        • 🗒️Config
      • 🅱️[QB] Blackmarket
        • 🛠️Installation
        • 🗒️Config
          • config_functions
          • config_language
      • 🚗[QB] Car Thief
        • 🗒️Config
      • 🏠[QB] House Robbery
        • 🛠️Installation
        • 🗒️Config
      • 💎[QB] Jewelry
        • 🛠️Installation
        • 🗒️Config
          • Functions
          • Language
      • ®️[QB] Mini Robberys
        • 🛠️Installation
        • 🗒️Config
      • 💰[QB] MoneyWash
        • 🛠️Installation
        • 🗒️Config
          • Functions
          • Language
      • 🔫[QB] Rob NPC
        • 🛠️Installation
        • 🗒️Config
      • 🏃‍♂️[QB] Runs
        • 🛠️Installation
        • 🗒️Config
          • Functions
          • Language
      • ⛽[QB] Steal Fuel
        • 🛠️Installation
        • 🗒️Config
          • Functions
          • Language
      • 🏬[QB] Store Robbery
        • 🛠️Installation
        • 🗒️Config
          • Functions
          • Language
      • 🪛[QB] Scrapyard
        • 🛠️Installation
        • 🗒️Config
          • Functions
          • Language
      • 👾[QB] Territories
        • 🛠️Installation
        • 📄Config
          • Functions
      • 🏨[QB] GoPostal
        • 🛠️Installation
        • 📄Config
          • Functions
          • Language
          • S_utils
  • ESX
    • Jobs
      • 🚗[ESX] Tunerjob
        • ❗Dependencies
        • 🛠️Installation
          • ℹ️OX-Inventory
          • ℹ️QS-Inventory
        • 🗒️Config
          • BlacklistVehicles
          • Craft
          • Functions
          • Language
          • Targets
          • Wraps
          • Events
        • ❓Common Questions
      • 🚚[ESX] Trucker
        • 🛠️Installation
        • 🗒️Config
          • 📄Functions
          • 📄Language
      • 🪵[ESX] Lumberjack
        • 🛠️Installation
        • 🗒️Config
      • 🛻[ESX] Mechanic Run
        • 🛠️Installation
        • 🗒️Config
      • ⛏️[ESX] Mining
        • 🛠️Installation
        • 🗒️Config
      • 🎣[ESX] Fishing
        • 🛠️Installation
        • 📄Config
          • Functions
          • Language
          • Diving
          • Fishingnet
          • Fishingrod
          • Seashells
          • Tournament
          • Upgrades
    • General
      • 🚘[ESX] Car Rental
        • 🛠️Installation
        • 🗒️Config
      • 📃[ESX] Insurance
        • 🛠️Installation
        • 🖥️Compatibilities
        • 📄Config
        • 🔁 Server-Exports
      • 🚘[ESX] Car Wash
        • 🛠️Installation
        • 📄Config
      • 📹[ESX] SpyCams & CCTV's
        • 🛠️Installation
        • 📄Config
        • 🏠[ESX] Motel
          • 🛠️Installation
          • 📄Config
          • 🖥️Compatibilities
      • 🛠️[ESX] Crafting
        • 🛠️Installation
        • 📄Config
          • Functions
          • Language
      • 🎄[ESX] Christmas
        • 🛠️Installation
        • 📄Configs
    • Illegal
      • 🔫[ESX] Gangs
        • 🛠️Installation
        • 📄Config
        • ❓Common Questions
      • 🅱️[ESX] Blackmarket
        • 🛠️Installation
        • 🗒️Config
          • config_functions
          • config_language
      • 🏨[ESX] GoPostal
        • 🛠️Installation
        • 📄Config
          • Functions
          • Language
          • S_utils
  • Both Framework
    • Scripts
      • 🚗Car Rebuild
        • 🛠️Installation
        • 🗒️Config
      • 🗺️City Guide
        • 🛠️Installation
        • 📄Config
          • Functions
          • Language
      • 🛒Shops
        • 📄Config
        • 🛠️Installation
      • 🔁Reputation
        • 📄Config
        • 🛠️Installation
        • ⁉️Exports & Commands
          • Server Exports
          • Commands
      • 💤AFK System
        • 📄Configs
        • 🛠️Installation
      • 🚗Garages
        • 🛠️Installation
        • 📑User Guide
          • Create Garages
          • Create Private Garage
          • Impound & Auctions
          • Add vehicle to gang/job
          • Commands
      • ✈️Airplane Job
        • 🛠️Installation
        • 📃Configs
        • ℹ️Exports
      • 📋Scoreboard
        • 📃Config
      • 📦StorageUnits
        • 🛠️Installation
        • 📃Config
Powered by GitBook
On this page
  1. QBCore
  2. General
  3. [QB] Car Rental

Compatibilities

okokGarage

Search this event on sv_utils:

Config.EventPrefix..":TransferVehicle"
RegisterNetEvent(Config.EventPrefix..":TransferVehicle", function(pID, plate, toSociety)
	local source = source
	local xPlayer = QBCore.Functions.GetPlayer(source)
	if not toSociety then
		pID = tonumber(pID)
	end
	if oldOwner ~= nil then
		source = oldOwner
	end

	if pID ~= nil and plate ~= nil then
		if toSociety then
			MySQLfetchAll('SELECT *, cast(`state` as signed) as `stored` FROM player_vehicles WHERE citizenid = @owner AND plate = @plate', {
				['@owner'] = xPlayer.PlayerData.citizenid,
				['@plate'] = plate:match( "^%s*(.-)%s*$" )
			}, function(vehicle)
				if vehicle[1] ~= nil then
					vehicle[1].sharedwith = {}
					MySQLexecute('UPDATE player_vehicles SET `citizenid` = @newowner, `license` = @license, `sharedwith` = @sharedwith, favourite = 0, garage = @garage WHERE citizenid = @owner AND plate = @plate', {
						['@owner'] = xPlayer.PlayerData.citizenid,
						['@plate'] = plate:match( "^%s*(.-)%s*$" ),
						['@newowner'] = pID,
						['@license'] = pID,
						['@sharedwith'] = json.encode(vehicle[1].sharedwith),
						['@garage'] = nil
					}, function (rowsChanged)
						if rowsChanged > 0 then
							TriggerClientEvent(Config.EventPrefix..':notification', source, _L('vehicle_transferred_to_other').title, _L('vehicle_transferred_to_other').text, _L('vehicle_transferred_to_other').time, _L('vehicle_transferred_to_other').type)

							if Webhook ~= "" then
								data = {
									playerid = source,
									type = "transfer-vehicle",
									info = plate:match( "^%s*(.-)%s*$" ),
								}

								discordWebhook(data)
							end
						end
					end)
				else
					TriggerClientEvent(Config.EventPrefix..':notification', source, _L('not_the_owner').title, _L('not_the_owner').text, _L('not_the_owner').time, _L('not_the_owner').type)
				end
			end)
		else
			if GetPlayerPing(pID) > 0 then
				local targetXPlayer = QBCore.Functions.GetPlayer(pID)
				MySQLfetchAll('SELECT *, cast(`state` as signed) as `stored` FROM player_vehicles WHERE citizenid = @owner AND plate = @plate OR citizenid = @society AND plate = @plate', {
					['@owner'] = xPlayer.PlayerData.citizenid,
					['@society'] = xPlayer.PlayerData.job.name:lower(),
					['@plate'] = plate:match( "^%s*(.-)%s*$" )
				}, function(vehicle)
					if vehicle[1] ~= nil then
						vehicle[1].sharedwith = {}
						MySQLexecute('UPDATE player_vehicles SET `citizenid` = @newowner, `sharedwith` = @sharedwith, favourite = 0, license = @license WHERE citizenid = @owner AND plate = @plate OR citizenid = @society AND plate = @plate', {
							['@owner'] = xPlayer.PlayerData.citizenid,
							['@society'] = xPlayer.PlayerData.job.name:lower(),
							['@plate'] = plate:match( "^%s*(.-)%s*$" ),
							['@newowner'] = targetXPlayer.PlayerData.citizenid,
							['@sharedwith'] = json.encode(vehicle[1].sharedwith),
							['@license'] = targetXPlayer.PlayerData.license
						}, function (rowsChanged)
							if rowsChanged > 0 then
								TriggerClientEvent(Config.EventPrefix..':notification', source, _L('vehicle_transferred_to_other').title, _L('vehicle_transferred_to_other').text, _L('vehicle_transferred_to_other').time, _L('vehicle_transferred_to_other').type)
								TriggerClientEvent(Config.EventPrefix..':notification', pID, _L('vehicle_transferred').title, _L('vehicle_transferred').text, _L('vehicle_transferred').time, _L('vehicle_transferred').type)

								if Webhook ~= "" then
									data = {
										playerid = source,
										type = "transfer-vehicle",
										info = plate:match( "^%s*(.-)%s*$" ),
									}

									discordWebhook(data)
								end
							end
						end)
					else
						TriggerClientEvent(Config.EventPrefix..':notification', source, _L('not_the_owner').title, _L('not_the_owner').text, _L('not_the_owner').time, _L('not_the_owner').type)
					end
				end)
			else
				TriggerClientEvent(Config.EventPrefix..':notification', source, _L('player_not_online').title, _L('player_not_online').text, _L('player_not_online').time, _L('player_not_online').type)
			end
		end
	end
end)
RegisterNetEvent(Config.EventPrefix..":TransferVehicle", function(pID, plate, toSociety)
	local source = source
	local xPlayer = QBCore.Functions.GetPlayer(source)
	if not toSociety then
		pID = tonumber(pID)
	end
	if oldOwner ~= nil then
		source = oldOwner
	end

	if pID ~= nil and plate ~= nil then
		if toSociety then
			MySQLfetchAll('SELECT *, cast(`state` as signed) as `stored` FROM player_vehicles WHERE citizenid = @owner AND plate = @plate', {
				['@owner'] = xPlayer.PlayerData.citizenid,
				['@plate'] = plate:match( "^%s*(.-)%s*$" )
			}, function(vehicle)
				if not vehicle[1].isRented then
					if vehicle[1] ~= nil then
						vehicle[1].sharedwith = {}
						MySQLexecute('UPDATE player_vehicles SET `citizenid` = @newowner, `license` = @license, `sharedwith` = @sharedwith, favourite = 0, garage = @garage WHERE citizenid = @owner AND plate = @plate', {
							['@owner'] = xPlayer.PlayerData.citizenid,
							['@plate'] = plate:match( "^%s*(.-)%s*$" ),
							['@newowner'] = pID,
							['@license'] = pID,
							['@sharedwith'] = json.encode(vehicle[1].sharedwith),
							['@garage'] = nil
						}, function (rowsChanged)
							if rowsChanged > 0 then
								TriggerClientEvent(Config.EventPrefix..':notification', source, _L('vehicle_transferred_to_other').title, _L('vehicle_transferred_to_other').text, _L('vehicle_transferred_to_other').time, _L('vehicle_transferred_to_other').type)

								if Webhook ~= "" then
									data = {
										playerid = source,
										type = "transfer-vehicle",
										info = plate:match( "^%s*(.-)%s*$" ),
									}

									discordWebhook(data)
								end
							end
						end)
					else
						TriggerClientEvent(Config.EventPrefix..':notification', source, _L('not_the_owner').title, _L('not_the_owner').text, _L('not_the_owner').time, _L('not_the_owner').type)
					end
				else
					TriggerClientEvent(Config.EventPrefix..':notification', source, "Notification", "Your vehicle is rented you can't transfer", 5000, "error")
				end
			end)
		else
			if GetPlayerPing(pID) > 0 then
				local targetXPlayer = QBCore.Functions.GetPlayer(pID)
				MySQLfetchAll('SELECT *, cast(`state` as signed) as `stored` FROM player_vehicles WHERE citizenid = @owner AND plate = @plate OR citizenid = @society AND plate = @plate', {
					['@owner'] = xPlayer.PlayerData.citizenid,
					['@society'] = xPlayer.PlayerData.job.name:lower(),
					['@plate'] = plate:match( "^%s*(.-)%s*$" )
				}, function(vehicle)
					if not vehicle[1].isRented then
						if vehicle[1] ~= nil then
							vehicle[1].sharedwith = {}
							MySQLexecute('UPDATE player_vehicles SET `citizenid` = @newowner, `sharedwith` = @sharedwith, favourite = 0, license = @license WHERE citizenid = @owner AND plate = @plate OR citizenid = @society AND plate = @plate', {
								['@owner'] = xPlayer.PlayerData.citizenid,
								['@society'] = xPlayer.PlayerData.job.name:lower(),
								['@plate'] = plate:match( "^%s*(.-)%s*$" ),
								['@newowner'] = targetXPlayer.PlayerData.citizenid,
								['@sharedwith'] = json.encode(vehicle[1].sharedwith),
								['@license'] = targetXPlayer.PlayerData.license
							}, function (rowsChanged)
								if rowsChanged > 0 then
									TriggerClientEvent(Config.EventPrefix..':notification', source, _L('vehicle_transferred_to_other').title, _L('vehicle_transferred_to_other').text, _L('vehicle_transferred_to_other').time, _L('vehicle_transferred_to_other').type)
									TriggerClientEvent(Config.EventPrefix..':notification', pID, _L('vehicle_transferred').title, _L('vehicle_transferred').text, _L('vehicle_transferred').time, _L('vehicle_transferred').type)

									if Webhook ~= "" then
										data = {
											playerid = source,
											type = "transfer-vehicle",
											info = plate:match( "^%s*(.-)%s*$" ),
										}

										discordWebhook(data)
									end
								end
							end)
						else
							TriggerClientEvent(Config.EventPrefix..':notification', source, _L('not_the_owner').title, _L('not_the_owner').text, _L('not_the_owner').time, _L('not_the_owner').type)
						end
					else
						TriggerClientEvent(Config.EventPrefix..':notification', source, "Notification", "Your vehicle is rented you can't transfer", 5000, "error")
					end
				end)
			else
				TriggerClientEvent(Config.EventPrefix..':notification', source, _L('player_not_online').title, _L('player_not_online').text, _L('player_not_online').time, _L('player_not_online').type)
			end
		end
	end
end)
PreviousConfigNext[QB] Sky Racing

Last updated 11 months ago

🚘
🖥️