Documentation
  • Weed Script
    • Installation
      • RedEM-RP
      • RSG
      • QR CORE
      • QBR CORE
      • VORP
      • SQL
    • Accessible code
  • Report System
    • Installation
    • Accessible code
  • SafeZone Creator
    • Installation
    • SQL File
    • Accessible code
  • Promo Codes Creator
    • Installation
    • Accessible code
  • Player Manager
    • Installation
    • Accessible code
Powered by GitBook
On this page
  1. Weed Script

Accessible code

Shared = {
    Locale = 'en',

    commands = {
        deletePlant = {
            name = 'deleteplant',
            help = 'Command that allows you to delete closest plant to you',
            restricted = 'group.admin'
        },

        tpplant = {
            name = 'tpplant',
            help = 'Command that allows you to teleport to desired plant',
            restricted = 'group.admin'
        },

        plantShow = {
            name = 'plantshow',
            help = 'Command that allows you to turn on/off blips of weed\'s on minimap',
            restricted = 'group.admin'
        },
        
        plantInfo = {
            name = 'plantinfo',
            help = 'Command that allows you to get closest plant info',
            restricted = 'group.admin'
        },

        plantid = {
            name = 'plantid',
            help = 'Command that allows you to get cloest plant ID',
            restricted = 'group.admin'
        },

        placeplant = {
            name = 'placeplant',
            help = 'Command that allows you to place plant on desired location'
        },

        cornersell = {
            enabled = true,         -- if you dont want to use this cornersell, put this to false
            name = 'cornersell',
            help = 'Command that turns on/off corner selling',
            reward = 'black_money'  -- item that you will get upon selling weed
        }
    },

    math = {
        updateInterval      = 35000,            -- how often plants are updated in msec, would recomment not to go under 30000 msec (30 sec)

        /*
        in every updateInterval hydratation
        and feed will decrease by reduceHydration

        aka:
        every 35 sec hydratation and feed will decrease by
        3% and growth will increase by 2%
        */

        reduceHydration     = 3.0,
        reduceFeed          = 3.0,
        giveGrowth          = 2.0,

        giveWater           = 10.0, -- how much % plant will get upon watering
        giveFood            = 10.0, -- how much % plant will get upon feeding

        /*
        in every updateInterval if plants
        hydratation is above QualityLvl
        then it will give giveQuality else it will
        reduceQuality

        aka:
        in every 35 sec if hydratation and
        feed >= 65% then quality of plant will
        increase by 5% else it will decrease
        by 5%
        */

        QualityLvl          = 65.0,
        giveQuality         = 5.0,
        reduceQuality       = 5.0,


        /*
        on what growth % it will change to next stage

        aka if plants growth is 55% then it will go to stage II,
        same for stage III
        */

        stageII             = 55.0,
        stageIII            = 85.0,

        /*
        after plant reaches 100%, on harvest
        next math will be applied:

        quality / 2
        max 100 / 2 = 50
        min 10 / 2 = 10

        if you took well care of plant
        and it has 100% quality you will
        get 50 rewardItem
        */


        harvestMath = 2, -- plant quality / harvestMath will give final item, 100 quality / 2 = 50 cannabis, 10 quality / 2 = 5 cannabis
    },

    durations = {
        watering = 6000,                        -- 6 sec sec
        feedingPlant = 6000,                    -- 6 sec sec
        removingPrints = 7500,                  -- 7.5 sec
        searchingForPrints = 10000,             -- 10 sec
    },

    TextUI = {
        position = "right-center",
        icon = 'fa-solid fa-cannabis',
        style = {
            borderRadius = 5,
            backgroundColor = '#48BB78',
            color = 'white'
        }
    },

    notifyPosition = 'bottom',                  -- 'top' or 'top-right' or 'top-left' or 'bottom' or 'bottom-right' or 'bottom-left' or 'center-right' or 'center-left'

    WeedStages = {                              -- plants per stage, if you have custom prop for this just can put it here
        [1] = `prop_weed_small`,
        [2] = `prop_weed_medium`,
        [3] = `prop_weed_large`,
    },

    jobs = {                                    -- jobs that will be able to destroy plants
        ['police'] = true,
    },

    items = {
        pot = 'weedpot',
        fertilizer = 'fertilizer',              -- item used to increase growth of weed
        water = 'water',                        -- item used to to reduce thirst of plant,
        rewardItem = 'cannabis'                 -- when strain type is unknown it will give this item, when migratin from old version
    },


    -- if you are migrating from version before where no strains types existed, this price will be used when selling, when harvesting it will give item that you used before in items.rewardItem
    priceForUnknown = math.random(50, 90),

    strains = {
        ['p_haze'] = {              -- item name (you need to add this item to your inventory or framework)
            seed = 'p_haze_seed',   -- seed item name (you need to add this item to your inventory or framework)
            label = 'Purple Haze',  -- label that will be displayed in menu
            back = { 0, 2, 30 },    -- { minimum, maximum, give chance, min 0, max 2, chance 30% }, upon harvesting how much you should get seed
            --price = 150,            -- price per item, you can also use math.radnom() to get random price upon every script start, also supported price per day
            price = {
                ['Mon'] = math.random(50, 100),
                ['Tue'] = 110,
                ['Wed'] = 120,
                ['Thu'] = 130,
                ['Fri'] = 140,
                ['Sat'] = 150,
                ['Sun'] = 170,
            },
            sellChance = 90 -- % to sell item to npc
        }

        -- you can add more types here
    },

    maxPlants = 6,                              -- max plants per player, if you put false then this feature is disabled

    forbiddenPlantZones = {                     -- zone where people will not be able to plant weed, radius is around 500 units from center of this coords
        {coords = vec3(426.544, -979.332, 30.706)},
    },
}
if IsVorp() then
    VORPinv = exports.vorp_inventory
