A helpful template/starting place for developers to make Lua scripts from.
What is a Boilerplate?!
A Boilerplate, this boilerplate, is a simple template script with a plethora of definitions, examples, tutorials, and more. The goal being to get any programmer building scripts with VORP as quickly and easily as possible.
How to install
Download this repo
Copy and paste boilerplate folder to resources/boilerplate
Rename resources/boilerplate to resources/<YOUR_RESOURCE_NAME> <<<<<<<<<<<<< !important
Add ensure <YOUR_RESOURCE_NAME> to your server.cfg file
Now you are ready to get coding!
How can I use this Codebase?
1. Use this to learn
2. Remove what you don't want to use and use this as your scripts base. <<<<<<<<<<<<< **!important**
3. Use this as a reference resource
4. Use this to standardize your code with ours
5. Use this code as you please
What do I do after I save my code?
You can refresh your script via server live console, f8, or terminal.
/refresh <YOUR_RESOURCE_NAME>
If all else fails, restart your server entirely.
Developer Tips
Use PlayerPedId() dont use GetPlayerPed(-1) as it is more optimal
If you are looking to calculate distance between coordinates. Do not use GetDistanceBetweenCoords, instead use with Lua math #(vector3 - vector3) or Vdist2 its much faster and optimized
Dont use table.insert USE tableName[#tableName+1] = useThis
Control your Citizen.CreateThreadwhile true loops with sleep = Wait(1000) in the threads to control the threads tick rate (how often/fast the loop cycles)
Use local variables whenever you can to help reduce your scripts overall memory consumption. Example:local str = "hello"
Instead of if this ~= nil use if this then. This method checks for nil and/or false at the same time
Check if the player is allowed before checking distance or displaying something. There is no need to run code if the client isn't meant to use it.. Example: If you are checking a player distance that is job specific, then add/use a job check with playerjob. Perform the check before executing any other code that is dependant on it.