Setup
Edit the first three lines of the index.ts file to set your custom folder layout, follow the folder structure below for a example.
const server_path: string = 'C:/fivem-server';
const cfx_data_path: string = 'cfx-server-data';
const artifacts_path: string = 'artifacts';
To install the node packages install Node.js and run the install.bat
you can delete this after.
To set your environment open the start.bat
file in your text editor and change environment
to either development
or production
, the latest artifacts will only be installed if the environment is set to production
Once you have completed the above steps run the start.bat
.
Folder structure
.
├── start.bat # Run this batch script to initiate the launch sequence.
├── cfx-server-data # Server data folder that should contain the resources, cache and server.cfg
│ └── cache # FiveM cache folder.
├── artifacts # FiveM artifacts folder.
└── builder # All files from this repository should be located in this folder.
Utilising the environment on the server
Once you have used the script to launch you're server you can use the convar environment
to access the environment variable on the server.
_G.environment = GetConvar('environment', 'development')
Use cases
Stop random players from joining the wrong server and allow developers and management to join.
if _G.environment == 'development' and allowed_accounts[account_id] ~= nil then
deferrals.done('Development server please join the live server instead.')
return
end
Only start checks that will be used for production.
Citizen.CreateThread(function()
if _G.environment == 'production' then
check_time_for_shutdown()
end
end)
Support
Feel free to make pull requests and issues i will try to respond to your requests and follows are highly appreciated :)