elseif IsRedem() then
    invData = {}
    TriggerEvent("redemrp_inventory:getData",function(call)
        invData = call
    end)
end


function AddItem(source, item, amount)
    if IsQBR() then
        local Player = exports['qbr-core']:GetPlayer(source)

        if Player then
            Player.Functions.AddItem(item, amount)
        end
    elseif IsRSG() then
        local Player = RSGCore.Functions.GetPlayer(source)

        if Player then
            Player.Functions.AddItem(item, amount)
        end
    elseif IsVorp() then
        exports['vorp_inventory']:addItem(source, item, amount)
    elseif IsRedem() then
        local itemData = invData.getItem(source, item)

        if itemData then
            itemData.AddItem(amount)
        end
    elseif IsQR() then
        local Player = QRCore.Functions.GetPlayer(source)

        if Player then
            Player.Functions.AddItem(item, amount)
        end
    end
end

function RemoveItem(source, item, amount)
    if IsQBR() then
        local Player = exports['qbr-core']:GetPlayer(source)

        Player.Functions.RemoveItem(item, amount)
    elseif IsRSG() then
        local Player = RSGCore.Functions.GetPlayer(source)

        if Player then
            Player.Functions.RemoveItem(item, amount)
        end
    elseif IsVorp() then
        local itemId = exports['vorp_inventory']:getItem(source, item)
        --TriggerClientEvent('vorpInventory:removeItem', source, item, itemId.id, amount)
        exports.vorp_inventory:RemoveItem(source, item, amount)
    elseif IsRedem() then
        local ItemData = invData.getItem(source, item)

        if ItemData then
            ItemData.RemoveItem(amount)
        end
    elseif IsQR() then
        local Player = QRCore.Functions.GetPlayer(source)

        if Player then
            Player.Functions.RemoveItem(item, amount)
        end
    end
end


function GetItemAmount(source, name)
    if IsQBR() then
        local Player = exports['qbr-core']:GetPlayer(source)

        if Player then
            local item = Player.Functions.GetItemByName(name)

            if item then
                return item.amount
            end
        end

        return 0
    elseif IsRSG() then
        local Player = RSGCore.Functions.GetPlayer(source)

        if Player then
            local item = Player.Functions.GetItemByName(name)

            if item then
                return item.amount
            end
        end

        return 0
    elseif IsVorp() then
        local item = exports['vorp_inventory']:getItem(source, name)

        if item then
            return item.amount
        end

        return 0
    elseif IsRedem() then
        local item = invData.getItem(source, name)

        if item then
            return item.ItemAmount
        end

        return 0
    elseif IsQR() then
        local Player = QRCore.Functions.GetPlayer(source)

        if Player then
            local item = Player.Functions.GetItemByName(name)

            if item then
                return item.amount
            end
        end

        return 0
    end
end

function GiveMoney(source, count)
    if IsQBR() then
        local Player = exports['qbr-core']:GetPlayer(source)

        if Player then
            Player.Functions.AddMoney(count)
        end
    elseif IsRSG() then
        local Player = RSGCore.Functions.GetPlayer(source)

        /*
            cash
            bank
            bloodmoney
        */

        if Player then
            Player.Functions.AddMoney('bloodmoney', count)
        end
    elseif IsVorp() then
        local Character = VORPcore.getUser(source)

        if Character then
            /*
                0 - money
                1 - gold
                2 - rol
            */
            TriggerEvent('vorp:addMoney', source, 0, count)
        end
    elseif IsRedem() then
        local Player = RedEM.GetPlayer(source)

        if Player then
            Player.AddMoney(count)
        end
    elseif IsQR() then
        local Player = QRCore.Functions.GetPlayer(source)

        if Player then
            Player.Functions.AddMoney(count)
        end
    end
