Search the Community
Showing results for tags 'lib'.
-
Hi I want to create an easy utility / library resource where I would store functions that is used often but not provided in MTA by default. This resource, called Lib looks like this: Lib/ G_Libs.lua meta.xml libs/ C_dx.lua C_gui.lua C_screen.lua G_element.lua G_math.lua G_table.lua ... the meta.xml for the Lib resource: <meta> <info author="driphunnid" type="utility" name="Libs" /> <download_priority_group>3</download_priority_group> <min_mta_version client="1.6.0" server="1.6.0" /> <!-- <include resource="" /> --> <!-- a config must be an xml file, types: client or server --> <!-- <config src=".xml" type="client" /> <config src=".xml" type="server" /> --> <oop>true</oop> <!-- <settings> <setting name="" value="" /> </settings> --> <!-- <aclrequest> <right name="function.startResource" access="true" /> <right name="function.stopResource" access="true" /> </aclrequest> --> <!-- Shared --> <script src="libs/G_number.lua" type="shared" /> <script src="libs/G_string.lua" type="shared" /> <script src="libs/G_table.lua" type="shared" /> <script src="libs/G_color.lua" type="shared" /> <script src="libs/G_math.lua" type="shared" /> <script src="libs/G_vector.lua" type="shared" /> <script src="libs/G_matrix.lua" type="shared" /> <script src="libs/G_position.lua" type="shared" /> <script src="libs/G_rotation.lua" type="shared" /> <script src="libs/G_material.lua" type="shared" /> <script src="libs/G_bone.lua" type="shared" /> <script src="libs/G_weapon.lua" type="shared" /> <script src="libs/G_world.lua" type="shared" /> <script src="libs/G_element.lua" type="shared" /> <script src="libs/G_vehicle.lua" type="shared" /> <script src="libs/G_cfg.lua" type="shared" /> <!-- Client --> <script src="libs/C_screen.lua" type="client" /> <script src="libs/C_gui.lua" type="client" /> <script src="libs/C_dx.lua" type="client" /> <script src="libs/C_ped.lua" type="client" /> <script src="libs/C_vehicle.lua" type="client" /> <script src="G_Libs.lua" type="shared" /> <export function="load" type="shared" /> </meta> and the G_Libs.lua contains this simple fileReading logic - we return the content of a read file: LIBS_FOLDER = "libs" function load(name, side) -- side = prefix - client, server or shared / global - C, S, G assert(type(name) == "string", "Bad argument @'load' [Expected string at argument 1, got "..type(name).."]") side = type(side) == "string" and side or "G" local libPath = string.format("%s/%s_%s.lua", LIBS_FOLDER, side, name) assert(fileExists(libPath), "Library not found: " .. libPath .. " - you might need to specify a /different/ side (C, S, G).") local file = fileOpen(libPath) local content = fileRead(file, fileGetSize(file)) fileClose(file) return content end For example, content of libs/G_element.lua and C_screen.lua: C_screen.lua: SCREEN_SIZE = Vector2(guiGetScreenSize()) MEDIAN_SCREEN_SIZE = Vector2(1440, 900) function ssX(x) return x / MEDIAN_SCREEN_SIZE.x * SCREEN_SIZE.x end function ssY(y) return y / MEDIAN_SCREEN_SIZE.y * SCREEN_SIZE.y end function isCursorInPosition(x, y, width, height) if (not isCursorShowing()) then return false end local cx, cy = getCursorPosition() local cx, cy = (cx * SCREEN_SIZE.x), (cy * SCREEN_SIZE.y) return ((cx >= x and cx <= x + width) and (cy >= y and cy <= y + height)) end function isCursorInCircle(x, y, r) if (not isCursorShowing()) then return false end local cx, cy = getCursorPosition() local cx, cy = cx*SCREEN_SIZE.x, cy*SCREEN_SIZE.y return (x-cx)^2+(y-cy)^2 <= r^2 end G_element.lua: function isPlayer(element) if not isElement(element) then return false end if not (getElementType(element) == "player") then return false end return true end function isPed(element) if not isElement(element) then return false end if not (getElementType(element) == "ped") then return false end return true end function isCharacter(element) if not isElement(element) then return false end if not (isPed(element) or isPlayer(element)) then return false end if not (element.model == 0) then return false end return true end function isVehicle(element) if not isElement(element) then return false end if not (getElementType(element) == "vehicle") then return false end return true end function isObject(element) if not isElement(element) then return false end if not (getElementType(element) == "object") then return false end return true end function isBuilding(element) if not isElement(element) then return false end if not (getElementType(element) == "building") then return false end return true end When I use loadstring with this concept, it works as far as I use loadstring inside a client side script, other than that, when I try to load a lib using loadstring in a server or global / shared script, I get an Access denied error for "loadstring" and "call". Example - other test resource: C_test.lua (script type in xml is "client") loadstring(exports.Lib:load("element"))() -- loads the G_element.lua file contents from Lib/libs as expected loadstring(exports.Lib:load("screen", "C"))() -- loads the C_screen.lua file contents from Lib/libs as expected however if I change the script type from client to server or shared, I get an error from the test.lua: G_test.lua / S_test.lua (script type in xml is "shared" / "server") loadstring(exports.Lib:load("element"))() -- yields an error on resource start saying Access denied for loadstring and call I tried this setting in the test resource xml file and allowing the request via console for the resource, but same issue, still access denied: <aclrequest> <right name="function.loadstring" access="true" /> <right name="function.call" access="true" /> </aclrequest> Are there any workarounds or fixes for this issue? I really would like to use this concept, I've been coming into so many restriction errors lately, I feel like I can't fully do what I want and have potential for. Why does loadstring not work on shared and server side scripts, or what am I missing? This concept would make editing and using utility functions so much easier, nicer and simpler for me, I don't want to let go of this. Also I am planning to create a framework, a boilerplate "gamemode" engine, where you have so much utility functions and systems to use, that you'll only have to worry about the final gamemode concept you will be creating, this essentially will be a free open source multiplayer gta game engine, and this Lib resource would be a huge part of it. How can I make this work? Thank you for your time!
-
Hello! I have a local network home server (192.168.0.4) for storage and other service server running. On this server I run Ubuntu server with CasaOS. I recently made two custom flask apps, one for a XAMPP manager and one for an MTA Server Manager so I can easily have a web UI on two different ports. I setup everything successfully, I could run and join to an FTP server from my main desktop PC (192.168.0.122) or laptop, manage MTA servers correctly, start and stop them, join them, open and run phpMyAdmin. But when I got to the part to run the MTA server on the server PC, and setup the MySQL database connection I run into an issue regarding linux. [02:25:51] Starting Database [02:25:51] ERROR: Could not load /home/hmsvr/ftp/servers/LegendaryLegacy/SA/x64/dbconmy.so - /lib/x86_64-linux-gnu/libssl.so.1.1: version `OPENSSL_1_1_1' not found (required by /home/hmsvr/ftp/servers/LegendaryLegacy/SA/x64/dbconmy.so) [02:2 5:51] WARNING: [Engine]/[Main]/Database/S_Database.lua:17: Bad usage @ 'dbConnect' [Could not connect] [02:25:51] ERROR: [Engine]/[Main]/Database/S_Database.lua:27: Database connection failed; When I start the server on my desktop PC, but still use the server PC to run the Apache, MySQL and FTP, I can successfully connect to the MySQL server running on my server PC. G_Database.lua & S_Database.lua sections for context DATABASE_DETAILS = { ["host"] = "192.168.0.4", -- "127.0.0.1" or "localhost" if the mysql server - XAMPP - runs on your PC, or "your server ip" if you have a separate PC or VPS ["port"] = 3306, -- Provided in XAMPP control panel or my.ini / my.cnf ["username"] = "mysql", -- Provided in phpMyAdmin or my.ini / my.cnf ["password"] = "", -- Provided in phpMyAdmin or my.ini / my.cnf - none by default ["database"] = "mta-ll", -- Rename if you are using different database or create one with this name } ---------------------- DATABASE = { CONNECTION = nil, RECONNECT_TIMER = nil } function connectDatabase() DATABASE.CONNECTION = dbConnect("mysql", "dbname="..DATABASE_DETAILS["database"]..";host="..DATABASE_DETAILS["host"]..";port="..DATABASE_DETAILS["port"], DATABASE_DETAILS["username"], DATABASE_DETAILS["password"], "log=1") if DATABASE.CONNECTION then print("Database connection successful") if isTimer(DATABASE.RECONNECT_TIMER) then killTimer(DATABASE.RECONNECT_TIMER) end DATABASE.RECONNECT_TIMER = nil --prepareDatabase() return true else error("Database connection failed; retrying in 5 seconds") DATABASE.RECONNECT_TIMER = setTimer(function() connectDatabase() end, 5000, 1) return false end end function disconnectDatabase() if not DATABASE.CONNECTION then return false end DATABASE.CONNECTION = nil print("Database connection closed") if isTimer(DATABASE.RECONNECT_TIMER) then killTimer(DATABASE.RECONNECT_TIMER) end DATABASE.RECONNECT_TIMER = nil return true end addEventHandler("onResourceStart", resourceRoot, function() connectDatabase() return true end) addEventHandler("onResourceStop", resourceRoot, function() disconnectDatabase() return true end) I already had OpenSSL installed when I checked the version, but also my version is 3.0 something. I was looking on many forums on how to get OpenSSL 1.1.1 as the error message requires but I didn't find any easy solutions apart from building from source and many complicated commands which I am not sure how to revert if it doesn't solve the issue. I downloaded some .deb file from ubuntu archive and istalled it via a forum post but I don't remember which one was it, because at first I got an error message saying that the libssl.so1.1 directory didn't exist or something similar, that's why I then tried to install that but then realised I have a newer OpenSSL version. I didn't even know I will have to f*ck around with OpenSSL for the sake of MTA SA MySQL database handling, nor I had to do this previously - well previously I didn't use MTA Linux Server on linux either. Does anybody have any suggestions how could I possibly solve this issue so I am able to run the linux version of MTA server on my home network Ubuntu linux server alongside the XAMPP / LAMPP Apache MySQL and FTP servers? I followed the tutorial on the MTA SA Linux Server Tutorial page. This is currently the only thing keeping me away from finishing what I've been wanting to do for a long time for a home network MTA development environment to be able to store and access and edit the server files on a separate server PC from various other devices. I am planning on releasing the flask apps for the XAMPP and MTA server managers later on in case anybody needs something similar, or also it could be used as good templates if you want to create docker images from it or so on, however the code may not be production ready but will be free to use and adjust. Thank you for your time response and help in advance!
-
It's about cambering the cars, but when I use the script and turn on ENBseries, the tires disappear due to a reflection that appears in the script for the tires. I want to remove that reflection from the resource. A video to watch : https://drive.google.com/file/d/1LmfHwTCUimI2Zb9B4CGD9KovExWfb4Cs/view?usp=sharing The resource: https://drive.google.com/file/d/1oUXeCGbVBb8uJbmUoesovndYl3rGumny/view?usp=sharing Help me please
-
[2018-01-12 14:55:12] ERROR: Could not load /home/gameservers/mta/turbo1/x64/./dbconmy.so - /home/gameservers/mta/turbo1/x64/./dbconmy.so: symbol __cxa_pure_virtual, version libmysqlclient_16 not defined in file libmysqlclient.so.16 with link time reference[2018-01-12 14:55:12] ERROR: san_mysql/server.lua:19: dbConnect failed; Could not connect [2018-01-12 14:55:12] INFO: [mysql]: Sikertelen MYSQL csatlakozás! please help me, how to fix this?