Scripting In Lua - Docs
Maybe your like
FiveM supports the general purpose programming language Lua as one of its scripting languages. Lua is a very easy language to learn, simple to use and fast to write. To use Lua, just use .lua in your scripts file extensions.
A modified version of Lua 5.4 is used in FiveM, called CfxLua. This version includes some of the modifications the Grit game engine introduced:
- Support for relative path literals
- Support for vectors & quaternions
To learn more about Lua, read their official documentation.
Using Lua
To use Lua in your scripts, simply use the .lua file extension. No additional configuration is required.
Compile-time hashes
Because you might often have to deal with 'Jenkins one-at-a-time' hashes in GTA/RAGE, the Lua runtime has been extended to have support for compile-time generation of hash keys, similar to GET_HASH_KEY, however with zero runtime overhead.
For example:
-- gettingRequestModel(`adder`) -- comparingif GetEntityModel(vehicle) == `buzzard` thenprint("Indeed, it's a Buzzard.") end -- printingprint(`a_m_y_skater_01`)Vectors & quaternions
FiveM supports first-class vectors and quaternions in Lua. Vectors and quaternions are incredibly useful to represent things like positions, rotations or even colors. For performance reasons, vectors and quaternions are real data types in CfxLua, just like booleans, numbers and strings are.
Many native functions return and accept vectors too. They're commonly used for world positions and standard euler rotations, so use them whenever you can. More about there here.
For usage and examples see their respective docs:
- quat
- vector2
- vector3
- vector4
Using exports
You can define exports by calling the global exports object:
hello.lua:
exports('SayHello', function(str)print('Hello, ' .. tostring(str) .. '!') end)You can also define an export or server_export entry in your resource manifest. Functions need to be global to be 'explicitly' exported. Note that these exports will only be available after the first scheduler tick.
For example:
Inside hello_explicit.lua:
functionSayHello(str)print('Hello, ' .. tostring(str) .. '!') endInside fxmanifest.lua:
-- Client:client_script 'hello.lua'export 'SayHello' -- Or server:server_script 'hello.lua'server_export 'SayHello'In another resource:
-- Prints 'Hello, world!'exports.myresource:SayHello('world')External libraries
The Lua runtime exposes some libraries on the global scope which you can use.
- json: dkjson 2.5
- promise: lua-promises
- msgpack: lua-MessagePack 0.3.3
Lua specific functions
- Client functions
- Server functions
Tag » Apprendre Le Lua Fivem
-
[TUTO/FIVEM] Apprendre Le LUA Sur FIVEM #1 Les Conditions
-
Comment Créer Un SCRIPT FiveM (Ep.1) - YouTube
-
A La Conquête Du Scripting FiveM : épisode 1 - Les Bases. - YouTube
-
Les Bases Du Lua Sur FiveM
-
Creating Your First Script In Lua - Docs
-
Scripting In JavaScript - Docs
-
Apprendre Le Lua | Tutoriel Et Bases Du Langage De Script - IONOS
-
LS Confidential On Twitter: " Hello Twitter ! Nous Sommes à La ...
-
Lua | VeryLeak's
-
FiveM Scripting | Comment ça Marche | ESX
-
Top 15 Développeurs Lua Freelances
-
Premier Livre En Français Sur Le Langage De Script Lua - AFJV
-
SUP2Ak [DEV]
-
Liens Utiles FiveM Pour Utilisateurs Et Développeur - GTA5 Cool