Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Function 4bytes to hex please.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
hemersonkla1
Cheater
Reputation: 0

Joined: 24 Jun 2015
Posts: 34

PostPosted: Mon Sep 11, 2017 2:25 pm    Post subject: Function 4bytes to hex please. Reply with quote

hello friends would like to ask for help with a function. I want to convert 4bytes example to the value 100 for hex code = 64 but I did not find the function for that.

I found the one that makes hex for string which is this below.
I would like the function similar to 4bytes to hex.
I appreciate the answers.

Code:
function string.fromhex(str)
    return (str:gsub('..', function (cc)
        return string.char(tonumber(cc, 16))
    end))
end


words='6F6CC3A1207465737465'
reve=string.fromhex(words)
print(reve)





I would like to transform 4bytes 100 >> Hex 0064
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 138

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Mon Sep 11, 2017 3:01 pm    Post subject: Reply with quote

Code:
print(string.format('%X', 100))  -- prints 64

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
hemersonkla1
Cheater
Reputation: 0

Joined: 24 Jun 2015
Posts: 34

PostPosted: Mon Sep 11, 2017 5:01 pm    Post subject: Reply with quote

ParkourPenguin wrote:
Code:
print(string.format('%X', 100))  -- prints 64


Thank you very much, my friend. =)

Sorry, one more question and if I want to make the format stays 100 = 64 00 with the spaces. Thank you.
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Mon Sep 11, 2017 7:35 pm    Post subject: Reply with quote

Code:
local number = 100
local bytes = dwordToByteTable(number)
local result = string.format("%02X %02X %02X %02X", unpack(bytes))
print(result)
Back to top
View user's profile Send private message
hemersonkla1
Cheater
Reputation: 0

Joined: 24 Jun 2015
Posts: 34

PostPosted: Mon Sep 11, 2017 7:56 pm    Post subject: Reply with quote

Zanzer wrote:
Code:
local number = 100
local bytes = dwordToByteTable(number)
local result = string.format("%02X %02X %02X %02X", unpack(bytes))
print(result)
. Very thanks Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites