Jump to content

Native event handling through RPH


Recommended Posts

Hey everyone,

I just recently decided to get into GTA V mod development and was wondering if anybody knew how to set up event handlers for native game events (something like FiveM's EventHandlers) such as CEventEntityDamaged...

I know there's a "PedShotEventArgs" type within the Rage Plugin Hook SDK, but I just can't seem to find anything that uses that, or any handleable event apart from FrameRender and RawFrameRender.

Link to comment
Share on other sites

  • Management Team

There is no support for game events in Rage Plugin Hook. There are generally two ways for implementing an event hook yourself: You can go the FiveM route which allows you to be notified about events happening and their parameters. This is quite simple to implement and should only involve hooking 1-2 functions. LSPDFR uses a slightly different approach in that we also want to be able to suppress events based on their parameters which requires some more work but yields greater control. Lastly, depending on your specific need it might be solvable without an event hook in the first place, so feel free to elaborate on that.

Please do not PM me unless really necessary (knowing you helps). If you think you need my attention in a topic, tag me.

Link to comment
Share on other sites

Alright, so what I was thinking about is a plugin that introduces a realistic-ish health system for both AI peds and the player, adding things such as bleeding, limping/crawling with injured legs, disable the ragdoll-on-shot thing that GTA has and instead only ragdoll on death/pass out. Therefore, I was thinking about adding a bunch of parameters to every ped using the handy Ped.Metadata, and acting upon those by intercepting something like an EntityDamaged event and then possibly suppressing it to prevent the game from interfering. If you, or anybody can think of a different strategy to tackle my goal I'd love to hear that, but otherwise I would be interested in the approach you mentioned LSPDFR uses, if you're willing to share any information on that. I am not too knowledgeable when it comes to low level stuff and function hooking, but I am more than willing to try and get into it if it might help with my project.

Thanks in advance!

Link to comment
Share on other sites

  • Management Team

For the most part you should be able to just keep track of all peds in the game and make changes according to their health. Now this won't be as smooth as hooking the events, but if you say you are not too experienced with that, it might be a good first approach. A general event hook to be notified is not too much work, but if you want to suppress events too it will be quite a bit more, so you may want to skip that for now. If you check the peds every 100-200 milliseconds that should yield decent response time and not affect performance too much.

Please do not PM me unless really necessary (knowing you helps). If you think you need my attention in a topic, tag me.

Link to comment
Share on other sites

I did try to set up something like that (monitoring ped health for changes), but the real reason I would need to take an event approach, is that I need access to some parameters that I'm assuming would be passed as an event argument, such as the sender entity and the weapon used. Also, the approach you suggested implies that to accomplish my goal of disabling the ragdoll on shot thing, I'd have to set every entity to unconditionally never go into a ragdoll state, and that is not really a viable option as peds would then not respond to falls, being hit by vehicles and all of those things that I would otherwise not affect in my plugin...

I guess I'll try to figure out the event hook anyway, maybe looking at FiveM's code, but if you have any pointers to share on that they would be greatly appreciated 😄

Edited by Lukez3218
Link to comment
Share on other sites

  • Management Team
On 5/8/2019 at 4:35 PM, Lukez3218 said:

I did try to set up something like that (monitoring ped health for changes), but the real reason I would need to take an event approach, is that I need access to some parameters that I'm assuming would be passed as an event argument, such as the sender entity and the weapon used. Also, the approach you suggested implies that to accomplish my goal of disabling the ragdoll on shot thing, I'd have to set every entity to unconditionally never go into a ragdoll state, and that is not really a viable option as peds would then not respond to falls, being hit by vehicles and all of those things that I would otherwise not affect in my plugin...

I guess I'll try to figure out the event hook anyway, maybe looking at FiveM's code, but if you have any pointers to share on that they would be greatly appreciated 😄

 

I see, yes, if you want that level of control a hook would be the best idea. You could take a look at EasyHook which is what we use for LSPDFR to hook unmanaged code from C#.

Please do not PM me unless really necessary (knowing you helps). If you think you need my attention in a topic, tag me.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...