├── fxmanifest.lua ├── README.md ├── server.lua ├── config.lua └── client.lua /fxmanifest.lua: -------------------------------------------------------------------------------- 1 | fx_version 'adamant' 2 | 3 | game 'gta5' 4 | Author "Ashen BoY" 5 | 6 | description "mushroom" 7 | 8 | client_scripts { 9 | "client.lua", 10 | } 11 | shared_scripts { 12 | "config.lua" 13 | } 14 | server_scripts { 15 | "server.lua", 16 | 17 | } 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # qb-mushroomfarm # 2 | 3 | The script is not my creation, I only did optimization and esx to qb translation. 4 | Join My Server https://discord.gg/QD3wkkjpgz 5 | 6 | #More Scripts Coming Soon# 7 | 8 | Video: https://streamable.com/tjdgyk 9 | 10 | Original script: https://forum.cfx.re/t/esx-mushroom-farming-converted-from-vrp-to-esx/1868663 11 | -------------------------------------------------------------------------------- /server.lua: -------------------------------------------------------------------------------- 1 | QBCore = nil 2 | QBCore = exports['qb-core']:GetCoreObject() 3 | local minpayout = 500 4 | local maxpayout = 600 5 | TriggerEvent('QBCore:GetObject', function(obj) QBCore = obj end) 6 | 7 | RegisterNetEvent("qb-mushroomfarmer:sell") 8 | AddEventHandler("qb-mushroomfarmer:sell", function() 9 | local xPlayer = QBCore.Functions.GetPlayer(source) 10 | local payout = math.random(minpayout,maxpayout) 11 | xPlayer.Functions.AddMoney("cash", payout, "sold-mushrooms") 12 | TriggerClientEvent('QBCore:Notify', source, 'You earnd ' ..payout.. '$ from selling mushrooms.', "success") 13 | end) -------------------------------------------------------------------------------- /config.lua: -------------------------------------------------------------------------------- 1 | Config = Config or {} 2 | Config = { 3 | coordonate = { 4 | {1906.4095, 4744.5923, 41.0109,}, 5 | {1916.3906, 4753.0703, 41.5258,}, 6 | {1926.9219, 4762.0908, 41.5947,}, 7 | {1903.6913, 4747.6240, 40.9170,}, 8 | {1913.5354, 4756.7612, 41.5951,}, 9 | {1923.6750, 4766.4019, 41.8050,}, 10 | }, 11 | MushroomShoplocation = { 12 | ["x"] = 1725.4817, 13 | ["y"] = 4642.5386, 14 | ["z"] = 43.8755, 15 | }, 16 | MushroomFarmlocation = { 17 | ["x"] = 1919.1243, 18 | ["y"] = 4758.5723, 19 | ["z"] = 42.6627, 20 | }, 21 | 22 | } 23 | 24 | Config.CollectingTime = 10000 25 | 26 | -------------------------------------------------------------------------------- /client.lua: -------------------------------------------------------------------------------- 1 | QBCore = nil 2 | QBCore = exports['qb-core']:GetCoreObject() 3 | 4 | local hasjob = false 5 | local mushrooms = 0 6 | local coordonate = Config.coordonate 7 | local sleep = 2000 8 | local CollectingTime = Config.CollectingTime 9 | 10 | 11 | Citizen.CreateThread(function() 12 | while QBCore == nil do 13 | TriggerEvent('QBCore:GetObject', function(obj) QBCore = obj end) 14 | Citizen.Wait(0) 15 | end 16 | end) 17 | 18 | function DrawText3D(x,y,z, text, scl) 19 | local onScreen,_x,_y=World3dToScreen2d(x,y,z) 20 | local px,py,pz=table.unpack(GetGameplayCamCoords()) 21 | local dist = GetDistanceBetweenCoords(px,py,pz, x,y,z, 1) 22 | local scale = (1/dist)*scl 23 | local fov = (1/GetGameplayCamFov())*100 24 | local scale = scale*fov 25 | if onScreen then 26 | SetTextScale(0.0*scale, 1.1*scale) 27 | SetTextFont(4) 28 | SetTextProportional(1) 29 | SetTextColour(255, 255, 255, 255) 30 | SetTextDropshadow(0, 0, 0, 0, 255) 31 | SetTextEdge(2, 0, 0, 0, 150) 32 | SetTextDropShadow() 33 | SetTextOutline() 34 | SetTextEntry("STRING") 35 | SetTextCentre(1) 36 | AddTextComponentString(text) 37 | DrawText(_x,_y) 38 | end 39 | end 40 | 41 | CreateThread(function() 42 | local blip = AddBlipForCoord(Config.MushroomShoplocation["x"],Config.MushroomShoplocation["y"],Config.MushroomShoplocation["z"]) 43 | SetBlipSprite(blip, 124) 44 | SetBlipAsShortRange(blip, true) 45 | SetBlipScale(blip, 0.7) 46 | SetBlipColour(blip, 49) 47 | BeginTextCommandSetBlipName("STRING") 48 | AddTextComponentString("Mushroom Shop") 49 | EndTextCommandSetBlipName(blip) 50 | end) 51 | CreateThread(function() 52 | local blip = AddBlipForCoord(Config.MushroomFarmlocation["x"],Config.MushroomFarmlocation["y"],Config.MushroomFarmlocation["z"]) 53 | SetBlipSprite(blip, 124) 54 | SetBlipAsShortRange(blip, true) 55 | SetBlipScale(blip, 0.7) 56 | SetBlipColour(blip, 49) 57 | BeginTextCommandSetBlipName("STRING") 58 | AddTextComponentString("Mushroom Farm") 59 | EndTextCommandSetBlipName(blip) 60 | end) 61 | 62 | Citizen.CreateThread(function() 63 | while true do 64 | Citizen.Wait(sleep) 65 | perform = false 66 | local pos = GetEntityCoords(PlayerPedId()) 67 | local metrii = math.floor(GetDistanceBetweenCoords(Config.MushroomShoplocation["x"],Config.MushroomShoplocation["y"],Config.MushroomShoplocation["z"], GetEntityCoords(PlayerPedId()))) 68 | if mushrooms == 6 then 69 | perform = true 70 | DrawText3D(pos.x,pos.y,pos.z, "~y~Go and Sell Mushrooms", 1) 71 | end 72 | if hasjob == true then 73 | for i,v in pairs(coordonate) do 74 | local metrii2 = math.floor(GetDistanceBetweenCoords(v[1],v[2],v[3], GetEntityCoords(PlayerPedId()))) 75 | if mushrooms == 1 or mushrooms == 2 or mushrooms == 3 or mushrooms == 4 or mushrooms == 5 then 76 | perform = true 77 | DrawText3D(pos.x,pos.y,pos.z, "Mushrooms ~r~"..mushrooms.."~w~/~g~6", 1) 78 | end 79 | if coordonate[i] ~= nil then 80 | if metrii2 <=1 then 81 | perform = true 82 | DrawText3D(v[1],v[2],v[3]+0.7, "Press ~y~[E]~w~ to collect mushrooms.", 1) 83 | if IsControlJustPressed(1,51) then 84 | table.remove(coordonate,i) 85 | local playerPed = PlayerPedId() 86 | TaskStartScenarioInPlace(playerPed, 'PROP_HUMAN_PARKING_METER', 0, false) 87 | SetTimeout(CollectingTime, function() 88 | ClearPedTasks(playerPed) 89 | QBCore.Functions.Notify("You have collected a mushroom.", "success") 90 | mushrooms = mushrooms + 1 91 | if mushrooms == 6 then 92 | SetNewWaypoint(Config.MushroomShoplocation["x"],Config.MushroomShoplocation["y"],Config.MushroomShoplocation["z"]) 93 | end 94 | end) 95 | end 96 | end 97 | else 98 | perform = true 99 | DrawText3D(coordonate[i]+0.7, "The mushroom has already been collected.", 1) 100 | end 101 | end 102 | end 103 | if metrii <= 2 then 104 | perform = true 105 | DrawText3D(pos.x,pos.y,pos.z+0.6, "Press ~y~[E]~w~ to get mushroom basket.\n Press ~y~[Y]~w~ to sell mushrooms.", 1) 106 | if IsControlJustPressed(1,51) then 107 | if hasjob == false then 108 | cosdeoua = CreateObject(GetHashKey("prop_fruit_basket"), pos.x, pos.y, pos.z, true, true, true) 109 | AttachEntityToEntity(cosdeoua, PlayerPedId(), GetPedBoneIndex(PlayerPedId(), 28422), 0.22, -0.3+0.25, 0.0+0.16, 160.0, 90.0, 125.0, true, true, false, true, 1, true) 110 | QBCore.Functions.Notify("You're hired!", "success") 111 | 112 | hasjob = true 113 | SetNewWaypoint(Config.MushroomFarmlocation["x"],Config.MushroomFarmlocation["y"],Config.MushroomFarmlocation["z"]) 114 | for i,v in pairs(coordonate) do 115 | cvprop = CreateObject(GetHashKey('prop_stoneshroom1'), v[1],v[2],v[3], false) 116 | end 117 | elseif hasjob == true then 118 | QBCore.Functions.Notify("You have already been hired as a Mushroom Farmer.", "success") 119 | end 120 | elseif IsControlJustPressed(1,246) then 121 | if mushrooms == 6 then 122 | TriggerServerEvent("qb-mushroomfarmer:sell") 123 | mushrooms = 0 124 | hasjob = false 125 | DeleteEntity(cosdeoua) 126 | DeleteEntity(cosdeoua) 127 | else 128 | QBCore.Functions.Notify("Do not be silly.", "success") 129 | end 130 | end 131 | end 132 | if perform then 133 | sleep = 7 134 | elseif not perform then 135 | sleep = 2000 136 | end 137 | end 138 | end) --------------------------------------------------------------------------------