Jump to content

Drawtag script video with MTA feature request


DiSaMe

Recommended Posts

There are two resources: drawtag and drawntag. Drawntag has TXD and a script which imports TXD and replaces a game texture with it. Drawtag has a client-side script for drawing. When you close drawing window, it sends image data to server. Server reads data, generates new TXD in drawntag and restarts that resource. So the texture changes. And drawtag also has a script which makes spray paint create tag object.

Link to comment

That's really a great thing!

The creating of the txd really impresses me, seems to be really cool to be able to generate those files.

Where did you learn this from? Now you made me curious :D

A clientside file management would be very useful indeed. I would love to be able to manipulate client files and load them without having to use meta.xml.

This would also be great to create a signature system. By this I mean that every player is able to sign his driver license or whatever you want to be signed and this signature could then be saved as an image file.

Link to comment

Nice stuff.. never actually bothered learning this stuff, although I'm quite experienced in modeling.

Sorry, if this may sound like a nooby question, but.. do the textures have a format like png? I just know that when creating a txd, it seems to become a bmp, but as I said, I never learned this ;)

I hope that the MTA team will actually react to this (besides favoring your video).

Link to comment

I don't know how PNG stores data. But uncompressed TXD textures store raster data in a similar way BMP files do. My script creates textures with DXT3 compression which stores data in 4x4 pixel blocks. Each block takes 16 bytes.

Link to comment

When you draw image client-side, you create green squares. Their coordinates are transferred to the server with triggerServerEvent when you close drawing window. Server uses them to store data in a matrix, 128x128 table. If a pixel is drawn over, its value in the raster is true, otherwise it's nil. Then it creates TXD file, and writes the beginning until it reaches position where raster data in the file starts. It cycles through the table, writes image data and final RW sections, then closes the file. Firstly I made it create BMP files because that format is very simple.

Link to comment
When you draw image client-side, you create green squares. Their coordinates are transferred to the server with triggerServerEvent when you close drawing window. Server uses them to store data in a matrix, 128x128 table. If a pixel is drawn over, its value in the raster is true, otherwise it's nil. Then it creates TXD file, and writes the beginning until it reaches position where raster data in the file starts. It cycles through the table, writes image data and final RW sections, then closes the file. Firstly I made it create BMP files because that format is very simple.

Hrm, thanks. But how do you write binary using fileWrite? It only takes strings AFAIK. Sorry if I'm slow, really sleepy.

Link to comment
string.char possibly

Thanks Lordy! It worked! :D I've created a blank TXD file with fileCreate and string.char... if that counts for something.

Edit: No, actually I did something wrong.

DoomedSpaceMarine, how did you do it, and what TXD specification/format did you use for your images?

fileWrite ( fileTXD, string.char ( 0x09 ) ) -- platform id: 9 for GTASA on the P.C
fileWrite ( fileTXD, string.char ( 0x04 ) ) -- filter flag : FILTER_MIP_LINEAR 0x04
fileWrite ( fileTXD, string.char ( 0x00 ) ) -- texture wrap WRAP_NONE 0x00
fileWrite ( fileTXD, string.char ( 0x00 ) ) -- texture wrap WRAP_NONE 0x00
fileWrite ( fileTXD, "TESTEXTURE", string.char ( 0x00 ) ) -- Diffuse Texture Name + Null Termination
fileWrite ( fileTXD, "TESTEXTUREALPHA", string.char ( 0x00 ) ) -- Alpha Texture Name + Null Termination
fileWrite ( fileTXD, string.char ( 0x20 ), string.char ( 0x00 ) ) -- Raster Format [b] ***[/b]
fileWrite ( fileTXD, string.char ( 0x01 ) ) -- Alpha/FOURCC
fileWrite ( fileTXD, string.char ( 0x80 ) ) -- image width
fileWrite ( fileTXD, string.char ( 0x80 ) ) -- image height
fileWrite ( fileTXD, string.char ( 0x08 ) ) -- image BPP
fileWrite ( fileTXD, string.char ( 0x02 ) ) -- mipmap count, testing 2 as value
fileWrite ( fileTXD, string.char ( 0x04 ) ) -- raster type - apparently always 0x04
fileWrite ( fileTXD, string.char ( 0x03 ) ) -- dxt compression type

