View previous topic :: View next topic |
Author |
Message |
Frouk Master Cheater Reputation: 5
Joined: 22 Jun 2021 Posts: 489 Location: mov dword ptr [Ukraine]
|
Posted: Tue Oct 12, 2021 10:21 am Post subject: [Solved]Define lua function local variable into c code |
|
|
As title says.I've used auto assemble in lua to execute c code and asm script that allows to call game function,but calling lua function with parametres won't do anything
_________________
void(__cdecl *Haxing)(HWND hGameWindow)
Last edited by Frouk on Tue Oct 12, 2021 11:20 am; edited 1 time in total |
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25288 Location: The netherlands
|
Posted: Tue Oct 12, 2021 10:29 am Post subject: |
|
|
is the lua function in the game or in CE ?
if in CE use {$luacode value=reg}
and call whatever function you like
_________________
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 |
|
|
Frouk Master Cheater Reputation: 5
Joined: 22 Jun 2021 Posts: 489 Location: mov dword ptr [Ukraine]
|
Posted: Tue Oct 12, 2021 10:31 am Post subject: |
|
|
This is a function in lua table that connects to c code
Code: |
function gameSetWorldHeat(DesiredHeatLevel)
local s = [[
alloc(worldHeat,1024)
createThread(worldHeat)
worldHeat:
{$ccode tmp=eax}
typedef int(__cdecl *fGame_SetWorldHeat)(float,void);
fGame_SetWorldHeat Game_SetWorldHeat = (fGame_SetWorldHeat)0x65C550;
Game_SetWorldHeat(DesiredHeatLevel) //Must be setted but won't
{$asm}
ret
dealloc(worldHeat)
]]
autoAssemble(s)
end |
_________________
void(__cdecl *Haxing)(HWND hGameWindow) |
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25288 Location: The netherlands
|
Posted: Tue Oct 12, 2021 10:59 am Post subject: |
|
|
ok but what is your issue/what you want to do?
_________________
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 |
|
|
Frouk Master Cheater Reputation: 5
Joined: 22 Jun 2021 Posts: 489 Location: mov dword ptr [Ukraine]
|
Posted: Tue Oct 12, 2021 11:04 am Post subject: |
|
|
I call function like this: Code: | gameSetWorldHeat(5) |
But after function was called there's no difference beetween values(value didn't changed)
EDIT:
I tried string.format and it worked
_________________
void(__cdecl *Haxing)(HWND hGameWindow) |
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 140
Joined: 06 Jul 2014 Posts: 4290
|
Posted: Tue Oct 12, 2021 11:31 am Post subject: |
|
|
You have alloc and dealloc in the same script. I don't know what exactly happens, but it's wrong.
The simplest thing you can do is use globalalloc and no dealloc.
In the script, DesiredHeatLevel is just part of the string literal. It isn't the parameter passed to the function. You need to use string.format if you want to format the string with the argument.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25288 Location: The netherlands
|
Posted: Tue Oct 12, 2021 11:32 am Post subject: |
|
|
oh yes, that dealloc won't work
_________________
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 |
|
|
Frouk Master Cheater Reputation: 5
Joined: 22 Jun 2021 Posts: 489 Location: mov dword ptr [Ukraine]
|
Posted: Tue Oct 12, 2021 12:40 pm Post subject: |
|
|
For me alloc and dealloc works in one script,idk how,but its working
_________________
void(__cdecl *Haxing)(HWND hGameWindow) |
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 140
Joined: 06 Jul 2014 Posts: 4290
|
Posted: Tue Oct 12, 2021 1:43 pm Post subject: |
|
|
The code executes fine but the script leaks memory every time it's run. Replace alloc with globalalloc and remove dealloc. globalalloc only allocates memory once so it doesn't leak.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
Frouk Master Cheater Reputation: 5
Joined: 22 Jun 2021 Posts: 489 Location: mov dword ptr [Ukraine]
|
Posted: Tue Oct 12, 2021 1:52 pm Post subject: |
|
|
Ok i will
_________________
void(__cdecl *Haxing)(HWND hGameWindow) |
|
Back to top |
|
|
|