Search the Community
Showing results for tags 'global'.
-
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 friends, today I will share with you a very simple and under development hud. To get rid of FPS and screen pollution, it is enough to install and run the hud I made on your server. Download > Link
-
Olá, eu tenho uma dúvida sobre MTA. Eu vim do SA:MP para o MTA com a intenção de abrir um servidor, eu realmente não gosto de PAWN e fiquei maravilhado ao ver que Lua e C++ é usado no MTA, as possibilidades são infinitas, e sinceramente sinto que a plataforma é mais bem feita, porém surge uma dúvida em minha mente. É possível fazer alterações no que se refere ao chat do MTA? Eu aprendi Lua no Tibia onde para fazer essa alteração seria necessário fazer um cliente próprio com alterações nas sources, imagino que aqui não seja o mesmo, porém essa é minha dúvida. No SA:MP há servidores que ao você apertar T, toda sua mensagem será global, e há servidores que você aperta T e digita sua mensagem, apenas quem está nas próximidades poderá ler o que você tem a dizer, podendo ser extendida essa distância com comandos que simulam um grito, enviada apenas para um jogador na sua proximidade através de um comando de sussurro, você também pode falar baixo para encurtar ainda mais a distância da sua fala porém para que todos possam ouvir. Minha dúvida é se isso é possível aqui, eu realmente procurei bastante e não encontrei nada especifico ou mesmo um servidor com um sistema assim ou parecido, eu descobri o MTA a cerca de três horas, para alguns isso pode ser uma dúvida de um leigo e realmente é, porém eu apreciaria uma resposta de alguém mais experiente, o MTA permite que você faça alterações no chat?
-
Hi Sorry for my bad english:( Learn how to disable Global Chat on my server For example, players who are not in one place do not see other players' chats please Help me
-
Hello MTA staff from past months I was facing ddos attacks from one of my client server GTAV FREEROAM I was totally not able to figure out the attacker IPS to ban him ! Due to ddos attacks my vps bandwidth usage increase in short period ,in server face network trouble ,restart of vps automatic ! So after watching on YouTube I got a video were users shows how to ddos I see that guy ddos by using spam chats were whole server cause network trouble ,lags ,timeout problems the same repeated in my client server This is the video I seen Attacker details : ⎝⧹ nick : montassar - IP:197.26.89.206 serial:648D81DFAA7496D5DB46C25324D0B7F2 version:1.5.6-9.14334.0 montassar - IP:197.26.89.206 serial:648D81DFAA7496D5DB46C25324D0B7F2 version:1.5.6-9.14334.0 This guy usually spam 30 times with word &&&&&&&&& every 6 chats the users usually who join in server get network trouble and net also got diagnosed below are proofs I shut down my vps for 30 min so that attacks will leave my server I reopen server and when I check on console I got all proofs of attacker ! Pls ban him globally https://imgur.com/a/Xks3MsQ https://imgur.com/a/Xks3MsQ
-
local function ujteamsay(message, messageType) if messageType == 2 then cancelEvent() outputChatBox("(CSOPORT) "..getPlayerName(source)..": #FFffFF"..message, root, red, green, blue, true ) end end addEventHandler("onPlayerChat", root, ujteamsay) how to fix this? i want just team mates see the message.. *sorry for my very bad English :c*