Popular Post TheNormalnij Posted November 21, 2022 Popular Post Share Posted November 21, 2022 (edited) LuaRocks is the package manager for Lua modules. Small tricks allow you to use it on MTA server. Installing Linux x64: Spoiler 1. Install ml_package module from github. 2. Install luarocks: sudo apt install luarocks lua5.1 3. Create configs: ~/.luarocks/default-lua-version.lua with content: return "5.1" ~/.luarocks/config-5.1.lua with content: arch = "x86_64" lua_version = "5.1" rocks_trees = { { name = "user", root = "/home/<YOU USER NAME>/.luarocks/tree", lib_dir = "/<PATH TO MTA SERVER>/mods/deathmatch/clua/x64", bin_dir = "/<PATH TO MTA SERVER>/mods/deathmatch/lua/bin", lua_dir = "/<PATH TO MTA SERVER>/mods/deathmatch/lua/server", } } Windows x86: Spoiler 1. Install ml_package module from github. 2. Download LuaRocks and additional libs from GDrive 3. Unpack files. 4. Run setup.bat 5. Create configs: %APPDATA%/luarocks/default-lua-version.lua with content: return "5.1" %APPDATA%/luarocks/config-5.1.lua with content: arch = "win32" lua_version = "5.1" rocks_trees = { { name = "user", root = "C:/Users/<USER NAME>/AppData/Roaming/luarocks", -- Write your MTA Server folder path here lib_dir = "C:\\Program Files (x86)\\MTA San Andreas 1.5\\server\\mods\\deathmatch\\clua\\x86", bin_dir = "C:\\Program Files (x86)\\MTA San Andreas 1.5\\server\\mods\\deathmatch\\bin", lua_dir = "C:\\Program Files (x86)\\MTA San Andreas 1.5\\server\\mods\\deathmatch\\lua\\server", } } 6. Install MinGW 7. Install mingw32-base-bin and mingw32-gcc-g++-bin packages in MinGW 8. Add MinGW/bin directory to your PATH env variable Usage example: Installing packages is done by typing commands such as: Linux: luarocks install lua-cjson Windows: luarocks.exe install lua-cjson Now you are ready to load this package from MTA. Do this in your Lua script file: -- You should run this function once in your resource initLuaPackage() -- Load library local json = require "cjson" -- Use it print( json.encode({ key = "example" }) ) It's done. Tell me in PM, if you have any remarks and additional information for this tutorial. Thx Edited November 23, 2022 by TheNormalnij Added missing windows steps 5 1 1 Link to comment
Recommended Posts