CocaColaBear / types-ragemp-s

Rage:MP TypeScript type definition for Server-side
https://rage.mp/
MIT License
44 stars 41 forks source link

Add typed correlation between event name and callback in mp.events.add #34

Open Jameskmonger opened 3 years ago

Jameskmonger commented 3 years ago

This change allows for strongly-typed usage of events.add for the specified events

For example if you do:

mp.events.add("playerDeath", (player, reason, killer) => { });

then player and killer will automatically be PlayerMp objects, while reason will automatically be a number

I have got the data from the Wiki e.g. https://wiki.rage.mp/index.php?title=PlayerDeath

foola1 commented 3 years ago

It would be better if it followed this from the 1.0 branch so you would have single source of truth in the EventKey enum.

https://github.com/CocaColaBear/types-ragemp-s/blob/68e985d47e6eb7191d5a0d2e4592519bae15012b/index.d.ts#L420 Also, why continue with 0.3.7? You cant officially get the server files for it anymore.

Jameskmonger commented 3 years ago

thanks for the link @foola1, to be honest I am only just getting started with RageMP dev so have just been going along with my initial setup from a few months back

Should I be updating to the ragemp developer preview? If so I'll do that - thank you!