config/events.lua > Config.Events

In this file you will find a list of default zones and its configuration, this is the list that you see when you create a new zone using the admin panel.

Create a new zone

  • For this example we are gonna create a new zone that will work as a Boss Stash and will require specials permissions to access it.

  • First add a new field to Config.Events:

["index_key"] = needs to be unique and is also used as zone type, for this example we named it 'boss_stash'

label = Is how you are gonna see it in the admin menu and when using the Target system.

event = is the event to trigger when you use this zone.

icon = the icon to use on target, icon names can be found in fontawesome website.

job = true/false if you want the zone to be job restricted, for this example we are gonna use true because we want the job boss be the only one who can access it.

  • Using the Admin Panel create a new zone for the Boss Stash, I'm skipping the creation part because is already explained in Admin Panel

  • Once the zone is created and if you have the needed job you will be able to see it but you will notice that nothings happen when you click it and that's because we haven't created the av_business:boss_stash event...

  • The event can be created in any resource, you can basically create a zone that triggers an event from your mechanic script, your police job, etc... But for this example we are creating the event in av_business/client/editable/stashes.lua and will look something like this:

  • The event will receive data as argument, this data contains the following info:

label: zone label name: an unique name for this specific zone zoneJob: the job linked to this event or false if no job is linked in Config.Events.

  • Data contains more info but for this example we are only using this 3 fields.

  • We want the boss to be the only one who can open the stash, we need to retrieve the player permissions using the getPermissions export from av_business, if isBoss permission exists we are gonna open the stash but if is false we trigger a notification.

RegisterNetEvent("av_business:boss_stash", function(data)
    -- print(json.encode(data, {indent = true}) -- Uncomment this if u want the full content of data table
    local label = data['label']
    local job = data['zoneJob']
    local name = data['name']
    local slots = 10
    local weight = 10000
    local permissions = exports['av_business']:getPermissions(job) -- it retrieves the players permissions from av_business
    if permissions and permissions['isBoss'] then -- check for isBoss permission, if true open stash if false show notification
        exports['av_laptop']:openStash(name, label, weight, slots)
        TriggerEvent("av_laptop:notification", Lang['app_title'], "You don't have permissions for this...", "error")
  • This is how you can register a new zone and trigger any client event you want, this is just an example, is on you to register and code your own events, add your permissions, checks, etc.

Last updated