View previous topic :: View next topic |
Author |
Message |
Programacao e cheats How do I cheat? Reputation: 0
Joined: 03 Sep 2021 Posts: 2
|
Posted: Fri Sep 03, 2021 9:09 pm Post subject: How to call Lua functions from {$ccode} blocks |
|
|
My question is how to get the lua_state from a {$ccode}, and thus be able to call Lua functions.
I know how to create functions using {$ccode}, call them using lua or assembly, but was wondering how to call Lua functions from C or asm code.
By creating a plugin I could easily add this feature, but I want to know if there is already a native way. |
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25288 Location: The netherlands
|
Posted: Sat Sep 04, 2021 1:57 am Post subject: |
|
|
Do you mean the lua_state that the game uses or the lua_state that CE uses internally as used in {$luacode} blocks ?
In case of the game's lua: hook any lua function, but I recommend lua_gettop, and then use that to call the functions (keep in mind thaty diufferent threads may have different lua_states, and sometimes the game may just destroy the lua state after just one call...)
in case of CE's lua functions:
make sure luaclient is injected into the target and the luaserver in CE is running (look at the call lua function aa template)
and then you can call CELUA_ExecuteFunctionByReference(functionrefid, parametercount, paramlist, async)
you can also call CELUA_ExecuteFunction("stringwithluascript", optionalparameter) but this will parse the script each time, so is slower _________________
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 |
|
|
Programacao e cheats How do I cheat? Reputation: 0
Joined: 03 Sep 2021 Posts: 2
|
Posted: Sat Sep 04, 2021 12:45 pm Post subject: |
|
|
I had never noticed that there was an AA template on it.
Thank you for your help. |
|
Back to top |
|
|
|