end


-- if you dont want this, delete then, only allowed who have ace command allow or command.testscript
RegisterCommand('testscript', function (source, args, raw)
    if IsQBR() then
        local Player = exports['qbr-core']:GetPlayer(source)

        Player.Functions.AddItem('p_haze_seed', 2)
        Player.Functions.AddItem(Shared.items.pot, 2)
        Player.Functions.AddItem(Shared.items.water, 2)
        Player.Functions.AddItem(Shared.items.fertilizer, 2)
    elseif IsRSG() then
        local Player = RSGCore.Functions.GetPlayer(source)

        Player.Functions.AddItem('p_haze_seed', 2)
        Player.Functions.AddItem(Shared.items.pot, 2)
        Player.Functions.AddItem(Shared.items.water, 2)
        Player.Functions.AddItem(Shared.items.fertilizer, 2)
    elseif IsVorp() then
        VORPinv:addItem(source, 'p_haze_seed', 2)
        VORPinv:addItem(source, Shared.items.pot, 2)
        VORPinv:addItem(source, Shared.items.water, 2)
        VORPinv:addItem(source, Shared.items.fertilizer, 2)
    elseif IsRedem() then
        local a = invData.getItem(source, 'p_haze_seed')
        local b = invData.getItem(source, Shared.items.pot)
        local c = invData.getItem(source, Shared.items.water)
        local d = invData.getItem(source, Shared.items.fertilizer)

        if a then a.AddItem(2) end
        if b then b.AddItem(2) end
        if c then c.AddItem(2) end
        if d then d.AddItem(2) end
    elseif IsQR() then
        local Player = QRCore.Functions.GetPlayer(source)

        if Player then
            Player.Functions.AddItem('weedseed', 2)
            Player.Functions.AddItem(Shared.items.pot, 2)
            Player.Functions.AddItem(Shared.items.water, 2)
            Player.Functions.AddItem(Shared.items.fertilizer, 2)
        end
    end
end, true)
if IsQBR() then
	for k,v in pairs(Shared.strains) do
		exports['qbr-core']:CreateUseableItem(v.seed, function(source)
			local src = source
			local canPlant = lib.callback.await('enpwr_weed:plantNewSeed', src)

			if canPlant then
				PlantSeed(src, k)
			end
		end)
	end
elseif IsRSG() then
	for k,v in pairs(Shared.strains) do
		RSGCore.Functions.CreateUseableItem(v.seed, function(source)
			local src = source
			local canPlant = lib.callback.await('enpwr_weed:plantNewSeed', src)

			if canPlant then
				PlantSeed(src, k)
			end
		end)
	end
elseif IsVorp() then
	for k,v in pairs(Shared.strains) do
		exports['vorp_inventory']:registerUsableItem(v.seed, function(data)
			if data and data.source then
				local canPlant = lib.callback.await('enpwr_weed:plantNewSeed', data.source)

				if canPlant then
					PlantSeed(data.source, k)
				end
			end
		end)
	end
elseif IsRedem() then
	for k,v in pairs(Shared.strains) do
		RegisterServerEvent(("RegisterUsableItem:%s"):format(v.seed))
		AddEventHandler(("RegisterUsableItem:%s"):format(v.seed), function(source)
			local src = source
			local canPlant = lib.callback.await('enpwr_weed:plantNewSeed', src)
	
			if canPlant then
				PlantSeed(src, k)
			end
		end)
	end
elseif IsQR() then
	for k,v in pairs(Shared.strains) do
		QRCore.Functions.CreateUseableItem(v.seed, function(source)
			local src = source
			local canPlant = lib.callback.await('enpwr_weed:plantNewSeed', src)

			if canPlant then
				PlantSeed(src, k)
			end
		end)
	end
end
---@return boolean
function ExtraCheck()
    return true
end


---@param coords vector3|vector3[]
function PoliceNotify(coords)
    
end


local rsg = GetResourceState("rsg-inventory")

function ImagePath()
    if rsg then
        return 'nui://rsg-inventory/html/images/%s.png'
    end

    return ''
end


function Notify(msg, type)
    lib.notify({
        description = msg,
        type = type,
        position = Shared.notifyPosition,
        duration = 4500
    })
end

RegisterNetEvent('enpwr_weed:Notify', Notify)
PreviousSQLNextReport System

Last updated 11 months ago