├── README.md └── qb-towrequest ├── client └── main.lua ├── fxmanifest.lua └── server └── main.lua /README.md: -------------------------------------------------------------------------------- 1 | # **A simple tow request script using qb-target | renewed qb-phone** 2 | 3 | ## **qb-target:** 4 | 5 | ### https://github.com/qbcore-framework/qb-target 6 | 7 | ## **Renewed QB-Phone:** 8 | 9 | ### https://github.com/Renewed-Scripts/qb-phone 10 | 11 | 12 | 13 | # **INSTALLATION** 14 | 15 | 16 | 17 | ## *PLACE THIS INSIDE YOUR qb-target/init.lua >* 18 | ``` 19 | Config.TargetBones = { 20 | ["requestTow"] = { 21 | bones = { 22 | "seat_dside_f", 23 | }, 24 | options = { 25 | { 26 | type = "client", 27 | event = "tow:requestTow", 28 | icon = "fas fa-truck", 29 | label = "Request Tow", 30 | }, 31 | }, 32 | distance = 4.0 33 | }, 34 | } 35 | ``` 36 | 37 | Make sure your qb-core/shared/jobs.lua has a job named "tow". 38 | ======================================- 39 | 40 | That's it. Just ensure it inside your server.cfg and play! -------------------------------------------------------------------------------- /qb-towrequest/client/main.lua: -------------------------------------------------------------------------------- 1 | local QBCore = exports['qb-core']:GetCoreObject() 2 | 3 | RegisterNetEvent('tow:requestTow') 4 | AddEventHandler('tow:requestTow', function() 5 | local player = PlayerPedId() 6 | local vehicle = QBCore.Functions.GetClosestVehicle() 7 | local coords = GetEntityCoords(player) 8 | 9 | if vehicle ~= 0 then 10 | TriggerServerEvent('tow:sendTowRequest', GetVehicleNumberPlateText(vehicle), coords) 11 | else 12 | QBCore.Functions.Notify('No vehicle found', 'error') 13 | end 14 | end) 15 | 16 | RegisterNetEvent('tow:requestResponse') 17 | AddEventHandler('tow:requestResponse', function(towDriverName, accepted) 18 | if accepted then 19 | exports['qb-phone']:PhoneNotification('Tow request accepted by ' .. towDriverName, 'They will be there shortly!', '#9f0e63', "NONE", 5000) 20 | else 21 | exports['qb-phone']:PhoneNotification('Tow request declined.', 'Declined.', '#9f0e63', "NONE", 5000) 22 | end 23 | end) 24 | 25 | RegisterNetEvent('tow:receiveTowRequest') 26 | AddEventHandler('tow:receiveTowRequest', function(target, plate, coords) 27 | 28 | local success = exports['qb-phone']:PhoneNotification('Tow Request: ', 'Vehicle Plate: ' .. plate, '#9f0e63', "NONE", 5000, 'fas fa-check-circle', 'fas fa-times-circle') 29 | if success then 30 | TriggerServerEvent('tow:sendTowResponse', target, true) 31 | local blip = AddBlipForCoord(coords.x, coords.y, coords.z) 32 | SetBlipAsShortRange(blip, false) 33 | SetBlipSprite(blip, 68) 34 | SetBlipColour(blip, 0) 35 | SetBlipScale(blip, 0.7) 36 | SetBlipDisplay(blip, 6) 37 | Wait(130000) 38 | RemoveBlip(blip) 39 | else 40 | TriggerServerEvent('tow:sendTowResponse', target, false) 41 | end 42 | end) -------------------------------------------------------------------------------- /qb-towrequest/fxmanifest.lua: -------------------------------------------------------------------------------- 1 | fx_version 'cerulean' 2 | game 'gta5' 3 | 4 | author 'Maji#1118' 5 | description 'Tow Request Script for QBCore' 6 | version '1.0.0' 7 | 8 | client_scripts { 9 | 'client/main.lua', 10 | } 11 | 12 | server_scripts { 13 | 'server/main.lua', 14 | } -------------------------------------------------------------------------------- /qb-towrequest/server/main.lua: -------------------------------------------------------------------------------- 1 | local QBCore = exports['qb-core']:GetCoreObject() 2 | 3 | RegisterServerEvent('tow:sendTowRequest') 4 | AddEventHandler('tow:sendTowRequest', function(plate, coords) 5 | local src = source 6 | local players = QBCore.Functions.GetPlayers() 7 | 8 | for _, playerId in ipairs(players) do 9 | local player = QBCore.Functions.GetPlayer(playerId) 10 | if player ~= nil and player.PlayerData.job.name == 'tow' then 11 | TriggerClientEvent('tow:receiveTowRequest', playerId, src, plate, coords) 12 | end 13 | end 14 | end) 15 | 16 | RegisterServerEvent('tow:sendTowResponse') 17 | AddEventHandler('tow:sendTowResponse', function(target, accepted) 18 | local towDriver = QBCore.Functions.GetPlayer(source) 19 | local towDriverName = towDriver.PlayerData.charinfo.firstname 20 | 21 | TriggerClientEvent('tow:requestResponse', target, towDriverName, accepted) 22 | end) --------------------------------------------------------------------------------