├── LICENSE ├── README.md └── vC-realisticWeaponDrop ├── client.lua ├── fxmanifest.lua ├── server.lua └── vCode.lua /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 vCode Scripts 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vC-realisticWeaponDrop 2 | QB-Core script which utilizes pickups to drop the weapon player is holding. 3 | 4 | It saves all the info of the weapon, so the person who picks it up gets the exact same weapon which was dropped. Only dependency is baseevents. 5 | 6 | Video: https://streamable.com/plj196 7 | -------------------------------------------------------------------------------- /vC-realisticWeaponDrop/client.lua: -------------------------------------------------------------------------------- 1 | local QBCore = exports['qb-core']:GetCoreObject() 2 | local dropTable = {} 3 | currweap, weaponHash = 1, nil 4 | local pos = nil 5 | 6 | --- Main Thread To Make It All Work 7 | 8 | function CanPickup() 9 | if IsEntityDead(PlayerPedId()) then return true end 10 | if IsPedFatallyInjured(PlayerPedId()) then return true end 11 | if GetEntityHealth(PlayerPedId()) == 0 then return true end 12 | return false 13 | end 14 | 15 | Citizen.CreateThread(function() 16 | sleep = 400 17 | while true do 18 | Citizen.Wait(sleep) 19 | pos = GetEntityCoords(PlayerPedId()) 20 | currweap, weaponHash = GetCurrentPedWeapon(PlayerPedId(), 1) 21 | for k,v in pairs(dropTable) do 22 | local distance = GetDistanceBetweenCoords(pos, v.pos, true) 23 | if distance < vCode.MaxDistance then 24 | sleep = 0 25 | if distance < vCode.PickupDistance then 26 | QBCore.Functions.DrawText3D(v.pos.x,v.pos.y, v.pos.z, vCode.Text.h..' '..vCode.Text.pickup..' ['..v.label..']' ) 27 | if IsControlJustPressed(0, vCode.Key) then 28 | local pickupB = CanPickup() 29 | if pickupB == false then 30 | Anim(v.info, v.name, k) 31 | end 32 | end 33 | else 34 | QBCore.Functions.DrawText3D(v.pos.x,v.pos.y, v.pos.z, vCode.Text.pickup..' ['..v.label..']') 35 | 36 | end 37 | else 38 | sleep = 400 39 | end 40 | end 41 | 42 | end 43 | end) 44 | 45 | function Anim(info,name,key) 46 | if not IsEntityDead(PlayerPedId()) then 47 | RequestAnimSet("move_ped_crouched") 48 | RequestAnimDict('pickup_object') 49 | while not HasAnimSetLoaded("move_ped_crouched") and not HasAnimDictLoaded('pickup_object') do 50 | Citizen.Wait(100) 51 | end 52 | SetPedMovementClipset(PlayerPedId(), "move_ped_crouched", 0.25) 53 | Wait(500) 54 | TaskPlayAnim(PlayerPedId(),'pickup_object', 'putdown_low', 5.0, 1.5, 1.0, 48, 0.0, 0, 0, 0) 55 | Wait(1000) 56 | ResetPedMovementClipset(PlayerPedId(), 0) 57 | ClearPedTasksImmediately(PlayerPedId()) 58 | TriggerServerEvent('vC-realsticWeaponDrop:server:removeforEveryone', name, info, key) 59 | end 60 | end 61 | RegisterNetEvent('vC-realsticWeaponDrop:client:removeforEveryone', function(serino) 62 | local key = dropTable[serino].pickupkey 63 | RemovePickup(key) 64 | dropTable[serino] = nil 65 | end) 66 | 67 | RegisterNetEvent('vC-realtisticWeaponDrop:dropweapon', function(itemname, info, weaponHash,newpos) 68 | 69 | local pickup = CreatePickupRotate(GetPickupHashFromWeapon(weaponHash), newpos.x, newpos.y, newpos.z, 0, 0, 0, 8, 1, 1, true, GetHashKey(weaponHash)) 70 | local apos = GetPickupCoords(pickup) 71 | 72 | local label = QBCore.Shared.Items[itemname].label 73 | dropTable[info.serie] = {pos = apos, name = itemname, info = info, pickupkey = pickup, label = label} 74 | 75 | end) 76 | 77 | haveTwoScriptsConrol = {} 78 | 79 | RegisterNetEvent('baseevents:onPlayerDied') 80 | AddEventHandler('baseevents:onPlayerDied', function() 81 | if haveTwoScriptsConrol['as'] == nil then 82 | local PlayerData = QBCore.Functions.GetPlayerData() 83 | local Items = PlayerData.items 84 | CanDrop = true 85 | for k,v in pairs(vCode.BlacklistedWeapons) do 86 | if GetHashKey(v) == weaponHash then 87 | CanDrop = false 88 | break 89 | end 90 | end 91 | if currweap ~= false and CanDrop then 92 | 93 | for k,v in pairs(Items) do 94 | 95 | if QBCore.Shared.SplitStr(v.name, "_")[1] == "weapon" and GetHashKey(v.name) == weaponHash then 96 | TriggerServerEvent('vc-realisticWeaponDrop:server:removeItem', v.name) 97 | TriggerEvent('inventory:client:CheckWeapon', v.name) 98 | TriggerServerEvent('vC-realisticWeaponDrop:server:syncforEveryone',v.name,v.info, weaponHash, pos) 99 | end 100 | end 101 | end 102 | haveTwoScriptsConrol['as'] = 'as' 103 | end 104 | Wait(2000) 105 | haveTwoScriptsConrol['as'] = nil 106 | end) 107 | 108 | local disabledPickups = { 109 | `PICKUP_WEAPON_ADVANCEDRIFLE`, 110 | `PICKUP_WEAPON_APPISTOL`, 111 | `PICKUP_WEAPON_ASSAULTRIFLE`, 112 | `PICKUP_WEAPON_ASSAULTRIFLE_MK2`, 113 | `PICKUP_WEAPON_ASSAULTSHOTGUN`, 114 | `PICKUP_WEAPON_ASSAULTSMG`, 115 | `PICKUP_WEAPON_AUTOSHOTGUN`, 116 | `PICKUP_WEAPON_BAT`, 117 | `PICKUP_WEAPON_BATTLEAXE`, 118 | `PICKUP_WEAPON_BOTTLE`, 119 | `PICKUP_WEAPON_BULLPUPRIFLE`, 120 | `PICKUP_WEAPON_BULLPUPRIFLE_MK2`, 121 | `PICKUP_WEAPON_BULLPUPSHOTGUN`, 122 | `PICKUP_WEAPON_CARBINERIFLE`, 123 | `PICKUP_WEAPON_CARBINERIFLE_MK2`, 124 | `PICKUP_WEAPON_COMBATMG`, 125 | `PICKUP_WEAPON_COMBATMG_MK2`, 126 | `PICKUP_WEAPON_COMBATPDW`, 127 | `PICKUP_WEAPON_COMBATPISTOL`, 128 | `PICKUP_WEAPON_COMPACTLAUNCHER`, 129 | `PICKUP_WEAPON_COMPACTRIFLE`, 130 | `PICKUP_WEAPON_CROWBAR`, 131 | `PICKUP_WEAPON_DAGGER`, 132 | `PICKUP_WEAPON_DBSHOTGUN`, 133 | `PICKUP_WEAPON_DOUBLEACTION`, 134 | `PICKUP_WEAPON_FIREWORK`, 135 | `PICKUP_WEAPON_FLAREGUN`, 136 | `PICKUP_WEAPON_FLASHLIGHT`, 137 | `PICKUP_WEAPON_GRENADE`, 138 | `PICKUP_WEAPON_GRENADELAUNCHER`, 139 | `PICKUP_WEAPON_GUSENBERG`, 140 | `PICKUP_WEAPON_GolfClub`, 141 | `PICKUP_WEAPON_HAMMER`, 142 | `PICKUP_WEAPON_HATCHET`, 143 | `PICKUP_WEAPON_HEAVYPISTOL`, 144 | `PICKUP_WEAPON_HEAVYSHOTGUN`, 145 | `PICKUP_WEAPON_HEAVYSNIPER`, 146 | `PICKUP_WEAPON_HEAVYSNIPER_MK2`, 147 | `PICKUP_WEAPON_HOMINGLAUNCHER`, 148 | `PICKUP_WEAPON_KNIFE`, 149 | `PICKUP_WEAPON_KNUCKLE`, 150 | `PICKUP_WEAPON_MACHETE`, 151 | `PICKUP_WEAPON_MACHINEPISTOL`, 152 | `PICKUP_WEAPON_MARKSMANPISTOL`, 153 | `PICKUP_WEAPON_MARKSMANRIFLE`, 154 | `PICKUP_WEAPON_MARKSMANRIFLE_MK2`, 155 | `PICKUP_WEAPON_MG`, 156 | `PICKUP_WEAPON_MICROSMG`, 157 | `PICKUP_WEAPON_MINIGUN`, 158 | `PICKUP_WEAPON_MINISMG`, 159 | `PICKUP_WEAPON_MOLOTOV`, 160 | `PICKUP_WEAPON_MUSKET`, 161 | `PICKUP_WEAPON_NIGHTSTICK`, 162 | `PICKUP_WEAPON_PETROLCAN`, 163 | `PICKUP_WEAPON_PIPEBOMB`, 164 | `PICKUP_WEAPON_PISTOL`, 165 | `PICKUP_WEAPON_PISTOL50`, 166 | `PICKUP_WEAPON_PISTOL_MK2`, 167 | `PICKUP_WEAPON_POOLCUE`, 168 | `PICKUP_WEAPON_PROXMINE`, 169 | `PICKUP_WEAPON_PUMPSHOTGUN`, 170 | `PICKUP_WEAPON_PUMPSHOTGUN_MK2`, 171 | `PICKUP_WEAPON_RAILGUN`, 172 | `PICKUP_WEAPON_RAYCARBINE`, 173 | `PICKUP_WEAPON_RAYMINIGUN`, 174 | `PICKUP_WEAPON_RAYPISTOL`, 175 | `PICKUP_WEAPON_REVOLVER`, 176 | `PICKUP_WEAPON_REVOLVER_MK2`, 177 | `PICKUP_WEAPON_RPG`, 178 | `PICKUP_WEAPON_SAWNOFFSHOTGUN`, 179 | `PICKUP_WEAPON_SMG`, 180 | `PICKUP_WEAPON_SMG_MK2`, 181 | `PICKUP_WEAPON_SMOKEGRENADE`, 182 | `PICKUP_WEAPON_SNIPERRIFLE`, 183 | `PICKUP_WEAPON_SNSPISTOL`, 184 | `PICKUP_WEAPON_SNSPISTOL_MK2`, 185 | `PICKUP_WEAPON_SPECIALCARBINE`, 186 | `PICKUP_WEAPON_SPECIALCARBINE_MK2`, 187 | `PICKUP_WEAPON_STICKYBOMB`, 188 | `PICKUP_WEAPON_STONE_HATCHET`, 189 | `PICKUP_WEAPON_STUNGUN`, 190 | `PICKUP_WEAPON_SWITCHBLADE`, 191 | `PICKUP_WEAPON_VINTAGEPISTOL`, 192 | `PICKUP_WEAPON_WRENCH` 193 | } 194 | 195 | CreateThread(function() 196 | for _, hash in pairs(disabledPickups) do 197 | ToggleUsePickupsForPlayer(PlayerId(), hash, false) 198 | end 199 | end) 200 | -------------------------------------------------------------------------------- /vC-realisticWeaponDrop/fxmanifest.lua: -------------------------------------------------------------------------------- 1 | fx_version 'cerulean' 2 | game 'gta5' 3 | 4 | author 'vCode Scripts https://discord.gg/ePnVpZE6mA' 5 | 6 | shared_scripts { 7 | 'vCode.lua' 8 | } 9 | 10 | client_script 'client.lua' 11 | server_script 'server.lua' -------------------------------------------------------------------------------- /vC-realisticWeaponDrop/server.lua: -------------------------------------------------------------------------------- 1 | local QBCore = exports['qb-core']:GetCoreObject() 2 | 3 | takeds = {} 4 | 5 | RegisterServerEvent('vC-realisticWeaponDrop:server:syncforEveryone', function(name, info, hash, pos) 6 | TriggerClientEvent('vC-realtisticWeaponDrop:dropweapon', -1, name,info,hash, pos) 7 | end) 8 | 9 | 10 | RegisterServerEvent('vC-realsticWeaponDrop:server:removeforEveryone', function(item,info,serie) 11 | local Player = QBCore.Functions.GetPlayer(source) 12 | if takeds[serie] == nil then 13 | if Player.Functions.AddItem(item, 1,false,info) then 14 | takeds[serie] = 'taked' 15 | local label = QBCore.Shared.Items[item].label 16 | TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, 'You Picked Up A '..label..' With Serial Number '..serie..' !') 17 | TriggerClientEvent('vC-realsticWeaponDrop:client:removeforEveryone',-1, serie) 18 | Citizen.Wait(5000) 19 | takeds[serie] = nil 20 | return 21 | else 22 | takeds[serie] = nil 23 | TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, 'You are too full to pick up this weapon!', 'error') 24 | end 25 | end 26 | end) 27 | 28 | RegisterServerEvent("vc-realisticWeaponDrop:server:removeItem", function(item) 29 | local Player = QBCore.Functions.GetPlayer(source) 30 | Player.Functions.RemoveItem(item, 1) 31 | 32 | end) 33 | -------------------------------------------------------------------------------- /vC-realisticWeaponDrop/vCode.lua: -------------------------------------------------------------------------------- 1 | vCode = {} -- 'whitelist is the other type, makes use of the vCode.WhitelistedWeapons table' 2 | 3 | vCode.BlacklistedWeapons = {} 4 | vCode.Key = 74 5 | vCode.MaxDistance = 3.5 6 | vCode.PickupDistance = 2.5 7 | 8 | vCode.Text = { 9 | h = '[H]', 10 | pickup = 'Pick Up', 11 | progressbar = 'Picking Up ' 12 | } 13 | --------------------------------------------------------------------------------