*** - This is out of format. Since this part is 16-bit, and string.char only writes up to 8-bits max, it turns into 0x00, 0x20. A lot of these parts are DWORDS & WORDS anyways, so string.char won't do.

It's roughly how I did it, but I just put in some random values out of the ones supported.

Edit 2 (Right Datalenghts, STILL FAILURE):

fileWrite ( fileTXD, string.char ( 0x00 ), string.char ( 0x00 ), string.char ( 0x00 ), string.char ( 0x09 ) ) -- platform id: 9 for GTASA on the P.C
fileWrite ( fileTXD, string.char ( 0x00 ), string.char ( 0x04 ) ) -- filter flag : FILTER_MIP_LINEAR 0x04
fileWrite ( fileTXD, string.char ( 0x00 ) ) -- texture wrap WRAP_NONE 0x00
fileWrite ( fileTXD, string.char ( 0x00 ) ) -- texture wrap WRAP_NONE 0x00
fileWrite ( fileTXD, "TESTEXTURE", string.char ( 0x00 ) ) -- Diffuse Texture Name + Null Termination
fileWrite ( fileTXD, "TESTEXTUREALPHA", string.char ( 0x00 ) ) -- Alpha Texture Name + Null Termination
fileWrite ( fileTXD, string.char ( 0x00 ), string.char ( 0x20 ), string.char ( 0x00 ), string.char ( 0x00 ) ) -- Raster Format
fileWrite ( fileTXD, string.char ( 0x00 ), string.char ( 0x00 ), string.char ( 0x00 ), string.char ( 0x01 ) ) -- Alpha/FOURCC
fileWrite ( fileTXD, string.char ( 0x00 ), string.char ( 0x80 ) ) -- image width
fileWrite ( fileTXD, string.char ( 0x00 ), string.char ( 0x80 ) ) -- image height
fileWrite ( fileTXD, string.char ( 0x08 ) ) -- image BPP
fileWrite ( fileTXD, string.char ( 0x02 ) ) -- mipmap count, testing 2 as value
fileWrite ( fileTXD, string.char ( 0x04 ) ) -- raster type - apparently always 0x04
fileWrite ( fileTXD, string.char ( 0x03 ) ) -- dxt compression type

Link to comment
You need to write all sections with their headers before writing texture native struct section. This is TXD file structure. Try looking at TXD files with RW analyzer. Without it, I would hardly have understood RW format.

I feel like an idiot, I was writing the txd native struct, not the folder txd. But what was your method of writing the data to the .txd's? fileWrite ( string.char ( ) ) is 8-bit, so it makes you have to make adjustments. :x

Link to comment
function addBinaryValueToString(s,value,size)
if value == false then value = 0 end
if value == true then value = 1 end
if type(value) == "number" then
	value = value%(256^size)
for bytenum = 0,size-1 do
		s = s..string.char(math.floor(value%256))
		value = value/256
end
elseif type(value) == "string" then
	value = value..string.rep("\0",size-string.len(value))
	s = s..value
end
return s
end

s is a string you want to join the new bytes to, value is the value you want to join, it can be a boolean, integer or string, size is number of bytes you want to join. Function returns s string with new bytes joined.

First I made a function which writes the value directly to the file, but it turned out to be faster to write more bytes in less times than less bytes in more times. Using this function on long strings is slow too, so it's best to write the data to the file when the string is long enough.

Link to comment
  • 1 month later...
  • 2 weeks later...
  • 1 year later...

I putted drawntag and drawtag in resources and add acl - admin. When i type /draw and draw something, and again /draw to close window. It save, reload but when i am using spray always i got a oryginall texture from resource, not my new pattern. Any errors in debugscript 3. Any ideas ?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...