View previous topic :: View next topic |
Author |
Message |
sir-gunny Advanced Cheater Reputation: 0
Joined: 15 Mar 2012 Posts: 77
|
Posted: Mon May 23, 2022 7:03 am Post subject: registerCustomTypeLua with QWord read/write wrong values |
|
|
Code: | function Money_bytestovalue(b1,b2,b3,b4,b5,b6,b7,b8,address)
local iMoney = byteTableToQword({b1,b2,b3,b4,b5,b6,b7,b8})/1000
return iMoney
end
function Money_valuetobytes(i,address)
local bBytes = qwordToByteTable(i*1000)
return bBytes[1],bBytes[2],bBytes[3],bBytes[4],bBytes[5],bBytes[6],bBytes[7],bBytes[8]
end
function MyCustomType()
local typename = "Money"
local bytecount = 8
local isFloat = false
registerCustomTypeLua(typename, bytecount, Money_bytestovalue, Money_valuetobytes, isFloat)
end |
Hi.
At high values displays this function wrong values.
Example:
I enter 4800000000, the func should convert it to 4800000000000 and write it to memory (00 80 4B 96 5D 04 00 00).
But currently, if i enter 4800000000 the memrec shows 505032704 and write to memory 505032704000 (00 80 4B 96 75 00 00 00)
If i enter 480000000 there are no problems.
What i'm doing wrong?
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 457
Joined: 09 May 2003 Posts: 25262 Location: The netherlands
|
Posted: Mon May 23, 2022 10:29 am Post subject: |
|
|
input is only in 32-bit
4800000000 is 11E1A3000 so that won't fit (will be 1E1A3000 so 505032704)
if you change the formula to do *10000 you can get a correct result with the value 480000000
you can of course device other ways to input higher bit values, like if it's 480000000 it's *1000 and if it's 480000001 it's *10000 after stripping the 1, and 480000002 it'd be *100000 (after stripping the 2)
just requires a bit more thought
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
sir-gunny Advanced Cheater Reputation: 0
Joined: 15 Mar 2012 Posts: 77
|
Posted: Tue May 24, 2022 7:07 am Post subject: |
|
|
Thanks
I change the formula to 1000000 (MoneyInK).
Is it possible to implement a 64-Bit input in future updates? By the way, is it posible to implement string-support to display/format values as date, time or money (e.g. 1.234.567 €)?
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 457
Joined: 09 May 2003 Posts: 25262 Location: The netherlands
|
Posted: Tue May 24, 2022 8:53 am Post subject: |
|
|
Typing in 64-bit values is kinda silly for custom types (the reason for custom types is to get human readable values from chaotic data).
But I will add float support to lua custom type so you can enter 4800000000 which then gets converted to a float (e.g 4.8E9) and then if you do 4.8E9 * 1000 it turns into 4.8E12 (4800000000000)
and then instead of converting the float to a float in memory you can convert the float to a 64-bit integer bytetable and write that. (you'll have to do the converting of fpu to integer based bytes yourself, or math.floor)
as for strings, I can add that I guess, but you will be responsible for converting the value to a string. And likely there will be a string limit
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
sir-gunny Advanced Cheater Reputation: 0
Joined: 15 Mar 2012 Posts: 77
|
Posted: Thu May 26, 2022 2:51 am Post subject: |
|
|
Stupid question: does the exponent convert only the 0 (4.8E9) or convert it e.g. 4812123123 to 4.812123123E9?
@strings:
Yes, converting the value to a string and back ist not the problem. Displaying the value in a way that I can easily edit it. Currently i convert a int datevalue (e.g. 245233 = 07.11.2022) to a hex-string like "07112022" (DDMMYYYY) and return the integer of it. After that I only have to select the option "show as Hex". This works for date but not for time or everything else. I hope you understand me with my bad english .
And BIG THX for support!!
|
|
Back to top |
|
|
sir-gunny Advanced Cheater Reputation: 0
Joined: 15 Mar 2012 Posts: 77
|
Posted: Sun Apr 30, 2023 1:47 am Post subject: |
|
|
Hi.
At the current version of CE you added string based custom types. How can i use it? Is there a new parameter like isString or so? At the Wiki i cant found anything.
|
|
Back to top |
|
|
|