Script for PolyZone to trigger an event by pressing E.
Last updated
new locked doorsMaybe you wondering how to use this script
Don't worry we will help here. Here you learn how to use our script.
How to use BoxE
First of all, we create a new Box in Boxes.lua
The Box config should look like that. Of course, customize it by your preferences
[1] = { ["enabled"] =true, ['coords'] =vector4(-57.0654, -1097.0039, 26.4224, 205.0292), ['sizeY'] =3, -- Size of box ['sizeX'] =2, --Size of box--['sizeZ'] = 2, -- 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. },
If you want to add next box just change [1] to [2]
[2] = { ["enabled"] =true, ['coords'] =vector4(-60.0654, -1097.0039, 26.4224, 205.0292), ['sizeY'] =3, -- Size of box ['sizeX'] =2, --Size of box ['message'] ='to trigger REEEE', --Text what you want ['side'] ='left', --Left/Right ['Trigger'] ='REEEEE', --Custom name what you set up in events.lua, if you don't need just leave it blank. },
So final config should look like that
boxes.lua
--[[ 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] = { ["showbox"] =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. }, [2] = { ["showbox"] =true, ['coords'] =vector4(-60.0654, -1097.0039, 26.4224, 205.0292), ['sizeY'] =3, -- Size of box ['sizeX'] =2, --Size of box ['sizeX'] =2, don't have to be there. Default is 2 ['message'] ='to trigger REEEE', --Text what you want ['side'] ='left', --Left/Right ['Trigger'] ='REEEEE', --Custom name what you set up in events.lua, if you don't need just leave it blank. },}
Now we have to set up Triggers. So, We open the events.lua and we make a new condition
The Condition is up to you. It depends on what you want to trigger
For example, I want to send to player a message by box [1] and by box [2] I want to spawn a vehicle
events.lua
local QBCore = exports['qb-core']: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 =='REEEEE' then QBCore.Functions.Notify('Now it works 2 :Wink:.', 'success', 7500) QBCore.Functions.SpawnVehicle('adder')--[[ elseif event == 'Example' then --Whatever you want ]]end
How to use BoxE for doors
First of all, we have to create new locked doors and set it all in qb-doorlock. Also, I recommend setting distance to 0
Now, we create a new Box in Doors.lua
The Box config should look like that. Of course, customize it by your preferences again
Doors.lua
--[[ 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 },}
These configs are just examples. The most of settings should be combinable.
If you find any bugs or you still didn't get it how it works contact us in the Support room on Discord.