CocaColaBear / types-ragemp-c

Rage:MP TypeScript type definition for Client-side
https://rage.mp/
MIT License
53 stars 60 forks source link

Adds mp.game.gxt #49

Closed nnsdev closed 4 years ago

nnsdev commented 4 years ago

get and getDefault currently have any assigned to them, because I am not sure what those return, I have not gotten around to test it in-depth yet.

Only thing I got to test so far is mp.game.gxt.add("PM_PAUSE_HDR", "Content"); which would mean the getDefault and get would return a string, however I am not sure if that is potentially the only type that this can return, so any will do for now.

pixlcrashr commented 4 years ago

What does get and getDefault return in game? From the API given it seems like that this methods are just methods of a simple key-value-pair-object.

pixlcrashr commented 4 years ago

Btw. Aren't you missing the set method?

nnsdev commented 4 years ago

It returns strings, at least for this value I have tried. However, I do not know if it potentially returns numbers on other label strings, because I do not know other labels to try.

set = add, as far as I can tell. 1.0 Changelog only referenced these methods

Added: Client-side: mp.game.gxt.add(labelNameOrHash, newLabelValue) Added: Client-side: mp.game.gxt.get(labelNameOrHash) Added: Client-side: mp.game.gxt.getDefault(labelNameOrHash) Added: Client-side: mp.game.gxt.reset()

pixlcrashr commented 4 years ago

However, I do not know if it potentially returns numbers on other label strings, because I do not know other labels to try.

Well, you could try adding a label with a number as a value. Either you can set a number or not. You'll probably will get an error by doing so.

However, if you can set a number check if the get method returns a number aswell by using the same key. This would justify using any. Otherwise we should use string, because it is more specific and type-safe.

set = add, as far as I can tell. 1.0 Changelog only referenced these methods

Oh okay. You wrote in your description set. Nvm.

nnsdev commented 4 years ago

Okay looking at this file: https://gist.githubusercontent.com/alloc8or/057e4d573cdfe238db31ec5edf2efbbb/raw/a8831b6c39292f7b4769fa6a183c8bbdb7fb1273/GTAV_All_Text_Labels_1737.txt

Going by this file, I am going to assume that the types are all just strings?

pixlcrashr commented 4 years ago

Going by this file, I am going to assume that the types are all just strings?

I would say so, but we should prove it to be sure.

nnsdev commented 4 years ago

Okay seems like .add(irrelevant, number) sets it to the default, which means only strings are accepted.

pixlcrashr commented 4 years ago

And what is the default? An empty ""?

nnsdev commented 4 years ago

For the one I have tried, it'd technically be "Grand Theft Auto V" (which is what the getDefault returns), however RAGE overwrites it to "RAGE Multiplayer" by default

pixlcrashr commented 4 years ago

Alright, then we should change it to the return type string.