Using boxZones

Changing locations and coordinates

What is a boxZone?

  1. As part of your recipe qb-core installation, you may notice that there is a resource named "PolyZone" which appears in your [standalone] folder.

  2. The PolyZone resource allows you to create a series of different zones which allow players to "target" them using qb-target or an equivalent resource.

  3. The readme.md which is contained within the PolyZone resource is detailed and carefully explains how to use the PolyZone resource. mz-resources recommends you read it carefully and consult it frequently if you are new to fiveM development.

boxZones in mz-resources

  1. mz-resources frequently uses boxZones to create locations for players to interact with.

  2. An example of a boxZone export appears in mz-bins where the pawnshop to sell items found in bins is located in your server:

    CreateThread(function()
        exports['qb-target']:AddBoxZone("sellbinitems", vector3(1703.29, 3779.5, 34.75), 1.2, 0.5, {
            name = "sellbinitems",
            heading = 125,
            debugPoly = false,
            minZ = 32.15,
            maxZ = 36.15,
            }, {
                options = { 
                {
                    type = "client",
                    event = "mz-bins:client:menuSelect",
                    icon = 'fas fa-trash',
                    label = 'Sell Items'
                },
            },
            distance = 1.5,
         })
    end)
  3. To modify this location, you will notice that the "AddBoxZone" export contains a number of co-ordinate details include the vector3, heading, minZ and maxZ of the relevant zone.

Creating a new boxZone to move locations

  1. To create a new boxZone, go into your server and type "/pzcreate"

  2. The name of the zone is irrelevant - you can type whatever you like here.

  3. The x and y sizes will dictate the size of the boxZone created. Using the same x and y values will create a square, using different values will create a rectangle. Fiddling with this function will allow you to get a feel for the types of boxZones you can create.

  4. If you make a mistake type "/pzcancel" - and to start again, type "/pzcreate".

  5. Once you have moved the created boxzone into the relevant position for where you would like it to trigger, type "/pzfinish". Again - we recommend that you consult the readme for PolyZone for more information regarding functionality.

Finding the details of the boxZone you created

  1. Once you have created a boxZone, navigate to your server folder where your server.cfg file is location (it should be one folder up from the "resources" folder branch.

  2. You will notice a txt file created called "polyzone_created_zones"

  3. Open this file and if you have never made any other polyzones, the first entry should be the zone you just created. If you have previously made any polyzones, this file will contain the zones in sequential order i.e. the last one you made will be the latest. For example:

--Name: EXAMPLEBOXZONE | 2023-04-07T10:40:03Z
BoxZone:Create(vector3(471.25, 2607.2, 44.48), 1.2, 0.3, {
  name="PLACEHOLDERNAME",
  heading=98,
  --debugPoly=true,
  minZ=41.68,
  maxZ=45.68
})
  1. Here you can see the appropriate vector3, boxZone size, heading and minZ/maxZ values for the boxZone you just created. The other variables are not as interesting as you are likely to delete this text once the boxZone you have created has been properly configured.

  2. Comparing the data in the boxZone you have just created with the export used by mz-bins you can see the variables you need to change in order to change the boxZone (being:

  • everything that appears after (vector3...

  • heading

  • minZ

  • maxZ

  1. You can then copy and paste those parameters into the script you are trying to change to change the location of the boxZone that will be used by that script.

  2. Once you are done you can delete this file or remove its contents so that you will not confuse yourself when you make new polyZones.

Last updated