-
Posts
822 -
Joined
-
Last visited
-
Days Won
86
Everything posted by The_GTA
-
@BihanduOut of fun, I aim to write an AST to Lua reversing engine during my Lua 5.1 compiler development. Maybe I will host a new website with a web-based decompiler again? Stay tuned!
-
@Infinity#There are two flaws in your code: If two players observe vehicle damage, then both send the attacker into the vehicle, causing unnecessary network traffic that could lag the server. Since you can damage a vehicle with a shovel, this is an undesired effect. You should limit it to known weapon-ids only by checking the weapon parameter. Both can be fixed by adjusting the client.lua the following way: local function is_gun_id(id) if (type(id) == "number") and ((id >= 22 and id <= 34) or (id == 38)) then return true end return false end addEventHandler("onClientVehicleDamage", root, function(attacker, weapon, loss, x, y, z, tire) if (is_gun_id(weapon) and getElementType(source) == "vehicle" and getElementType(attacker) == "player" and attacker == localPlayer) then triggerServerEvent("mtasa.warpPed", attacker, source) end end) If you want to make it somewhat more secure you would use the "client" event variable on the serverside.
-
If I understand you correctly then you want the shooting animation and behaviour to be possible WHILE the player is also in the animation of entering or leaving a vehicle. Since this is not possible in the regular game, I think you will need a custom MTA resource. Just saying: this is not going to be as simple as you might think.
-
Nice work! I am interested in the debug-ability of TypeScript code. Last time I used TypeScript in connection with JavaScript I saw that you could annotate function signatures with types or leave out the types. By leaving out the types you did revert back to regular Lua with all of its glory (and pain?). Anyway, since we are using Lua it is going to be the backend of your solution. What if we introduce errors into the script? In a traditional Lua resource we do receive warning and error messages into the scripting debug console (both server and client) with line numbers and a somewhat-helpful message. How do they look like in your solution? Is it a mess due to the transpilation? Or have you compiled to bytecode directly as well as written a custom debug-info generator to adjust for the TypeScript-based line numbers? Have you introduced any kind of new debug messages to help developers? I am asking this because what if somebody is using your solution and then comes asking inside of our forum Scripting section. We have to know how to support your TypeScript-based resources!
- 5 replies
-
- 1
-
- typescript
- resources
-
(and 2 more)
Tagged with:
-
@DatPsychopath Glad that you have responded! It looks like the issue does indeed stem from your MySQL table init query. Take a look at the following line: `updatedate` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', The timestamp value of 0000-00-00 00:00:00 is outside of the range from '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC. Change the line to `updatedate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, because it does make sense that the SQL table entry was updated at the same time as it was created. If you have some weird code that checks if the database was never updated then you might have to adjust it too (I doubt it). I hope that you have no problem reinitializing that database. Maybe you might have to dump it beforehand if you already have data stored inside of it. Links for reference: * https://www.mysqltutorial.org/mysql-timestamp.aspx * https://dev.mysql.com/doc/refman/8.0/en/datetime.html Good luck with your scripting project! ?
-
Verify that your script is assigned to run server-side by looking into your meta.xml file. <script src="script.lua" type="server" /> This is important because you are using the serverside versions of functions.
-
To me CO-OP was the first idea I had when searching for GTA SA multiplayer back in 2008. But I think that we will have to advertise this feature to people that use DYOM or CLEO as content creators. Just imagine if Megadreams does all this work for nothing. If we get the passion of these people then it is more likely that their followers will reach us too. Like with any strong addition to our multiplayer engine we also need a good release strategy. This could be the thing that attracts people!
-
Hello Fierelier, nice work on your GTA map converter! I see that you are passionate about bringing GTA SA content directly into multiplayer. I think this is a great idea that brings both the SP and MP communities together. I hope that you will be able to solve all related issues to achieve your project goals. Did you know that I have created such a tool myself? It is called scene2res and can convert IPL/IDE files while also doing conversion of the TXD files into GTA SA engine format. Kind of a swiss knife if you wish. Even so, I like to see alternatives like yours! Maybe you will solve some problems that I was unable to solve, like adjusting the water regions to the target map. Please be mindful about the importance of intellectual property in GTA modding. Maps from inside of GTA games have been created by Rockstar Games and it is NOT okay to offer these files for download anymore because there exist "legal" GTA engine alternatives that can play them. This way the original content creators would not get paid. Don't worry: you as tool creator are not the core of the problem and I do not expect you to come forward to the content creators by implementing your own DRM system. But I want you to be aware, just in case!
-
An important topic for every to-the-metal developer is memory management. While we like to keep things simple, for example by limiting our data models to trees, we have to admit that in the general case, in all of reality software is a complex graph of data nodes which is held together by so-called "pointers". In the professional business world people like to create complicated proofs on when to release memory nodes in the correct time and place to both gain saving on the memory footprint and on the performance. But can we skip all these custom proofs and get a grip on this issue? Welcome to the world of garbage collection! The science behind it is simple. We define a graph as a set of nodes (the circles with the letters) and for each node there is a set of edges (the arrows pointing away from each circle). We define a set of interesting nodes. A node is alive if there is a path from one of the interesting nodes to it. Otherwise the node is black, or we could also say dead. Since programs are mutable in nature the program graph does always change. New nodes are being created that replace older with better ones, convert nodes to more specialized representations and put the older things to rest. Now, if the incoming connections to a node change and the graph has reached the desired state, we could check if the node does not connect to the set of interesting nodes anymore and in that case delete it. There are multiple approaches possible: 1) Perform a complete path scan for every node once the incoming connections of it have changed. The drawback of this method are the performance hits if the graph is growing to unexpected odds. On the other hand, this approach is the most memory saving because you do not have to remember anything once the query is done. 2) Utilize a data-structure which remembers the reachability of the memory nodes from each other, so that reachability can dynamically expand based on new node components that connect to already reachable ones. This is perfect for performance because the path proofs do not have to be computed to the set of interesting nodes but can be short-cut to reachable nodes which are a much bigger set. Drawback is that you have to deal with the additional memory bookkeeping for each node. 3) Limit your program model to simple things like trees where each node has only one input connection so that entire subtrees can be deleted when a node is deleted. For the Lua machine code compiler I am going to need garbage collection during the lexing, the program model conversion and the Lua runtime. The problems have already been solved using C++ code. I am looking forward to further implementing it!
-
Dear yasinkenzo, it looks like the accounts-system resource has not been initialized properly. If you have any manuals about the resource then please look for the steps required to initialize the SQL database. On the other hand, it could be an issue with the resource itself. Have you tried contacting the resource creator for support? If you cannot contact the guy, then maybe we could help you. In order to sufficiently help you with resource scripting related issues, we need more details from you. A quick look into the MTA community resources page has not revealed the resource that you possess. You need to post the resource code if you want me to help you.
-
Hello DatPsychopath, how was your MySQL database created? I am interested in the table creation commands. It might shed light on the cause of this issue.
-
I would say the last two posts show detection of the MTA client as "YouTube app". If the user agent string does play a role in it, then this could be seen as MTA issue.
-
This issue is really strange. I doubt that the client script is starting faster than the serverside script. Could you send me the complete resource so that I could take a look?
-
1) Is there any error inside the server or client debug console when starting your resource? 2) What is the content of your meta.xml file for the triggerServerEvent version? NOTE: shared does not mean synchronized, but that the export rule is applied to both clientside and serverside or the script is available on both ends.
-
I wonder, too! From what we know by inspection of his YouTube channel, Sphene has been in development for at least 8 months (https://www.youtube.com/watch?v=kbgKXM4QN9c). I would be interested in what the challenges of implementing this interpreter are and how Megadreams wants to overcome them.
-
That is fine, on the pretext that every triangle that is clickable has first been displayed on the screen. There could be a one-frame delay in clicking your rectangles. The optimal approach is sharing the variables or sharing the code, as mentioned. setElementData is a very useful function for attaching data to MTA elements. I can recommend you this function if you want to synchronize data across resources or even across the network to clients or the server.
-
You either recalculate the positions of the rectangles inside the onClick function or you remember their positions inside of objects like Lua tables. If you have control over the contents of "renderCache" then you can create rectangle information structures inside of them. Here is an idea (conceptual code): local clickable_rectangles = {} local clickable_rect_by_elem = {} local font = "clear" local function createClickableRectangle(element) local rect = {} local size = -- TODO function rect.getPosition() local x = -- TODO local y = -- TODO return x, y end function rect.getSize() local w, h = -- TODO return w, h end table.insert(clickable_rectangles, rect) clickable_rect_by_elem[element] = rect return rect end ... function Panel() local cameraX, cameraY, cameraZ = getCameraMatrix(); for element, value in pairs(renderCache) do local distance = value["distance"] if distance <= maxDistance then local boneX, boneY, boneZ = getElementPosition(element); local size = 1 - (distance / maxDistance); local screenX, screenY = getScreenFromWorldPosition(boneX, boneY, boneZ + (1.1)); if screenX and screenY then local alpha = interpolateBetween(0,0,0,255, 0, 0, size, "Linear") local text = "Text" local length = dxGetTextWidth(text, size, font) + 15 * size local rect = clickable_rect_by_elem[ element ] -- TODO: is there always a rectangle? local x, y = rect.getPosition() local w, h = rect.getSize() dxDrawRectangleBox(x, y, w, h, tocolor(20,20,20,alpha * 0.7)); --- I want to put these positions inside the isMouseInPosition function dxDrawText(text, screenX, screenY, screenX, screenY, tocolor(255,255,255,alpha), size, font, "center", "center"); end end end end function isMouseInPosition ( x, y, width, height ) if ( not isCursorShowing( ) ) then return false end local sx, sy = guiGetScreenSize ( ) local cx, cy = getCursorPosition ( ) local cx, cy = ( cx * sx ), ( cy * sy ) if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then return true else return false end end function onClick(button, state) if (button == "left") and (state == "up") then for m,n in ipairs(clickable_rectangles) do local x, y = n.getPosition() local w, h = n.getSize() if isMouseInPosition(x, y, w, h) then --- I want to put the position here which is in the "Panel" function outputChatBox ("click") end end end end addEventHandler( "onClientClick", root, onClick ) By the way, did you mean "dxDrawRectangle" instead of "dxDrawRectangleBox" ?
-
I can surely help you with the coloring question. For that you should create a local copy of the code inside your MTA resource project and modify it in the following way: Insert this at the top: local colors_cicled = { tocolor( 80, 80, 80, 200 ), tocolor( 110, 110, 110, 200 ) }; Then go to line 317 and replace it with the following: dxDrawText ( cData[iIndex]["text"], x, y, cData.info.width + x, ( 30 % data.h ) + y, colors_cicled[ ( ( iIndex - 1 ) % #colors_cicled ) + 1 ], FIT_MODE and ( 1 * SCALE ) or 1, "default-bold", "center", "center", true, true, data.pg, false, true ); About your other demand: I refuse to do it for free, the code does resemble more of an artistic masterpiece than a scientifically authenticable work.
-
I am no user of DGS but you are not supposed to create UI elements or load the DGS environment variables every frame. I have no idea what you are trying to do, but try this? loadstring(exports.dgs:dgsImportFunction())() local gridlist = dgsCreateGridList(screenW * 0.2443, screenH * 0.2241, screenW * 0.1313, screenH * 0.2148,false) dgsGridListAddColumn(gridlist,"test1",0.4) dgsGridListAddColumn(gridlist,"test2",0.4) for i=1,20 do local row = dgsGridListAddRow(gridlist) dgsGridListSetItemText(gridlist,row,1,i) dgsGridListSetItemText(gridlist,row,2,i-1) end -- TODO: hide the gridlist if showdashboard == false -- TODO: show the gridlist if you set showdashboard to true function showDashBoard () if showdashboard == true then dxDrawRectangle(screenW * 0.2130, screenH * 0.1676, screenW * 0.5745, screenH * 0.6648, tocolor(47, 45, 47, 255), false) end end addEventHandler ( "onClientRender", root, showDashBoard ) DGS comes with it's own rendering code which runs every frame. You have to consult the manuals of the resource if you want to know about customization.
-
@spaghetti1337 You are listing some of the key ideas about the implementation of so called "scroll panes"! A scrollpane is a rectangle connected to a vertical and a horizontal scrollbar. The scrollpane has a content rectangle in which you can place other rectangles, in your example a text display. The content of a scrollpane forms it's own UI hierarchy which has a 2D bounding box that contains all scollpane-contained UI elements. Now imagine that you put another cut-out rectangle above the bounding box that forms the "view" of the elements on the contents of the scrollpane. Now about the mathematics: the contents of the scrollpane are based on a 2D coordinate system centered around the (0,0) point. Each contained UI element has a coordinate (x,y) and a size (w,h) inside the scrollpane content, forming a rectangle UI_rect. The combined region of all UI_rect is enclosed by the bounding box with position (cx,cy) and size (cw,ch). The scrollpane itself has a view rectangle with "position" 2D vector (vx,xy) and a "viewport size" 2D vector (vw,vh). The viewport position is linked to the progress of your scrollbars: vx = ( cx + hscroll_progress * max( 0, cw - vw ) ) vy = ( cy + vscroll_progress * max( 0, ch - vh ) ) where the progress of each scrollbar ranges from numeric values between 0 and 1, the maximum function returns the biggest of the passed values. If you cut the viewport rectangle with the content bounding box, you get the region of UI that should be displayed within your scrollpane viewport. The implementation is up to you. IMPLEMENTATION NOTE: there are certain limitations in MTA's ability regarding dxDrawText that force you to use so called "render targets" for cut-out rectangles. You basically have a rectangle that functions as your scrollpane viewport and perform the drawing inside of the render-target, which will cut-out any unwanted text that clips outside the width and height that you created the render-target with. This will be important for your idea.
-
Dear MTA community, you may not expect what I am about to show you. But your reaction is important to me so that I can categorize this new discovery. I am currently researching the TXD loading mechanics on request by the MTA team and I have found this peculiar use-case that I think is not a security hazard but a dubious feature. Don't get me wrong: this feature does NOT corrupt game memory, does not change game variables in a harmful way. Consider the following MTA clientside script: addEventHandler("onClientRender", root, function() local txd = engineLoadTXD("screendraw.txd"); assert(not (txd == false)); destroyElement(txd); end ); Did you know that this script can be used to replace the backbuffer of the GTA SA engine? The result is as follows: You can download the resource here: https://green-candy.osdn.jp/mta/screendraw.zip Load it onto your local MTA server, start it and execute the "rt sdhd" command. You need to have a clientside resolution of 1920x1200x32 for this resource to work. You can edit the texture using my Magic.TXD tool to change the content that it displays using the screendraw resource. What do you think about this feature? Do you think MTA should disallow TXD files that can draw onto the GTA SA/MTA screen by loading them?
-
Please come back at me if you have any questions during the process. I will be able to answer most of your questions.
-
If you have a problem with the big idea behind gridlist/scrollbar/dropdown then try playing around with the MTA dx functions until you get something done that converges against the idea of the UI elements that you have. I have yet to see any code from you. To give you a hint about the math, a layout engine is typically based around the following concept: each UI element is a box with position (x,y) and a size (w,h). Children can be placed inside each element with an offset (ox,oy) so their "screen"/absolute position would be (x+ox,y+oy). This system does form a tree of UI elements. Helpful ideas for UI element layouts: A gridlist is a 2D matrix of rows and columns with the top row typically used for details. The rows are consecutive on the y-axis, the columns consecutive on the x-axis. A scrollbar is a box with another box inside of it. It can be layed-out vertically or horizontally. By clicking the inner box you can move it either horizontally or vertically inside the outer box. A dropdown is a 1D array of rows which are layed out consecutively on the y-axis.
-
You either use a resource that already exists or create something yourself. If you want to create something yourself, then you need a layout engine, a UI layout and a concrete UI design. If you don't know where to start, then you should first get your Lua skills up-to-speed. Then research the topics plus the mathematics behind them. After the mathematics you can go to the UI layout and design which require just applications of the layout engine. And then after all the hard work you can get to fun stuff like the pictures you have posted above. The quality of the UI depends on the amount of care you put into the single components and their versatility.
-
Amazing work, Megadreams! I am excited for more of your content and have subscribed to your YouTube channel. How did you implement this? Is this a regular Lua resource? Or is this a special MTA client?