Jump to content

searching for .dff .txd .col compiler


Recommended Posts

Example:
 

function string_padding_dword(s)
	local l = 4 - string.len(s) % 4
  	return s .. string.rep(string.char(l), l)
end

function string_unpadding_dword(s)
	return string.sub(s, 0, string.len(s) - string.byte(s, string.len(s)))
end

function FileProtection(path, key)
	local file = fileOpen(path)
	local size = fileGetSize(file)
	local FirstPart = fileRead(file, 65536)
		fileSetPos(file, 65536)
	local SecondPart = fileRead(file, size - 65536)
	fileClose(file)

	file = fileCreate(path..'rw')
		fileWrite(file, encodeString('tea', string_padding_dword(FirstPart), { key = key })..SecondPart)
  	fileClose(file)

	return true
end

function FileUnProtection(path, key)
	local file = fileOpen(path)
	local size = fileGetSize(file)
	local FirstPart = fileRead(file, 65536 + 4)
		fileSetPos(file, 65536 + 4)
	local SecondPart = fileRead(file, size - (65536 + 4))
	fileClose(file)

	-- file = fileCreate(path..'rw')
		-- fileWrite(file, string_padding_dword( decodeString('tea', FirstPart, { key = key }) )..SecondPart)
  	-- fileClose(file)

	return string_padding_dword( decodeString('tea', FirstPart, { key = key }) )..SecondPart
end

-- example
FileProtection('infernus.dff', 'GT4BAE')

-- FileUnProtection(path, key)

local txd = engineLoadTXD('infernus.txd')
engineImportTXD(txd, 401)

local dff = engineLoadDFF( FileUnProtection('infernus.dff', 'GT4BAE') )
engineReplaceModel(dff, 401)

 

Edited by XaskeL
  • Like 3
Link to post
1 hour ago, XaskeL said:

Example:
 


function string_padding_dword(s)
	local l = 4 - string.len(s) % 4
  	return s .. string.rep(string.char(l), l)
end

function string_unpadding_dword(s)
	return string.sub(s, 0, string.len(s) - string.byte(s, string.len(s)))
end

function FileProtection(path, key)
	local file = fileOpen(path)
	local size = fileGetSize(file)
	local FirstPart = fileRead(file, 65536)
		fileSetPos(file, 65536)
	local SecondPart = fileRead(file, size - 65536)
	fileClose(file)

	file = fileCreate(path..'rw')
		fileWrite(file, encodeString('tea', string_padding_dword(FirstPart), { key = key })..SecondPart)
  	fileClose(file)

	return true
end

function FileUnProtection(path, key)
	local file = fileOpen(path)
	local size = fileGetSize(file)
	local FirstPart = fileRead(file, 65536 + 4)
		fileSetPos(file, 65536 + 4)
	local SecondPart = fileRead(file, size - (65536 + 4))
	fileClose(file)

	-- file = fileCreate(path..'rw')
		-- fileWrite(file, string_padding_dword( decodeString('tea', FirstPart, { key = key }) )..SecondPart)
  	-- fileClose(file)

	return string_padding_dword( decodeString('tea', FirstPart, { key = key }) )..SecondPart
end

-- example
FileProtection('infernus.dff', 'GT4BAE')

-- FileUnProtection(path, key)

local txd = engineLoadTXD('infernus.txd')
engineImportTXD(txd, 401)

local dff = engineLoadDFF( FileUnProtection('infernus.dff', 'GT4BAE') )
engineReplaceModel(dff, 401)

 

Thank you very much :) Do I just have to change infernus.dff and infernus.txd to my files? and what do I have to do with the key? (GT4BAE) 

Link to post
8 minutes ago, Dope88 said:

Thank you very much :) Do I just have to change infernus.dff and infernus.txd to my files? and what do I have to do with the key? (GT4BAE) 

It is worth testing. And the key is what you encrypt your file and decrypt, it is advisable to come up with it yourself. After that, you need to encrypt the models and in the client-side decrypt in RAW and load.

  • Like 1
Link to post
10 minutes ago, XaskeL said:

It is worth testing. And the key is what you encrypt your file and decrypt, it is advisable to come up with it yourself. After that, you need to encrypt the models and in the client-side decrypt in RAW and load.

Thank you I made all in Client File but now I get Errors in line 49: Corrupt DFF File data or file path too long

Link to post
  • 1 month later...
  • 4 weeks later...
7 hours ago, Maark said:

how i can do that? i trying right now but its not working :X

