├── README.md ├── client └── client.lua ├── config.lua ├── fxmanifest.lua └── server └── server.lua /README.md: -------------------------------------------------------------------------------- 1 | # envi-carjack 2 | 3 | PREVIEW: 4 | https://youtu.be/Bavm7xvbwRw 5 | 6 | SUPPORT & UPDATES: 7 | https://discord.gg/pJXc2yzzqT 8 | 9 | Envi-Carjack is a simple FiveM resource designed to allow the player to remove a player/NPC from the driver's seat of a vehicle that fully utilises the native GTA function and includes animations and synced window smash. 10 | The player must be weilding the Nightstick Weapon. (You can add/ change weapons inside the config). 11 | 12 | Compatible with qtarget, ox_target and can also be used without any taget system. 13 | 14 | Currently supports ESX/QB-Core 15 | 16 | Big shout-out to the mentor SloppyShovel! 17 | -------------------------------------------------------------------------------- /client/client.lua: -------------------------------------------------------------------------------- 1 | if Config.Framework == 'esx' then 2 | ESX = exports['es_extended']:getSharedObject() 3 | 4 | Carjack = function() 5 | local ped = PlayerPedId() 6 | local playerPos = GetEntityCoords(ped) 7 | local closestPed, closestPedDist = ESX.Game.GetClosestPed(playerPos, nil) 8 | if closestPed ~= ped and closestPedDist < 2 then 9 | local vehicle = GetVehiclePedIsIn(closestPed, false) 10 | local relationship = GetPedRelationshipGroupHash(closestPed) 11 | if vehicle ~= 0 then 12 | if not HasAnimDictLoaded('veh@break_in@0h@p_m_zero@') then 13 | RequestAnimDict('veh@break_in@0h@p_m_zero@') 14 | while not HasAnimDictLoaded('veh@break_in@0h@p_m_zero@') do 15 | Wait(0) 16 | end 17 | end 18 | if Config.AlwaysUnlock then 19 | local plate = GetVehicleNumberPlateText(vehicle) 20 | SetVehicleDoorsLocked(vehicle, 0) 21 | Unlock(vehicle, plate) 22 | end 23 | if Config.FreezeVehicle then 24 | FreezeEntityPosition(vehicle, true) 25 | end 26 | TaskPlayAnim(ped, "veh@break_in@0h@p_m_zero@" ,"std_force_entry_ds" ,8.0, -8.0, -1, 48, 0, false, false, false ) 27 | Wait(1000) 28 | TriggerServerEvent('envi-carjack:smash', NetworkGetNetworkIdFromEntity(vehicle)) 29 | Wait(1000) 30 | SetRelationshipBetweenGroups(5, `PLAYER`, `PLAYER`) 31 | SetPedCanBeDraggedOut(closestPed, true) 32 | TaskEnterVehicle(ped, vehicle, -1, 0, 1.0, 524288, 0) 33 | Wait(5000) 34 | SetPedCanBeDraggedOut(closestPed, false) 35 | if IsPedAPlayer(closestPed) then 36 | SetPedRelationshipGroupHash(closestPed, relationship) 37 | end 38 | RemoveAnimDict('veh@break_in@0h@p_m_zero@') 39 | if Config.FreezeVehicle then 40 | FreezeEntityPosition(vehicle, false) 41 | end 42 | end 43 | end 44 | end 45 | elseif Config.Framework == 'qb' then 46 | local QBCore = exports['qb-core']:GetCoreObject() 47 | Carjack = function() 48 | local ped = PlayerPedId() 49 | local playerPos = GetEntityCoords(ped) 50 | local closestPed, closestPedDist = QBCore.Functions.GetClosestPed(playerPos, { ped }) 51 | if closestPedDist < 2 then 52 | local vehicle = GetVehiclePedIsIn(closestPed, false) 53 | local relationship = GetPedRelationshipGroupHash(closestPed) 54 | if vehicle ~= 0 then 55 | if not HasAnimDictLoaded('veh@break_in@0h@p_m_zero@') then 56 | RequestAnimDict('veh@break_in@0h@p_m_zero@') 57 | while not HasAnimDictLoaded('veh@break_in@0h@p_m_zero@') do 58 | Wait(0) 59 | end 60 | end 61 | if Config.AlwaysUnlock then 62 | local plate = GetVehicleNumberPlateText(vehicle) 63 | SetVehicleDoorsLocked(vehicle, 0) 64 | Unlock(vehicle, plate) 65 | end 66 | if Config.FreezeVehicle then 67 | FreezeEntityPosition(vehicle, true) 68 | end 69 | TaskPlayAnim(ped, "veh@break_in@0h@p_m_zero@" ,"std_force_entry_ds" ,8.0, -8.0, -1, 48, 0, false, false, false ) 70 | Wait(1000) 71 | TriggerServerEvent('envi-carjack:smash', NetworkGetNetworkIdFromEntity(vehicle)) 72 | Wait(1000) 73 | SetRelationshipBetweenGroups(5, `PLAYER`, `PLAYER`) 74 | SetPedCanBeDraggedOut(closestPed, true) 75 | TaskEnterVehicle(ped, vehicle, -1, 0, 1.0, 524288, 0) 76 | Wait(5000) 77 | SetPedCanBeDraggedOut(closestPed, false) 78 | if IsPedAPlayer(closestPed) then 79 | SetPedRelationshipGroupHash(closestPed, relationship) 80 | end 81 | RemoveAnimDict('veh@break_in@0h@p_m_zero@') 82 | if Config.FreezeVehicle then 83 | FreezeEntityPosition(vehicle, false) 84 | end 85 | end 86 | end 87 | end 88 | end 89 | 90 | Unlock = function(vehicle, plate) 91 | -- add your vehicle keys logic/triggers here 92 | -- TriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(vehicle), 1) -- uncomment if using QB 93 | --TriggerServerEvent('shorty_slocks:breakIn', plate) 94 | end 95 | 96 | RegisterNetEvent('envi-carjack:smash',function(netID) 97 | if NetworkDoesNetworkIdExist(netID) and NetworkDoesEntityExistWithNetworkId(netID) then 98 | SmashVehicleWindow(NetworkGetEntityFromNetworkId(netID),0) 99 | end 100 | end) 101 | if Config.Target == 'qtarget' then 102 | local door = {'door_dside_f', 'seat_dside_f'} 103 | exports['qtarget']:AddTargetBone(door, { 104 | options = { 105 | { 106 | icon = 'fa-solid fa-car-side', 107 | label = 'Commandeer Vehicle', 108 | 109 | canInteract = function() 110 | return Config.TakeVehWeapons[GetSelectedPedWeapon(PlayerPedId())] ~= nil 111 | end, 112 | action = function() 113 | Carjack() 114 | end 115 | }, 116 | }, 117 | distance = 1.5, 118 | }) 119 | 120 | elseif Config.Target == 'ox_target' then 121 | exports.ox_target:addGlobalVehicle({ 122 | { 123 | name = 'ox_target:carsteal', 124 | icon = 'fa-solid fa-car-side', 125 | label = ('Commandeer Vehicle'), 126 | distance = 1.5, 127 | bones = { 'door_dside_f', 'seat_dside_f' }, 128 | canInteract = function() 129 | return Config.TakeVehWeapons[GetSelectedPedWeapon(PlayerPedId())] ~= nil 130 | end, 131 | onSelect = function() 132 | Carjack() 133 | end 134 | } 135 | }) 136 | 137 | elseif Config.Target == 'qb-target' then 138 | 139 | local door = {'door_dside_f', 'seat_dside_f'} 140 | exports['qb-target']:AddTargetBone(door, { 141 | options = { 142 | { 143 | icon = 'fa-solid fa-car-side', 144 | label = 'Commandeer Vehicle', 145 | canInteract = function() 146 | return Config.TakeVehWeapons[GetSelectedPedWeapon(PlayerPedId())] ~= nil 147 | end, 148 | action = function() 149 | Carjack() 150 | end, 151 | }, 152 | }, 153 | distance = 1.5, 154 | }) 155 | 156 | else 157 | RegisterCommand('carjack', function() 158 | if Config.TakeVehWeapons[GetSelectedPedWeapon(PlayerPedId())] ~= nil then 159 | Carjack() 160 | end 161 | end) 162 | end 163 | -------------------------------------------------------------------------------- /config.lua: -------------------------------------------------------------------------------- 1 | Config = {} 2 | 3 | Config.Framework = 'esx' -- 'esx' or 'qb' 4 | 5 | Config.TakeVehWeapons = { 6 | [`WEAPON_NIGHTSTICK`] = true, -- add/change weapons here 7 | 8 | } 9 | 10 | Config.Target = 'ox_target' -- 'ox_target', 'qtarget', 'qb-target' or false --( /carjack command ) 11 | 12 | Config.AlwaysUnlock = true -- always unlock vehicle? (add your vehicle keys triggers in client.lua) 13 | 14 | Config.FreezeVehicle = false -- freeze the vehcile in place when triggered? 15 | -------------------------------------------------------------------------------- /fxmanifest.lua: -------------------------------------------------------------------------------- 1 | 2 | fx_version 'cerulean' 3 | 4 | game 'gta5' 5 | 6 | client_scripts { 7 | 'client/*.lua', 8 | } 9 | shared_scripts { 10 | 'config.lua', 11 | } 12 | 13 | server_scripts { 14 | 'server/*.lua', 15 | } 16 | 17 | lua54 'yes' -------------------------------------------------------------------------------- /server/server.lua: -------------------------------------------------------------------------------- 1 | 2 | 3 | RegisterNetEvent('envi-carjack:smash', function(netID) 4 | TriggerClientEvent('envi-carjack:smash',-1, netID) 5 | end) 6 | 7 | --------------------------------------------------------------------------------