FiveM Modding Tutorial
That is my try to assist others whom are already (a bit?) aware of programming however want some
instructions to get began (“bounce into”) FiveM script improvement. I actually am a programmer in a number of
languages for a number of years, however did had some points to start with find the proper sources,
Natives and/or documentation.
(Yeah, perhaps i didn’t regarded on the proper locations, but it surely’s at all times useful to have extra paths to assist )
So I made a decision to make a ‘small overview’ for others to get began on fundamental stuff they could/will
want when beginning out ‘contemporary’ in FiveM or lua (assuming lua right here since that’s what most will use,
though I actually additionally use C# so much, I ASSUME that almost all right here would profit extra from a lua level
of view on this ‘how-to’. (and C# programmers will know the best way to apply this info to C# anyway
i suppose )
New to lua or want extra info on some lua capabilities?
First of: IF you might be new to lua scripting or want some further info I can advocate this hyperlink:
Understand that not all capabilities may/will work for FiveM scripting however A LOT is, and it’s DEFINITELY
a helpful useful resource for trying up capabilities or strategies with the search operate.
Subsequent be sure to tell your self by researching/studying from:
The official FiveM Scripting Manual
Which additionally covers many examples.
When interfacing with gamers, objects, autos and your “GTA world” you will have a number of
capabilities/natives to take action. These capabilities/natives are very properly documented/listed at:
FiveM Native Documentation and at Dec-C NativeDb
In fact it’s extremely really useful once you’re new to lua and even (recreation) scripting in any respect, to simply
obtain some SIMPLE examples and see how they work, strive altering stuff and see the way it works out and reacts for you in recreation.
“Professional Tip:” You’ll be able to really run FiveM (The Sport itself) in windowed mode by urgent left-alt+enter
Whenever you then restart your script on the server you may immediately re-test it with out the necessity of restarting
the entire recreation.
CAUTION THOUGH! When you find yourself getting extra superior and are including/changing
sources and even streaming stuff like autos after which restart your script, it won’t work as anticipated when restarting and even trigger a crash (consumer aspect). Though that is (for now) strategy to detailed to clarify and also you SHOULD don’t have any points with this once you’re simply beginning out and discovering your means.
(Because it’s positively not the suitable time to begin ‘messing’ with that stuff with out getting the dangle of the remaining )
**Primary Server Instructions**
The server instructions are documented right here FiveM Documentation
The Primary instructions that are useful to know and keep in mind:
begin MyScriptName [Which is the FOLDERNAME which contains the _resource.lua and your scripts)
restart MyScriptName (especially handy when testing it while programming)
Windows users: Do note that these commands are case sensitive!
**Basic Client Commands (For the F8 console)**
The total documentation can yet again be found at: FiveM Documentation
However, one that I would like to point out extra, and which is quite important for
resource/performance aware programmers is:
Using this command in the client console will open a resource monitor like this:
TIP: When holding ALT+CTRL you can resize the resource monitor.
With this resource monitor you can view what the ‘response time’, memory use
and streaming data for your script is. (always try to keep those numbers as low as possible!)
For those whom are paying attention: YES i’m aware of the rather high CPU msec on XNL-Scripting,
And i also know what’s causing it, no worries it’s just a testing script
Further more I have some more (also external) resources which can/will be quite helpful, I definitely
hope that I’m not violating any TOS or “provoke” ‘but that’s a competitor site’ stuff, since it’s merely posted here to help others along with ‘valuable information’ And also please do note
that I’m NOT an owner, associated with or ‘promoter’ of these external links, just here to help others
along with resource information.
**Ped and player animations**
Animations (or animation scenario’s) are absolutely crucial to make interactions, ped and the
world in it’s own more “life like’ and can even make it “blend (nearly) seamless” with the original game.
Two most common ways of animating ped’s (or the player) are TaskStartScenarioAtPosition and TaskPlayAnim (Both documented at the FiveM Native website as mentioned above).
For scenarios you could use this link as reference: Scenario’s
And for TaskPlayAnim you can use This list which has over 13.8K of animation clips listed.
DO NOTE That TaskPlayAnim requires dictionary loading before you can use the animation,
although i will NOT get into that here, since this ‘how to’ is purely meant to give directions to resources,
information and give you ‘waypoints’ to get along more easily. There are PLENTY of animation
examples on the forum, and now you also have a massive list of animations to try
SMS Text Messages with pictures (and player ‘photo’)
I bet you have seen them plenty of times in GTA Offline, Online or even in FiveM:
SMS Text Notifications with an logo or picture, well you can use those to, and even fairly simple
to be honest (The one above is from one of my own scripts).
You can use my Trains and Metro’s script to see an example of how they are used:
SMS Text Example In My Trains Script
BUT what if I would like to use other icons than the one you’ve used?
Check out the ■■■■■■■■■■ Wiki with all (as far as i know) SMS pictures.
You can even use your (or other player’s) ‘mugshots’ as sms photo by using this code:
local headshotId = RegisterPedheadshot(GetPlayerPed(player)) while not IsPedheadshotReady(headshotId) do Wait(0) end local headshotTxd = GetPedheadshotTxdString(headshotId)
headshotTxd will then be your “mugshot”/photo
and if you would then use “my function” from my trains script it can be used like this:
local headshotId = RegisterPedheadshot(GetPlayerPed(player)) while not IsPedheadshotReady(headshotId) do Wait(0) end local headshotTxd = GetPedheadshotTxdString(headshotId) PlName = GetPlayerName(PlayerId()) SMS_Message(**headshotTxd**, PlName, "Subject Here", "Message Here", true)
Well hope that part was useful at least
**Player Bones (To attach objects to)**
When you would like to use the native AttachEntityToEntity to attach objects to a player or ped
you would need to know bone index and/or the bone ID. Well the bone index can be retrieved by:
BoneIndex = GetPedBoneIndex(Ped, bone_ID)
Well I assume that most by now know that Ped should be refrencing the ped or player you’re trying
to attach something to. But how do you know the bone_ID’s?
Well here’s another large list, this time with bones for you all:
■■■■■■■■■■ Wiki Bones List
**(Vehicle) color list, ID’s, RGB and Names**
Here’s a list with vehicle colors and names from GTA: Color List
Some other resources/links which are quite ‘vital’ or handy when making new scripts or gamemodes:
Map blips/icons which can be used on the game map/radar in scripts or game modes:
GTA Map Blips And Their ID’s
My objects list (so you can more easily look up hashkeys to object names to make programming a
bit more easier:
Modelhash to ObjectName
A wonderful tool by @Mooshe to support development and detect objects/entity’s in game
Note: It might be a ‘bit annoying’ to use together with Menyoo since they both respond to each others
keymappings so you could/should change those for your convenience ;).
Personally i do recommend the menyoo menu to since it’s easy to use the ‘Freemode’ when placing objects.
There are MANY other things to guide and show pathways to but then i could go-on endlessly haha,
Just use the search function on the forum and you will find A LOT of help and info.
If there are some other aspects I might have missed which should also be included please let me
know. Again this is NOT meant to “learn you scripting” but to guide you to resources to be able to
“get to work” (much) faster by knowing the places to look for the (correct) data
Please do keep in mind that I’m programming for a long time already, so I might have forgotten to
mention important directions to look for, but that might be due to stuff becoming ‘second nature’.
If I did forgot important directions please let me know and i will try to add them when I have some time
Despite mentioning at the top of this post that this is not for ‘complete starters’ , I do want to put some
extra words of advice for newly starters our there in here
**Final words of advice (for those whom it may concern/total new starters 😉 )**
PLEASE just do yourself (and others ) a favor and learn to script, it’s really not that difficult, it just
takes some time, devotion and what most seem to do their best to avoid: READING.
In my years programming I have had many people (not just on forums, but even more at work and on
projects) ask “how do I learn this” or “how do I do this” and when then explaining or showing some examples they just ‘dropped out’ with a remark like: “Nah way to much reading pfffff”.
While then later returning with: “Hey can you “just” program this for me?” sometimes even with a
remark like “I can pay if you require?”… Well nope just learn it yourself, it’s not that hard.
It’s very easy to ask if others would solve your ‘problem’, but let me put it this way:
If you don’t even put the effort in reading a bit of text, then why would someone else put his or her
time in making something for you?
Most are just very fast ‘demotivated’ by all the technical terms like variables, structures, event handlers
and by how those ‘scary functions’ look like :
void TASK_PLAY_ANIM(Ped ped, char* animDictionary, char* animationName, float speed, float speedMultiplier, int duration, int flag, float playbackRate, BOOL lockX, BOOL lockY, BOOL lockZ);
Well don’t be, it’s not that difficult when you just take your time, read it carefully and try to understand
what it does PER section. Most new scripters will try to instantly understand the whole line as a whole.
DO NOT do this, just read a bit slower and understand what each parameter (separated by the ,) does.
This makes it MUCH less intimidating and difficult.
And even more important:
USE OTHER PEOPLE’S SCRIPTS TO LEARN FROM The reason for open source stuff like these
scripts is not just so that others can contribute to it and improve it together (well okay that’s the
main purpose haha), but many others (like me) also upload it for others to learn from or use parts
People whom are keeping new people to scripting in mind will often MASSIVELY add comments
to their code (just like i do in most stuff what i publish (not just on here)), READ THOSE COMMENTS Those often contain useful and important information on how the function(s) work.
In the end there is nothing more awesome than being able to script your own stuff, see your game,
software or any other piece of modification ‘come to life’ And secondly it’s also MUCH more convenient and faster to have the ability to add or fix your own features
Hope this post is/will be a bit helpful for some. Even if it just helps one or two people it served it’s purpose haha
EDIT: Okay appearently it’s not allowed to mention some names or sites on this forum, just hope that
the time i’ve put in putting this article together isn’t wasted by including ‘banned terms’ apparently.
If so please let me know and I will just request/delete the whole topic (not going to re-write it all just
for ‘competitor censoring’ while trying to help FiveM scripters whom are WAY MORE interested in FiveM anyway since it’s much better )
Unique supply: https://discussion board.cfx.re/t/directions-getting-started-basics/285155