Script for PolyZone to trigger an event by pressing E.
Last updated
This script offers you to make PolyZone where is possible to trigger an event by pressing E.
Configuration
Here is a simple config for boxes. The box and door setup are in different files.
In boxes.lua you can manage BoxEs.
Here you can manage the opening of the doors by BoxE. The doors still have to be set up in qb-doorlock and also radius/distance has to be set to 0, then you can use doors.lua
Anyway, BoxE is better optimized than the qb-doorlock system to control locks.
qb-doorlock - 0,00ms idle | 0,03ms use
SA-BoxE - 0,00ms idle | 0,01ms use
Triggers are configurable in /client/events.lua
Here you can change notify system by your preferencies
local QBCore = exports[Config.Framework]:GetCoreObject()------------------------------------------------------- In config set the trigger name and continue event == "NameOfTrigger"functionSummonBoxEvent(Trigger)local event = Triggerif event =='Test' then QBCore.Functions.Notify('Now it works.', 'success', 7500)elseif event =='Test2' then QBCore.Functions.Notify('Now it works 2 :Wink:.', 'success', 7500)--[[ elseif event == 'Example' then --Whatever you want ]]endend
--[[ TEMPLATES ]]----BASIC TEMPLATES--You can combine most of things. If you find a bug contact us on Discord.--[[ [1] = { ["enabled"] = true, ['coords'] = vector4(-57.0654, -1097.0039, 26.4224, 205.0292), ['sizeY'] = 3, -- Size of box ['sizeX'] = 2, --Size of box --['sizeZ'] = 5, --SizeZ is optionable don't have to be there. Default is 2 ['message'] = '[E] to trigger Test', --Text what you want ['side'] = 'left', --Left/Right ['Trigger'] = 'Test', --Custom name what you set up in events.lua, if you don't need just leave it blank. }, [2] = { ["enabled"] = true, ['coords'] = vector4(-69.6077, -1088.9026, 26.5622, 40.0142), ['sizeY'] = 5, -- Size of box ['sizeX'] = 5, -- Size of box ['sizeZ'] = 5, -- Size of box ['message'] = 'to trigger Test2', --Text what you want ['side'] = 'left', --Left/Right ['Trigger'] = 'Test2', --Custom name what you set up in events.lua, if you don't need just leave it blank. }, ]]Shared.BoxEs = { [1] = { ["enabled"] =true, ['coords'] =vector4(-57.0654, -1097.0039, 26.4224, 205.0292), ['sizeY'] =3, -- Size of box ['sizeX'] =2, --Size of box--SizeZ don't have to be there. Default is 2 ['message'] ='to trigger Test', --Text what you want ['side'] ='left', --Left/Right ['Trigger'] ='Test', --Custom name what you set up in events.lua, if you don't need just leave it blank. },}
Shared = {} -- DO NOT TOUCH THIS!!!Config = { Framework ='qb-core', -- Don't touch this. Change it only if you have renamed qb Debug =false, -- To debug script. It shows also polyzones VersionCheck =true, -- Here is an option to disable the print of versions in the console. E_Side ='left', -- left/right | This define where will text [E] appear, if behind text or in front of. E_Text ='[E]', -- Text which appear in fron of every message. E_Control =38, -- Key which trigger box. All keys are registere here https://docs.fivem.net/docs/game-references/controls/#controls}
local Translations = { doors = { unlock ="[E] To Unlock ", lock ="[E] To Lock ", NotAuthorized ='You are not authorized to do that.', }}Lang = Locale:new({ phrases = Translations, warnOnMissing =true})
local QBCore = exports[Config.Framework]:GetCoreObject()functionSA_Notify(data)local data = dataif data =='NotAuthorized' then QBCore.Functions.Notify(Lang:t('doors.NotAuthorized'), 'error', 7500)endend
--[[ TEMPLATES ]]----BASIC TEMPLATES--You can combine most of things. If you find a bug contact us on Discord.--TEMPLATE FOR DOORS--[[ [1] = { ["enabled"] = true, ['coords'] = vector4(-60.6077, -1078.9026, 26.5622, 40.0142), ['sizeY'] = 5, -- Size of box ['sizeX'] = 5, -- Size of box --['sizeZ'] = 5, --SizeZ is optionable don't have to be there. Default is 2 ['side'] = 'left', --Left/Right ['unlock'] = '[E] Unlock', --Text to unlock --['lock'] = '[E] Lock', --Text to lock is optionable ['isDoor'] = true, --It starts qb-doorlock mode ['OneTime'] = true, --This is for one use. It automatically locks door after 2s by default or by Timer what you set below ['Timer'] = 1000, --This lock your door automatically after 1000 = 1s +- ['DoorID'] = '', --Here should be name of doors }, [2] = { ["enabled"] = true, ['coords'] = vector4(-38.4101, -1108.5775, 26.4688, 143.6674), ['sizeY'] = 3, -- Size of box ['sizeX'] = 2, -- Size of box ['unlock'] = 'Control of gate', --Text to unlock and lock ['side'] = 'left', --Left/Right ['isDoor'] = true, --It starts qb-doorlock mode ['DoorID'] = 'PDM-Entrance', --Here should be name of doors },}]]Shared.Doors = {--Put here code [1] = { ["enabled"] =true, ['coords'] =vector4(-60.61, -1093.79, 26.63, 251.62), ['sizeY'] =3, -- Size of box ['sizeX'] =2, -- Size of box ['side'] ='left', --Left/Right ['unlock'] ='Unlock', --Text to unlock ['isDoor'] =true, --It starts qb-doorlock mode ['OneTime'] =false, --This is for one use. It automatically locks door after 2s by default or by Timer what you set below ['Timer'] =1000, --This lock your door automatically after 1000 = 1s +- ['DoorID'] ='PDM-PDM_1', --Here should be name of doors },}