Jump to content

The_GTA

Helpers
  • Posts

    822
  • Joined

  • Last visited

  • Days Won

    86

Everything posted by The_GTA

  1. The_GTA

    Error

    Dear murilo2929, 1) either "fix" the code by using the following function: function formatNumber(amount, spacer) if not spacer then spacer = "," end if not amount then amount = 0 end amount = math.floor(amount) local left, num, right = string.match(tostring(amount), "^([^%d]*%d)(%d*)(.-)$") return left .. (num:reverse():gsub("(%d%d%d)", "%1" .. spacer):reverse()) .. right end 2) or post your entire code as attachment so we can search for the formatNumber error. - Martin
  2. Dear Hazardinho, please read the top Notes of this MTA wiki article: https://wiki.multitheftauto.com/wiki/ExecuteCommandHandler So there are some limitations on implementing your own chat window. But I hope that provided with MTA's function set you will be able to achieve your dream project!
  3. Dear xMoDy, do you know what the scripting language called "Lua" is? We use it in MTA to create server mods. You don't seem to have posted any scripting progress so I am curious. We could help you get started with Lua! Yours, - Martin
  4. The_GTA

    Error

    I don't want to be the guy to spot the obvious, but: in Lua, loopTable is a different variable than looptable because variable names are case-sensitive. Could you make sure you spelled "looptable" correctly in your code? --- About the second error, I cannot decipher the cause because you are not showing the code that called the function "formatNumber".
  5. Let me throw in an idea. To avoid any kind of flickering (rapid presses of the fire button, players shooting single shots, etc) you should implement a "heated area" timer. If there was shooting at for example Groove street, then your script should remember that for 5 seconds and update the timer when new shooting happens. This way your alert GUI will stay visible. Good luck with your idea!
  6. How about looking into the game's info.zon file? You find the entries... zone (...) BONE, 0, -480.539, 596.349, -242.99, 869.461, 2993.87, 900.0, 1, BONE ROBAD, 0, -2997.47, 1659.68, -242.99, -480.539, 2993.87, 900.0, 1, ROBAD (...) end zonename, interior, start_x, start_y, start_z, end_x, end_y, end_z, levelNumber, gxtName You can use colshape createColRectangle ( float fX, float fY, float fWidth, float fHeight ) and then use addEventHandler with "onClientElementColShapeHit" and "onClientElementColShapeLeave" to detect player position, playSound if inside colshape, then stopSound if leaving colshape. Hopefully this helps!
  7. Hello gubi, I have tried your resource, but it always complains that it has no access to "fetchRemote". Changing line 32 to if not hasObjectPermissionTo(getThisResource(), "fetchRemote", true) then has fixed the issue. Now I see naughty work of art on Grove Street I think this is a good use of the new xmlLoadString function call. But you could still add more features to this script, to make it better.
  8. Hello Haxardous! Thank you for complimenting me. I spent a lot of work into it and just want people to have a good starting foundation. Later the performance of the implementation will be improved by choosing better data structures as well as faster algorithms (already have plans). As a side note, I was heavily inspired by Direct3D 9's frustum definition when setting out my math formulas. So if you read their documentation you will find many parallels. Pretty sure this definition is industry standard.
  9. Thanks! <3 I like hearing about your appreciation. About the possibility of a Doom port, this could take a lot of work ;) But not impossible because Doom is a retro game.
  10. Dear MTA community, I have been spending my last 8 weeks on mathematical problems. One of them is the 3D Frustum-Plane intersection that is used by GPUs to draw triangles onto your screen. If you want to learn more about this please consider reading this thread. Promotional Video: https://www.youtube.com/watch?v=RQy3Q4Xe110 Prerequisites This tutorial is aimed at people who are capable of scientific thinking and are willing to playfully learn with Lua code. To execute steps in this tutorial minimal knowledge of Linear Algebra and Lua is required. Required MTA Resource: https://github.com/quiret/mta_lua_3d_math Description of the math Imagine that we have got a frustum and a plane in a 3D room described by coordinates plus their boundaries. By intersecting both you obtain all coordinates on a screen along with their depth values. Now think about how your vision works. You see distant objects smaller than closer ones. You rotate your eyes to angles of vision. If we were to put this concept into terms of math we could say: the plane of vision is bigger in the distance than in close proximity. The frustum is a seamless row of vision planes starting from the pyramid tip to the bottom. How to use the MTA Resource Just download the GitHub repository into a folder of your MTA Resources, name it "math_3d_nonlin" and start it. You can execute the following commands for quick testing: send_bbuf: draws a simple depth test draw_model: draws the DFF file "gfriend.dff" Now we have got the basics out of the way. Time to start coding. Please create a new "_math_test.Lua" script file in the resource and include it server-side at the bottom of meta.xml. Tutorial: software rendering a plane on screen Open your _math_test.Lua and include the following code: local viewFrustum = createViewFrustum( createVector(0, 0, 0), -- position createVector(10, 0, 0), -- right createVector(0, 0, 10), -- up createVector(0, 20, 0) -- front ); local plane = createPlane( createVector(-3, 10, -3), createVector(6, 0, 0), createVector(0, 0, 6) ); local function task_draw_scene(thread) local bbuf = create_backbuffer(640, 480, 255, 255, 0, 50); local dbuf = createDepthBuffer(640, 480, 1); local time_start = getTickCount(); do local gotToDraw, numDrawn, numSkipped = draw_plane_on_bbuf(viewFrustum, bbuf, dbuf, plane, true); if ( gotToDraw ) then outputDebugString( "drawn " .. numDrawn .. " pixels (skipped " .. numSkipped .. ")" ); end end local time_end = getTickCount(); local ms_diff = ( time_end - time_start ); outputDebugString( "render time: " .. ms_diff .. "ms" ); taskUpdate( 1, "creating backbuffer color composition string" ); local bbuf_width_ushort = num_to_ushort_bytes( bbuf.width ); local bbuf_height_ushort = num_to_ushort_bytes( bbuf.height ); local pixels_str = table.concat(bbuf.items); local bbuf_string = pixels_str .. ( bbuf_width_ushort .. bbuf_height_ushort ); taskUpdate( false, "sending backbuffer to clients (render time: " .. ms_diff .. "ms)" ); local players = getElementsByType("player"); for m,n in ipairs(players) do triggerClientEvent(n, "onServerTransmitImage", root, bbuf_string); end outputDebugString("sent backbuffer to clients"); end addCommandHandler( "testdraw", function(player) spawnTask(task_draw_scene); end ); Result: Try executing the "testdraw" command. At the top of file you see the definition of our frustum cone as well as a plane. By calling the function "draw_plane_on_bbuf" we put color information into bbuf for exactly the pixels that make up the rectangle. If you change the plane definition to... local plane = createPlane( createVector(-2, 10, -4), createVector(6, 0, 3), createVector(-2, 0, 6) ); you instead get this image: Try changing around the coordinates of frustum and plane to obtain different pictures! Tutorial: software rendering a triangle on screen Take the same code as in the tutorial above but change line 19 to: local gotToDraw, numDrawn, numSkipped = draw_plane_on_bbuf(viewFrustum, bbuf, dbuf, plane, true, "tri"); This way we have changed the primitive type to triangle (rectangle is the default). Try executing the "testdraw" command again to inspect the new result! Tutorial: drawing a DFF file onto screen Instead of writing triangle definitions by hand we can take them from a DFF file instead. DFF files are storage of triangle and vertex information along with 3D rotation and translation information. By extacting the triangles from the DFF file we can put them into our algorithm to software-render them! Here is a related excerpt from math_server.Lua: local modelToDraw = false; do local modelFile = fileOpen("gfriend.dff"); if (modelFile) then modelToDraw = rwReadClump(modelFile); fileClose(modelFile); end end local function task_draw_model(thread) local bbuf = create_backbuffer(640, 480, 255, 255, 0, 50); local dbuf = createDepthBuffer(640, 480, 1); local time_start = getTickCount(); local num_triangles_drawn = 0; if (modelToDraw) then -- Setup the camera. local geom = modelToDraw.geomlist[1]; local mt = geom.morphTargets[1]; local centerSphere = mt.sphere; local camPos = viewFrustum.getPos(); camPos.setX(centerSphere.x); camPos.setY(centerSphere.y - 3.8); camPos.setZ(centerSphere.z); local camFront = viewFrustum.getFront(); camFront.setX(0); camFront.setY(5 + centerSphere.r * 2); camFront.setZ(0); local camRight = viewFrustum.getRight(); camRight.setX(centerSphere.r * 2); camRight.setY(0); camRight.getZ(0); local camUp = viewFrustum.getUp(); camUp.setX(0); camUp.setY(0); camUp.setZ(centerSphere.r * 2); local triPlane = createPlane( createVector(0, 0, 0), createVector(0, 0, 0), createVector(0, 0, 0) ); local vertices = modelToDraw.geomlist[1].morphTargets[1].vertices; local triangles = modelToDraw.geomlist[1].triangles; local tpos = triPlane.getPos(); local tu = triPlane.getU(); local tv = triPlane.getV(); for m,n in ipairs(triangles) do taskUpdate( m / #triangles, "drawing triangle #" .. m ); local vert1 = vertices[n.vertex1 + 1]; local vert2 = vertices[n.vertex2 + 1]; local vert3 = vertices[n.vertex3 + 1]; tpos.setX(vert1.x); tpos.setY(vert1.y); tpos.setZ(vert1.z); tu.setX(vert2.x - vert1.x); tu.setY(vert2.y - vert1.y); tu.setZ(vert2.z - vert1.z); tv.setX(vert3.x - vert1.x); tv.setY(vert3.y - vert1.y); tv.setZ(vert3.z - vert1.z); local gotToDraw, numDrawn, numSkipped = draw_plane_on_bbuf(viewFrustum, bbuf, dbuf, triPlane, false, "tri"); if (gotToDraw) and (numDrawn >= 1) then num_triangles_drawn = num_triangles_drawn + 1; end end end local time_end = getTickCount(); local ms_diff = ( time_end - time_start ); (...) end The code first loads a DFF file called "gfriend.dff" and stores it inside the "modelToDraw" variable. Once you execute the "draw_model" command the code looks up the first geometry in the DFF file and fetches all triangles associated with it. The rendering camera is set up to point at the middle of the model. Then all triangles are drawn one-by-one. https://twitter.com/rplgn/status/1230650912345067520 Try swapping the DFF file for another one, like biker.dff, and examine the results! Maybe extract a different DFF file from GTA:SA and replace gfriend.dff with that one. External references: math calculation on paper example: https://imgur.com/gallery/rLvln3X German thread on mta-sa.org: https://www.mta-sa.org/thread/38693-3d-frustum-ebene-schneidung-in-Lua/ Do you have any questions related to the math or the implementation? Do not shy away from asking! I want to provide you with as much insight as I can.
  11. Linux support! Recent changes to Scene2Res and dependencies have added Linux compilation support. Thus I want to share it with you guys. Linux only download: OSDN.net Windows only download: OSDN.net Some people have noticed me that they could not download from OSDN.net, thus here is a mirror: How to compile on Linux First execute the following commands in your terminal: sudo apt-get install g++-7 sudo apt-get install codeblocks sudo apt-get install subversion cd ~ subversion checkout https://svn.osdn.net/svnroot/scene2res/ scene2res Then go here to setup your Code::Blocks for compilation. Now continue with the commands... codeblocks --build --target=Release build/scene2res.workspace mv obin/linux/Release/scene2res bin/scene2res cd bin Now you should have a terminal with Scene2Res set-up in the common run location (contents of a downloaded zip archive). Have fun! You can execute scene2res using... ./scene2res Of course, you can simply use the Code::Blocks GUI interface to build Scene2Res. But that ain't the fun, rite? What is new? Nothing really noteworthy. The whole implementation of my modules has received a huge facelift over time. Yours, - Martin
  12. Did you know that GTA San Andreas is based on the RenderWare engine? It is a product of Criterion which, in the past, was used by great game developers. Due to my heartfelt affliation to MTA I want to say: The source code is available. But I must not tell where. Hot stuff. Gosh, why could it not be that way three years ago?
  13. PSA: Turns out GTA3 DFF files are not supported by SA. Try this fix if you use DFF files from other platform or different game. You need to transform them to SA DFFs, which is easy. * makesadff.bat: https://pastebin.com/2m6brtap * dffconv.exe: http://gtaforums.com/topic/752450-rel-renderware-file-converter/ When you converted map you get this "output" folder. Put dffconv.exe and makesadff.bat into there. Then run "makesadff.bat". It should create a new folder "models_sa" with GTA:SA compatible DFF files. Delete "models" folder and rename "models_sa" to "models". Last time I said original GTA3 map is completely supported. So turns out I forgot this. But now it should work, sort of. Better idea is to start out with GTA United 1.2 GTA3 map because it is converted to SA already. This fix works for any map tho, I think The Hero added support for PS2 files aswell. If you have further problems with DFF files please post in his GTAForums thread! - Martin
  14. Thank you for thóse kind words! I indeed see little use for MTA:BLUE because it just works. But I want to do a special installer for other projects, for example (as you mentioned) .ASI projects and alternative MTA solutions. Long term goals.
  15. Correct! Hope you enjoyed the show, Simple01. I really should switch the wallpaper, huh ^^ After all it is my default account I record on.
  16. Here is a quick new video. A brand new way to load MTA. World premiere, using pefrmdllembed, the DLL to EXE injector. Not like it amounts to anything playable. You might enjoy this if you are a technological mind like me.
  17. Please take a moment and salute the passing CodePlex SCM host. It will die by the end of 2017. I remember the days when I used to check out the MTA:BLUE codebase from google code using TortoiseSVN. Good old days. Soon, no one will be able to use SVN for free anymore.
  18. Glad I can still use my mipmapped textures on MTA. This counts as modification of gta3.img. But I do not think it is a good idea to punish modders by default.
  19. Scene2Res has been updated greatly, thanks to renewed interest by people in custom maps in MTA (Matias_Montana, Cody, HeySlickThatsMe just to name a few). New things: added automatic TXD optimization for smaller and clearer map textures (thanks to my work on Magic.TXD) added support for original GTA3 and GTAVC maps fixed many rotation issues (hopefully all) fixed unicode path issues added Windows XP compatible executable added enableFiltering and ignoreFlagsSecure INI options added ability to automatically process COL archives (has been there for a while but not announced) open source using SVN and CodePlex many under-the-hood improvements Happy modding! <3
  20. Please understand that it is a reasonable decision to use only one CPU core. MTA uses technologies such as Lua which do come with a threading model and those make it next-to-impossible for an architecture redesign. MTA performance depends on GTA:SA performance. If you are looking for GTA:SA performance improvements you could try adding mipmaps to your textures (safe) or reducing the complexity of DFF files (could lock you out of public servers).
  21. Good job! I see your dedication and creativity. Impressive modification thread. And the fact that it is entirely multiplayer is great.
  22. Nice debug console. You seem to be a reputable person too. Could look into adding debug pipeline support to resedit this weekend, if I find the time, as well as fixing it up for latest MTA.
  23. The_GTA

    Green Candy

    I had the crazy idea once to write a Lua resource which would parse HTML content and display it in DX drawings. That idea is still floating around my head, you see CEGUI surely seems old; that is why I made dxElements which is an OOP GUI programming environment in Lua. An example of it's usage is resedit. What if said dxElements can parse configuration files for GUI, like XML? It could be neatly combined with Lua scripts for actual functionality. HTML seems powerful though and is known by lots of people. We will see whether it will fit into the 2.0 concept. For now, cool GUI is possible with Lua, too. Good example is the one from the FFS server: straightforward. About the pdf: it looks like an advertisement for web programming (cons for C++, blurry IE, suggestive presentation of IMVU); I cannot make my mind up about it
  24. The_GTA

    Green Candy

    Yes, currently the RpLight only supports dynamic vertex lighting as you know it. More advanced lighting routines may come if demand is high enough.
  25. The_GTA

    Green Candy

    I put a lot of effort into MTA:Eir. Most of these ideas are mapped out in my brain and are constantly developing. Those charts are the result of said long-term development process.
×
×
  • Create New...