thaCURSEDpie Posted August 19, 2017 Share Posted August 19, 2017 Hi everybody,I miss one big feature in the current scripthooks/plugin hooks: the ability to intercept and modify game events. Example: you could intercept an event in which the player receives damage. Then, you could triple the damage received, or maybe reflect the damage back to the attacker. You could spawn chickens instead of rockets. You could flip the player's car when they run over a ped. In essence, you would have complete control over the game.I have already made a C library which can intercept (hook, detour) arbitrary x86_64 function calls. It works great so far: any function can be intercepted and the parameters can be inspected and modified as well. The same can be done for the return value.It is possible to intercept function calls, so we can also reroute these to our self-written plugins and scripts (even calling .net scripts is possible). Great! But now comes the problem:The rerouted function call is not in a Script thread/fiber. Therefore, the plugin/script we notify of the event cannot call any native functions. This is pretty sad :-(.I can think of two ways of solving this issue:1) From the hooked function, call a helper script, then immediately resume the hooked function. On the next Script tick(), the helper script notifies other scripts/plugins of the event, so modifying/blocking it is not possible, but at least the scripts know an event happened. 2) From the hooked function, call a helper script, then wait. On the next Script tick(), the helper script notifies other scripts/plugins, and allows them to modify it. When the helper script is done, it wakes up the hooked function again, which then continues.Option (1) sucks, because you cannot modify the events. Option (2) may be OK, but the detoured function call is blocked while the custom scripts sort out their stuff. This could take very long, slowing down the game.What do you guys think? What would be a good approach? ikt 1 Link to comment Share on other sites More sharing options...