Page cover image

πŸ“ƒUsage

Everything you need to understand how to use the script.

Command

/startcapturethearea zonename

You can use it from the console or in-game if you have the permissions you've set in IsAllowedToStart() configurable open function.

Exports

Start Event Out Of Schedule (Server-Sided)

exports["petris-capturethearea"]:StartEvent() -- For Random Area Selection

exports["petris-capturethearea"]:StartEvent("AreaName") -- For Specific Area

Check If Player Is Capturing (Client-Sided)

exports["petris-capturethearea"]:IsPlayerCapturing()

Check If Player Is In Zone (Client-Sided)

exports["petris-capturethearea"]:IsPlayerInZone()

Weekly Schedule Configuration

Schedule = {
        ['Monday'] = {
            {zone = "House", hour = 14, minute = 0}, -- 14:00 - 2:00PM
            {zone = "random", hour = 18, minute = 30}, -- 18:30 - 6:30PM
        },
        ['Tuesday'] = {
            {zone = "House", hour = 14, minute = 0}, -- 14:00 - 2:00PM
            {zone = "random", hour = 18, minute = 30}, -- 18:30 - 6:30PM
        },
        ['Wednesday'] = {
            {zone = "House", hour = 14, minute = 0}, -- 14:00 - 2:00PM
            {zone = "random", hour = 18, minute = 30}, -- 18:30 - 6:30PM
        },
        ['Thursday'] = {
            {zone = "House", hour = 14, minute = 0}, -- 14:00 - 2:00PM
            {zone = "random", hour = 18, minute = 30}, -- 18:30 - 6:30PM
        },
        ['Friday'] = {
            {zone = "House", hour = 14, minute = 0}, -- 14:00 - 2:00PM
            {zone = "random", hour = 18, minute = 30}, -- 18:30 - 6:30PM
        },
        ['Saturday'] = {
            {zone = "House", hour = 14, minute = 0}, -- 14:00 - 2:00PM
            {zone = "random", hour = 18, minute = 30}, -- 18:30 - 6:30PM
        },
        ['Sunday'] = {
            {zone = "House", hour = 14, minute = 0}, -- 14:00 - 2:00PM
            {zone = "random", hour = 18, minute = 30}, -- 18:30 - 6:30PM
        }
    },

In the zone value, you can either set "random" to let the script select one of your configured zones or the name of a specific zone of your configured zones.

Areas/Zones Configuration

Zones = {
        ["House"] = {
            ["Area"] = { -- INFO: /pzcreate: to start a polyzone creation, /pzadd to add a point in the polyzone, /pzfinish to finish the creation of the polyzone.
                vector2(3275.9729003906, 5182.8525390625),
                vector2(3286.1896972656, 5196.1513671875),
                vector2(3288.8740234375, 5197.8774414063),
                vector2(3307.4431152344, 5200.8916015625),
                vector2(3333.015625, 5181.2436523438),
                vector2(3315.8989257813, 5158.84765625),
                vector2(3312.8894042969, 5160.7846679688),
                vector2(3309.7436523438, 5156.7666015625)
            },
            ["Blip"] = {
                Coords = vector3(3305.22,5178.94,17.16)
            },
            ["Settings"] = {
                visible = true,
                minZ = 17.0, 
                maxZ = 37.0,
            },
            ["Duration"] = 2, -- INFO: Duration in minutes.
            ["Bucket"] = 1, -- INFO: Use 0 if you don't want an exclusive area bucket.
            ["ViewDistance"] = 100.0, -- INFO: View distance to see the zone if setted to be visible.
            ["Rewards"] = { -- INFO: You can add any types, names and amount of rewards as the reward function is open source and you can handle freely the function.
                {type = "item", name = "bread", amount = 5},
                {type = "weapon", name = "WEAPON_PISTOL", amount = 50},
                {type = "money", name = "black_money", amount = 1000}
            }
        }
    },

In order to create a zone properly, you must create a polyzone via PolyZone script. /pzcreate : To start the creation of a zone. /pzadd : To add points of a zone. (Better use zone corners for points) /pzfinish : To finish the zone. After that, a text file will be generated in the same location where your server.cfg is located at.

Open Framework Functions

Functions = {
        TriggerCronTask = function(h, m) -- INFO: ESX Cron is used here. Change it if you're using something else.
            TriggerEvent('cron:runAt', h, m, StartCaptureTheArea)
        end,
        RewardPlayer = function(playerId, reward) -- INFO: In this function, you can handle any type of rewards the capturer will receive.
            -- ESX EXAMPLE
            if reward.type == 'item' then
                local xPlayer = Config.Framework.GetPlayerFromId(playerId)
                xPlayer.addInventoryItem(reward.name, reward.amount)
            end
        end,
        GetPlayerGroup = function(playerId) -- INFO: This is used to avoid capturing being paused by friends 
            -- ESX EXAMPLE
            local xPlayer = Config.Framework.GetPlayerFromId(playerId)
            return xPlayer.job.name
        end,
        SendNotificationToPlayer = function(playerId, text)
            -- ESX EXAMPLE
            TriggerClientEvent('esx:showNotification', playerId, text)
        end,
        Announcement = function(text)
            -- ESX EXAMPLE (Notification)
            -- RECOMMENDATION: It would be better if you replace the notification with a chat message instead.
            TriggerClientEvent('esx:showNotification', -1, text)
        end,
        IsStaff = function(playerId)
            -- ESX EXAMPLE
            local xPlayer = Config.Framework.GetPlayerFromId(playerId)
            if xPlayer.getGroup() ~= 'user' then
                return true
            end
            return false
        end,
        IsAllowedToStart = function(playerId)
            -- ESX EXAMPLE
            local xPlayer = Config.Framework.GetPlayerFromId(playerId)
            if xPlayer.getGroup() == 'superadmin' then
                return true
            end
            return false
        end
    }

We've added ESX functionality as it's the most popular framework right now, but you can use any framework and make the script work. If you need extra assistance, please don't hesitate to open a ticket on my Discord Server.

Last updated