Stausi Libraries
A standalone libraries for providing reusable code to increase the compatibility between scrips.
Installation
- Download the last release of the library
- Add the resource
st_libs
in your resources folder - Add
ensure st_libs
in your server.cfg
Usage
- To use libraries, just add the initiator as a shared script inside of your
fxmanifest.lua
file.
lua
shared_scripts {
'@st_libs/init.lua'
}
- List modules you want use inside the
fxmanifest.lua
(in lowercase)
lua
st_libs {
'print',
'table',
}
You can now use the libraries inside of your resource with the st
global variable.
Functions
Some functions are automatically added when you use st_libs in your script.
st.ready()
A function fired when all modules are loaded
Syntax
lua
st.ready(cb)
Parameters
cb
: function
The function to execute
Example
lua
st.ready(function()
print('All modules are loaded')
end)
st.stopped()
A function fired when the script is stopped
Syntax
lua
st.stopped(cb)
Parameters
cb
: function
The function to execute
Example
lua
st.stopped(function()
print(GetCurrentResourceName()..' has been stopped')
end)