Lua Scripting, all natives

Been working with Lua and was wondering, does anyone have a natives.lua for scripting?

I have found natives.h, natives.html, natives.json but nothing for lua.

If I am calling these functions, do I have to have a file with the natives or will that be called from GTAV through scripthook?

Any and all help is appreciated, very little information out there for lua scripts.

Also a lot of player natives seem to differ from a few lists I have, for example;

static void _SET_MOVE_SPEED_MULTIPLIER(Player player, float multiplier) { invoke(0x6DB47AA77FD94E09, player, multiplier); } // 0x6DB47AA77FD94E09 0x825423C2

is a working one but when I look it up on the dev-c.com natives, it is different there/ I cant find it.

void SET_RUN_SPRINT_MULTIPLIER_FOR_PLAYER(Player player, float multiplier)
// 0x6DB47AA77FD94E09 0x825423C2

Does anyone have an explanation? Which is correct?

And yes, I am aware not all these natives are available in FiveReborn.

Thanks

It’s located in FiveReborn (Client Folder)\citizen\scripting\lua\natives.lua. I attached it anyway.
natives.lua (486.8 KB)

Yes, I just looked at this. Helpful stuff but not all natives are in there, I am looking for ALL natives available to GTA, not just the ones that FiveReborn uses.

If I am making a script, does natives.lua have to exist with my mod.lua in the same folder?

Or is this just for reference and auto completion?

Also, I see in examples of other people’s Lua’s, they call native.PLAYER/VEHICLE/WEAPON.SET_xxx etc.

Example:
function onlineFunctions.removeAllWeapons§
if(Preformatted textPlayer§:Exists() then
natives.WEAPON.REMOVE_ALL_PED_WEAPONS(Player§.ID,true)
end
end

Why do some peoples code call natives. before a namespace while others do not?

natives.lua is just used by the client, no you don’t need it in any server folder and it doesn’t have anything to do with the server really, it’s just downloaded server resources for the client to use.

Do you have a name of a native you couldn’t find in natives.lua? Some natives are not yet known so they are displayed as “N_0x56c8b608cfd49854”.

Also, I see in examples of other people’s Lua’s, they call native.PLAYER/VEHICLE/WEAPON.SET_xxx etc.

Example:

function onlineFunctions.removeAllWeapons(p)
if(Preformatted textPlayer(p):Exists() then
natives.WEAPON.REMOVE_ALL_PED_WEAPONS(Player(p).ID,true)
end
end

Why do some peoples code call natives. before a namespace while others do not?

I don’t know where that’s from but RemoveAllPedWeapons(ped, true) is what you should use in lua and it’ll work.

1 Like

Edited last post.

I gotcha on the client natives, and I get that not all are defined.

Still don’t know why some are defined differently in different lists.

No underscores? Sorry, making concrete rules in my head and I don’t want anything incorrect to stick.

Yeah, that’s not how you call natives from the mod, I really don’t know where that came from. You just call the natives from the client resources following the function names and arguments of the natives.lua file. If there’s an underscore, remove the underscore and search it in the natives.lua file, make sure the function name matches, it’s case sensitive as well.

1 Like

PLAYER. SET_MOVE_SPEED_MULTIPLIER(Player player, float multiplier)
^Namespace/
^Function name^____^Arguments ^
^ Native

Hash and arguments?-> { invoke(0x6DB47AA77FD94E09, player, multiplier); }

Hash name-> // 0x6DB47AA77FD94E09 0x825423C2

So why does everywhere else say to use underscores in the function name for lua?

Are there just no underscores in the natives.lua for FiveReborn? or if I am making a mod for just single player, standard GTA, do I then use the underscores? or not at all?

I don’t use the hashes obviously, but I have to ask; where did the natives.lua come from?

Would there be a way to add to the natives.lua in the client to expand upon the toolbox?

Well there are different mods and other mods may use underscores but FiveReborn also known as pλ does not. You just call everything from a client resource the way it’s shown in that natives.lua file. natives.lua is the main native file for FiveReborn that is used to call upon game native functions when players invoke one of the lua functions in it, that’s all it is.

About auto-complete, in the future I may do something like that for notepad++, don’t know about sublime text, maybe I do, I don’t know at the moment.

1 Like

Well, using netbeans I just added natives.lua to my project folder and it added auto fill for functions (Same package).

Guess I might as well make these using the natives of pλ as I am looking to make mods I can use with friends, not solo.

Thanks!

Here is what I have for a simple faster run mod-
mymods.lua (254 Bytes)
How does it look?

Yes, I know simple but, whatever, just wanna make sure I am doing it semi-correctly.

Sure, get rid of return mymods though (it’s not even in a function). return is supposed to be used inside functions that return values only, or to halt the execution of a function. The return must also be before the end of the function declared by “end”.

1 Like

Please create A wiki !!!

Ah, okay then. Will redo it a little later and test it. So don’t even need a return in this one? (Yet)

Thanks, you will probably hear from me again.

@ForPlayers
For what?

Those exist at http://www.dev-c.com/gtav/

Because other Lua APIs do use these raw names.

Any of these that started with _ are a guessed name that did not match the old Jenkins hash. These can change names at any time based on community documentation.

natives.lua is a snapshot from nativedb created quite a while ago, but the long (int64) hashes will always match.

Generated by a tool by a developer a long time ago.

Namespaces are a nonsensical idea anyway that only helped for categorizing natives during initial research. R* themselves doesn’t even use those in their scripting language anyway.

1 Like

Ah okay thanks for advice me !

WOW!

Thank you, looks I found a new friend.

Have begun making some mods in Lua, I hope more are doing this, it seems the devs prefer them for stability/ security.