├── img ├── cowpelt.png ├── pigpelt.png ├── birdfeather.png ├── boartusks.png ├── cougarclaw.png ├── coyotepelt.png ├── deerhorns.png └── rabbitfur.png ├── fxmanifest.lua ├── sv_main.lua ├── sv_sell.lua ├── Readme.md └── cl_main.lua /img/cowpelt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cadburry6969/cad-hunting/HEAD/img/cowpelt.png -------------------------------------------------------------------------------- /img/pigpelt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cadburry6969/cad-hunting/HEAD/img/pigpelt.png -------------------------------------------------------------------------------- /img/birdfeather.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cadburry6969/cad-hunting/HEAD/img/birdfeather.png -------------------------------------------------------------------------------- /img/boartusks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cadburry6969/cad-hunting/HEAD/img/boartusks.png -------------------------------------------------------------------------------- /img/cougarclaw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cadburry6969/cad-hunting/HEAD/img/cougarclaw.png -------------------------------------------------------------------------------- /img/coyotepelt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cadburry6969/cad-hunting/HEAD/img/coyotepelt.png -------------------------------------------------------------------------------- /img/deerhorns.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cadburry6969/cad-hunting/HEAD/img/deerhorns.png -------------------------------------------------------------------------------- /img/rabbitfur.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cadburry6969/cad-hunting/HEAD/img/rabbitfur.png -------------------------------------------------------------------------------- /fxmanifest.lua: -------------------------------------------------------------------------------- 1 | fx_version 'bodacious' 2 | games { 'gta5' } 3 | 4 | author "Cadburry#7547" 5 | 6 | shared_script "@qb-core/import.lua" 7 | 8 | client_script 'cl_main.lua' 9 | server_script 'sv_sell.lua' 10 | server_script 'sv_main.lua' 11 | 12 | -------------------------------------------------------------------------------- /sv_main.lua: -------------------------------------------------------------------------------- 1 | --============================ 2 | -- SERVER CONFIG 3 | --============================ 4 | local animals = { 5 | [1] = {item = "meatdeer", id = 35}, 6 | [2] = {item = "meatpig", id = 36}, 7 | [3] = {item = "meatboar", id = 37}, 8 | [4] = {item = "meatlion", id = 38}, 9 | [5] = {item = "meatcow", id = 39}, 10 | [6] = {item = "meatcoyote", id = 40}, 11 | [7] = {item = "meatrabbit", id = 41}, 12 | [8] = {item = "meatbird", id = 42}, 13 | [9] = {item = "meatbird", id = 43} 14 | } 15 | --============================ 16 | -- EVENTS 17 | --============================ 18 | RegisterServerEvent("cad-hunting:server:AddItem") 19 | AddEventHandler("cad-hunting:server:AddItem", function(data, amount) 20 | local _source = source 21 | local Player = QBCore.Functions.GetPlayer(_source) 22 | for i = 1, #animals do 23 | if data == animals[i].id then 24 | Player.Functions.AddItem(animals[i].item, amount) 25 | TriggerClientEvent("inventory:client:ItemBox", _source, QBCore.Shared.Items[animals[i].item], "add") 26 | end 27 | end 28 | end) 29 | 30 | RegisterServerEvent("cad-hunting:server:spawnanimals") 31 | AddEventHandler("cad-hunting:server:spawnanimals", function() 32 | local _source = source 33 | TriggerClientEvent("cad-hunting:client:spawnanimals", -1) 34 | end) 35 | 36 | --============================ 37 | -- Spawning Ped 38 | --============================ 39 | QBCore.Commands.Add("spawnanimal", "Spawn Animals", {{"model", "Animal Model"}}, false, function(source, args) 40 | TriggerClientEvent('cad-hunting:client:spawnanim', source, args[1]) 41 | end, 'god') 42 | -------------------------------------------------------------------------------- /sv_sell.lua: -------------------------------------------------------------------------------- 1 | --============================ 2 | -- SELLING CONFIG 3 | --============================ 4 | local sellanimals = { 5 | ["meatdeer"] = 140, 6 | ["meatpig"] = 50, 7 | ["meatboar"] = 120, 8 | ["meatlion"] = 222, 9 | ["meatcow"] = 32, 10 | ["meatcoyote"] = 170, 11 | ["meatrabbit"] = 80, 12 | ["meatbird"] = math.random(70,75), 13 | } 14 | --============================ 15 | -- SELLING EVENTS 16 | --============================ 17 | RegisterServerEvent('hunting:server:sellmeat') 18 | AddEventHandler('hunting:server:sellmeat', function() 19 | local src = source 20 | local Player = QBCore.Functions.GetPlayer(src) 21 | local price = 0 22 | if Player ~= nil then 23 | if Player.PlayerData.items ~= nil and next(Player.PlayerData.items) ~= nil then 24 | for k, v in pairs(Player.PlayerData.items) do 25 | if Player.PlayerData.items[k] ~= nil then 26 | if sellanimals[Player.PlayerData.items[k].name] ~= nil then 27 | price = price + (sellanimals[Player.PlayerData.items[k].name] * Player.PlayerData.items[k].amount) 28 | Player.Functions.RemoveItem(Player.PlayerData.items[k].name, Player.PlayerData.items[k].amount, k) 29 | end 30 | end 31 | end 32 | Citizen.Wait(2000) 33 | Player.Functions.AddMoney("cash", price, "sold-items-hunting") 34 | TriggerClientEvent('QBCore:Notify', src, "You have sold your items and recieved $"..price) 35 | else 36 | TriggerClientEvent('QBCore:Notify', src, "You don't have items") 37 | end 38 | end 39 | Wait(10) 40 | end) 41 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | !! THIS IS NOT MAITAINED ANY MORE YOU CAN TRY THE MAITAINED VERSION BY swkeep https://github.com/swkeep/keep-hunting !! 2 | 3 | -- ADD THESE LINES IN qb-core/shared.lua 4 | -- UNDER ITEMS SECTION 5 | 6 | ["meatdeer"] = {["name"] = "meatdeer", ["label"] = "Deer Horns", ["weight"] = 100, ["type"] = "item", ["image"] = "deerhorns.png", ["unique"] = false, ["useable"] = false, ["shouldClose"] = false, ["combinable"] = nil, ["description"] = "Deer Horns"}, 7 | ["meatpig"] = {["name"] = "meatpig", ["label"] = "Pig Meat", ["weight"] = 100, ["type"] = "item", ["image"] = "pigpelt.png", ["unique"] = false, ["useable"] = false, ["shouldClose"] = false, ["combinable"] = nil, ["description"] = "Pig Meat"}, 8 | ["meatboar"] = {["name"] = "meatboar", ["label"] = "Boar Tusks", ["weight"] = 100, ["type"] = "item", ["image"] = "boartusks.png", ["unique"] = false, ["useable"] = false, ["shouldClose"] = false, ["combinable"] = nil, ["description"] = "Boar Tusks"}, 9 | ["meatlion"] = {["name"] = "meatlion", ["label"] = "Cougar Claws", ["weight"] = 100, ["type"] = "item", ["image"] = "cougarclaw.png", ["unique"] = false, ["useable"] = false, ["shouldClose"] = false, ["combinable"] = nil, ["description"] = "Cougar Claw"}, 10 | ["meatcow"] = {["name"] = "meatcow", ["label"] = "Cow Pelt", ["weight"] = 100, ["type"] = "item", ["image"] = "cowpelt.png", ["unique"] = false, ["useable"] = false, ["shouldClose"] = false, ["combinable"] = nil, ["description"] = "Cow Pelt"}, 11 | ["meatrabbit"] = {["name"] = "meatrabbit", ["label"] = "Rabbit Fur", ["weight"] = 100, ["type"] = "item", ["image"] = "rabbitfur.png", ["unique"] = false, ["useable"] = false, ["shouldClose"] = false, ["combinable"] = nil, ["description"] = "Rabbit Fur"}, 12 | ["meatbird"] = {["name"] = "meatbird", ["label"] = "Bird Feather", ["weight"] = 100, ["type"] = "item", ["image"] = "birdfeather.png", ["unique"] = false, ["useable"] = false, ["shouldClose"] = false, ["combinable"] = nil, ["description"] = "Bird Feather"}, 13 | ["meatcoyote"] = {["name"] = "meatcoyote", ["label"] = "Coyote Pelt", ["weight"] = 100, ["type"] = "item", ["image"] = "coyotepelt.png", ["unique"] = false, ["useable"] = false, ["shouldClose"] = false, ["combinable"] = nil, ["description"] = "Coyote Pelt"}, 14 | -------------------------------------------------------------------------------- /cl_main.lua: -------------------------------------------------------------------------------- 1 | --============================ 2 | -- CLIENT CONFIGS 3 | --============================ 4 | local lastAnimals = {} 5 | local animals = { 6 | {model = "a_c_deer", hash = -664053099, item = "Deer Horns", id = 35}, 7 | {model = "a_c_pig", hash = -1323586730, item = "Pig Pelt", id = 36}, 8 | {model = "a_c_boar", hash = -832573324, item = "Boar Tusks", id = 37}, 9 | {model = "a_c_mtlion",hash = 307287994,item = "Coager Claws",id = 38}, 10 | {model = "a_c_cow", hash = -50684386, item = "Cow Pelt", id = 39}, 11 | {model = "a_c_coyote", hash = 1682622302, item = "Coyote Pelt", id = 40}, 12 | {model = "a_c_rabbit_01", hash = -541762431, item = "Rabbit Fur", id = 41}, 13 | {model = "a_c_pigeon", hash = 111281960, item = "Bird Feather", id = 42}, 14 | {model = "a_c_seagull", hash = -745300483, item = "Bird Feather", id = 43} 15 | } 16 | local SellSpots = { 17 | {x = -390.522, y = 6050.458, z = 31.500} 18 | -- {x = -390.522, y = 6050.458, z = 31.500} 19 | } 20 | local isPressed = false 21 | --============================ 22 | -- FUNCTIONS 23 | --============================ 24 | function SellingBlips() 25 | for _, v in pairs(SellSpots) do 26 | local blip = AddBlipForCoord(v.x, v.y, v.z) 27 | SetBlipSprite(blip, 141) 28 | SetBlipDisplay(blip, 4) 29 | SetBlipScale(blip, 0.6) 30 | SetBlipColour(blip, 49) 31 | SetBlipAsShortRange(blip, true) 32 | BeginTextCommandSetBlipName("STRING") 33 | AddTextComponentString("Sell Meat") 34 | EndTextCommandSetBlipName(blip) 35 | end 36 | end 37 | 38 | function getAnimalMatch(hash) 39 | for _, v in pairs(animals) do if (v.hash == hash) then return v end end 40 | end 41 | 42 | function removeEntity(entity) 43 | local delidx = 0 44 | 45 | for i = 1, #lastAnimals do 46 | if (lastAnimals[i].entity == entity) then delidx = i end 47 | end 48 | 49 | if (delidx > 0) then table.remove(lastAnimals, delidx) end 50 | end 51 | 52 | function lastAnimalExists(entity) 53 | for _, v in pairs(lastAnimals) do 54 | if (v.entity == entity) then return true end 55 | end 56 | end 57 | 58 | function handleDecorator(animal) 59 | if (DecorExistOn(animal, "lastshot")) then 60 | DecorSetInt(animal, "lastshot", GetPlayerServerId(PlayerId())) 61 | else 62 | DecorRegister("lastshot", 3) 63 | DecorSetInt(animal, "lastshot", GetPlayerServerId(PlayerId())) 64 | end 65 | end 66 | 67 | function isKillMine(animal) 68 | if (DecorExistOn(animal, "lastshot")) then 69 | local aid = DecorGetInt(animal, "lastshot") 70 | local id = GetPlayerServerId(PlayerId()) 71 | 72 | return aid == id 73 | end 74 | end 75 | 76 | function drawTxt(text) 77 | SetTextFont(0) 78 | SetTextProportional(0) 79 | SetTextScale(0.32, 0.32) 80 | SetTextColour(0, 255, 255, 255) 81 | SetTextDropShadow(0, 0, 0, 0, 255) 82 | SetTextEdge(1, 0, 0, 0, 255) 83 | SetTextDropShadow() 84 | SetTextOutline() 85 | SetTextCentre(1) 86 | SetTextEntry("STRING") 87 | AddTextComponentString(text) 88 | DrawText(0.5, 0.93) 89 | end 90 | 91 | function ShowHelpMsg(msg) 92 | BeginTextCommandDisplayHelp('STRING') 93 | AddTextComponentSubstringPlayerName(msg) 94 | EndTextCommandDisplayHelp(0, false, true, -1) 95 | end 96 | 97 | function loadAnimDict(dict) 98 | while (not HasAnimDictLoaded(dict)) do 99 | RequestAnimDict(dict) 100 | Citizen.Wait(0) 101 | end 102 | end 103 | 104 | --============================ 105 | -- KILLING & SELLING 106 | --============================ 107 | Citizen.CreateThread(function() 108 | SellingBlips() 109 | while true do 110 | Citizen.Wait(4) 111 | local ped = PlayerPedId() 112 | if (IsAimCamActive()) and not IsPedInAnyVehicle(ped, false) then 113 | local _, ent = GetEntityPlayerIsFreeAimingAt(PlayerId(),Citizen.ReturnResultAnyway()) 114 | if (ent and not IsEntityDead(ent)) then 115 | if (IsEntityAPed(ent)) then 116 | local model = GetEntityModel(ent) 117 | local animal = getAnimalMatch(model) 118 | if (model and animal) then 119 | handleDecorator(ent) 120 | if (not lastAnimalExists(ent)) then 121 | if (#lastAnimals > 10) then 122 | table.remove(lastAnimals, 1) 123 | end 124 | local newAnim = {} 125 | newAnim.entity = ent 126 | newAnim.data = animal 127 | table.insert(lastAnimals, newAnim) 128 | end 129 | end 130 | end 131 | end 132 | end 133 | if (#lastAnimals > 0) then 134 | for _, v in pairs(lastAnimals) do 135 | local pos = GetEntityCoords(ped) 136 | local rpos = GetEntityCoords(v.entity) 137 | if (GetDistanceBetweenCoords(pos, rpos.x, rpos.y, rpos.z, true) < 40 and isKillMine(v.entity)) then 138 | if (DoesEntityExist(v.entity)) then 139 | if (IsEntityDead(v.entity)) then 140 | DrawMarker(20, rpos.x, rpos.y, rpos.z + 0.8, 0, 0, 0,0, 0, 0, 0.5, 0.5, -0.25, 255, 60, 60, 150, 1, 1, 2, 0, 0, 0, 0) 141 | if (GetDistanceBetweenCoords(pos, rpos.x, rpos.y,rpos.z, true) < 1.1) then 142 | ShowHelpMsg('Press ~INPUT_PICKUP~ to Harvest Animal.') 143 | if IsControlJustPressed(0, 38) and not isPressed then 144 | QBCore.Functions.TriggerCallback("QBCore:HasItem", function(hasitem) 145 | if hasitem then 146 | loadAnimDict('amb@medic@standing@kneel@base') 147 | loadAnimDict('anim@gangops@facility@servers@bodysearch@') 148 | TaskPlayAnim(GetPlayerPed(-1),"amb@medic@standing@kneel@base","base", 8.0, -8.0, -1, 1, 0,false, false, false) 149 | TaskPlayAnim(GetPlayerPed(-1),"anim@gangops@facility@servers@bodysearch@","player_search", 8.0, -8.0, -1,48, 0, false, false, false) 150 | isPressed = true 151 | QBCore.Functions.Progressbar("harv_anim", "Harvesting Animal", 5000, false, false, { 152 | disableMovement = true, 153 | disableCarMovement = false, 154 | disableMouse = false, 155 | disableCombat = true, 156 | }, {}, {}, {}, function() 157 | ClearPedTasks(GetPlayerPed(-1)) 158 | TriggerServerEvent('cad-hunting:server:AddItem',v.data.id, 1) 159 | Citizen.Wait(100) 160 | DeleteEntity(v.entity) 161 | removeEntity(v.entity) 162 | isPressed = false 163 | end) 164 | else 165 | QBCore.Functions.Notify("You dont have knife.") 166 | end 167 | end, "weapon_knife") 168 | end 169 | end 170 | end 171 | else 172 | DeleteEntity(v.entity) 173 | removeEntity(v.entity) 174 | end 175 | end 176 | end 177 | end 178 | 179 | for _, v in pairs(SellSpots) do 180 | local pos = GetEntityCoords(ped) 181 | if #(vector3(pos.x, pos.y, pos.z)-vector3(v.x, v.y, v.z)) < 8 then 182 | DrawMarker(20, v.x, v.y, v.z, 0, 0, 0, 0, 0, 0, 0.5, 0.5,-0.25, 255, 60, 60, 150, 1, 1, 2, 0, 0, 0, 0) 183 | if #(vector3(pos.x, pos.y, pos.z)-vector3(v.x, v.y, v.z)) < 2 then 184 | ShowHelpMsg('Press ~INPUT_PICKUP~ to Sell Hunting Items.') 185 | if IsControlJustPressed(0, 38) then 186 | TriggerServerEvent('cad-hunting:server:sellmeat') 187 | end 188 | end 189 | end 190 | end 191 | end 192 | end) 193 | 194 | --============================ 195 | -- Spawning Ped 196 | --============================ 197 | RegisterNetEvent('cad-hunting:client:spawnanim') 198 | AddEventHandler('cad-hunting:client:spawnanim', function(model) 199 | model = (tonumber(model) ~= nil and tonumber(model) or GetHashKey(model)) 200 | local playerPed = PlayerPedId() 201 | local coords = GetEntityCoords(playerPed) 202 | local forward = GetEntityForwardVector(playerPed) 203 | local x, y, z = table.unpack(coords + forward * 1.0) 204 | 205 | Citizen.CreateThread(function() 206 | RequestModel(model) 207 | while not HasModelLoaded(model) do 208 | Citizen.Wait(1) 209 | end 210 | CreatePed(5, model, x, y, z, 0.0, true, false) 211 | end) 212 | end) 213 | --------------------------------------------------------------------------------