DottieDot / GTAV-NativeDB

https://nativedb.dotindustries.dev/
MIT License
53 stars 17 forks source link

Feat/ts gen #51

Closed skyrossm closed 1 year ago

skyrossm commented 1 year ago

Description

Adds TypeScript codegen & native display support

Sample codegen

// https://alloc8or.re/gta5/doc/enums/ePedType.txt
// Full list of peds by DurtyFree: https://github.com/DurtyFree/gta-v-data-dumps/blob/master/peds.json
function CreatePed(pedType: number, modelHash: number | string, x: number, y: number, z: number, heading: number, isNetwork: boolean, bScriptHostPed: boolean): number { return _in<number>(0xD49F9B0955C367DE, pedType, _ch(modelHash), x, y, z, heading, isNetwork, bScriptHostPed); } // 0xD49F9B0955C367DE 0x0389EF71 b323

To ensure compatibility with existing FiveM code, strings in place of hashes get converted to numbers. _ch is the existing CFX JS function converting a string to a hash, however it should be simple to recreate this as needed.

Other Changes

Screenshots

image image

skyrossm commented 1 year ago

Thanks for the quick review, I've updated the PR 👍

skyrossm commented 1 year ago

Yep the CFX JS library has parameters that it passes in instead of the pointers. It's something I noted but I think it would require a lot more refactoring to work properly.

Ints are also converted (maybe not needed?) to floats in JS with +0.0000001.

I think a separate PR improving the way types are handled would be the next step.