You must remove all references to the buffer variable and call "collectgarbage ()" after replacing the model, thereby freeing memory from unused data in the variables

  • Thanks 1
Link to post
12 hours ago, XaskeL said:

You must remove all references to the buffer variable and call "collectgarbage ()" after replacing the model, thereby freeing memory from unused data in the variables

im trying to do like this

local string = nil
function FileUnProtection(path, key, clear)
	print("loaded")
	local file = fileOpen(path)
	local size = fileGetSize(file)
	local FirstPart = fileRead(file, 65536 + 4)
	fileSetPos(file, 65536 + 4)
	local SecondPart = fileRead(file, size - (65536 + 4))
	fileClose(file)
  	if file ~= nil then file = nil end
	if size ~= nil then size = nil end
	return decodeString('tea', FirstPart, { key = key })..SecondPart
end

function FileUnProtection2(path, key, clear)
	if path and key and clear == nil then
		print("loading")
		local returnDATA = FileUnProtection(path, key, nil)
		return returnDATA
	elseif clear then
		print("clearing")
		print(returnDATA) -- prints nil ._.
		if returnDATA ~= nil then 
			returnDATA = nil 
			print("cleared")
		end
		if file ~= nil then file = nil end
		if size ~= nil then size = nil end
		if FirstPart ~= nil then FirstPart = nil end
		if SecondPart ~= nil then SecondPart = nil end
	end
end

local string1 = FileUnProtection2('549.txdcw', 'password', nil)
local txd = engineLoadTXD(string1)
engineImportTXD(txd, 549)
local string1 = nil

local string2 = FileUnProtection2('549.dffcw', 'password', nil)
local dff = engineLoadDFF(string2)
engineReplaceModel(dff, 549)
local string2 = nil

FileUnProtection2(nil, nil, true)

but in ipb still in Lua Memory

jbs9NWf.png

Edited by Maark
Link to post
12 minutes ago, Maark said:

im trying to do like this

but in ipb still in Lua Memory

jbs9NWf.png

Set txd and dff to nil too after replace.

  • Thanks 1
Link to post
1 hour ago, Maark said:

im trying to do like this


local string1 = FileUnProtection2('549.txdcw', 'password', nil)
local txd = engineLoadTXD(string1)
engineImportTXD(txd, 549)
local string1 = nil

local string2 = FileUnProtection2('549.dffcw', 'password', nil)
local dff = engineLoadDFF(string2)
engineReplaceModel(dff, 549)
local string2 = nil

FileUnProtection2(nil, nil, true)

but in ipb still in Lua Memory

jbs9NWf.png

Oh god. Let me help you seeing that you are not completely familiar with the "local" keyword in Lua. :) 

If you create a local variable in Lua then it overshadows any previous local variable definition without modifying variables with same names. Thus from the Lua compiler's perspective

local var1 = 1;
local var1 = 2;

There are two different variables with the same name but you can only access the last variable in subsequent code (the first one remains silently on the Lua stack).

THUS, to fix your code, replace line 37

local string1 = nil

with

string1 = nil

Please repair line 42 in the same way. ;) 

- Martin

Link to post
15 minutes ago, The_GTA said:

Oh god. Let me help you seeing that you are not completely familiar with the "local" keyword in Lua. :) 

If you create a local variable in Lua then it overshadows any previous local variable definition without modifying variables with same names. Thus from the Lua compiler's perspective


local var1 = 1;
local var1 = 2;

There are two different variables with the same name but you can only access the last variable in subsequent code (the first one remains silently on the Lua stack).

THUS, to fix your code, replace line 37


local string1 = nil

with


string1 = nil

Please repair line 42 in the same way. ;) 

- Martin

Ty, but still 36403KB in memory =/

Link to post
2 minutes ago, Maark said:

Ty, but still 36403KB in memory =/

Are you calling the function "collectgarbage" as XaskeL has suggested? I am not seeing it in your code that you posted above.

  • Thanks 1
Link to post
55 minutes ago, The_GTA said:

Are you calling the function "collectgarbage" as XaskeL has suggested? I am not seeing it in your code that you posted above.

No, i dont know about this function, i put in the code and now is 2451 KB in memory

@edit, i put 6 times and now is 212KB, thats nice (i see in stackoverflow we need use 2 times do destroy)

Link to post
  • 3 weeks later...
On 12/03/2020 at 21:18, The_GTA said:

Are you calling the function "collectgarbage" as XaskeL has suggested? I am not seeing it in your code that you posted above.

car dff size 24 mb txd 113 mb I am doing it for trial purposes but it does not appear in the game.

Link to post

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...