[Directions] Getting Started Basics

Hey All,

This is my attempt to help others whom are already (a bit?) familiar with programming but need some
directions to get started (“jump into”) FiveM script development. I myself am a programmer in several
languages for several years, but did had some issues in the beginning in finding the correct resources,
Natives and/or documentation.

(Yeah, maybe i didn’t looked at the right places, but it’s always helpful to have more paths to help :slight_smile: )

So I decided to make a ‘small overview’ for others to get started on basic stuff they might/will
need when starting out ‘fresh’ in FiveM or lua (assuming lua here since that’s what most will use,
although I myself also use C# a lot, I ASSUME that most here would benefit more from a lua point
of view in this ‘how-to’. (and C# programmers will know how to apply this information to C# anyway
i suppose :wink: )

New to lua or need more information on some lua functions?

First of: IF you are new to lua scripting or need some additional information I can recommend this link:
Lua Wiki

Keep in mind that not all functions might/will work for FiveM scripting but A LOT is, and it’s DEFINITELY
a useful resource for looking up functions or methods with the search function.

Next make sure to inform yourself by researching/learning from:
The official FiveM Scripting Manual
Which also covers many examples.

**Native Functions**

When interfacing with players, objects, vehicles and your “GTA world” you will need lots of
functions/natives to do so. These functions/natives are very well documented/listed at:
FiveM Native Documentation and at Dec-C NativeDb

Of course it’s highly recommended when you’re new to lua or even (game) scripting at all, to just
download some SIMPLE examples and see how they work, try changing stuff and see how it works out and reacts for you in game.

“Pro Tip:” You can actually run FiveM (The Game itself) in windowed mode by pressing left-alt+enter
When you then restart your script at the server you can instantly re-test it without the need of restarting
the whole game.

CAUTION THOUGH! When you are getting more advanced and are adding/replacing
resources or even streaming stuff like vehicles and then restart your script, it might not work as expected when restarting or even cause a crash (client side). Although this is (for now) way to detailed to explain and you SHOULD have no issues with this when you’re just starting out and finding your way.
(Since it’s definitely not the right time to start ‘messing’ with that stuff without getting the hang of the rest :wink: )

**Basic Server Commands**

The server commands are documented here FiveM Documentation
The Basic commands which are handy to know and remember:
start MyScriptName [Which is the FOLDERNAME which contains the _resource.lua and your scripts)
stop MyScriptName
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:
resmon 1

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 :wink:

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’ :slight_smile: 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 :slight_smile:

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

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 :slight_smile:

**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
Mooshe’s DevTools
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 :slight_smile:

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 :slight_smile:

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 :slight_smile:

**Final words of advice (for those whom it may concern/total new starters ;) )**

PLEASE just do yourself (and others :wink: ) 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? :wink:

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
from.

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’ :slight_smile: And secondly it’s also MUCH more convenient and faster to have the ability to add or fix your own features :slight_smile:

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

Happy Scripting,
VenomXNL

==================================================
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 :stuck_out_tongue: )

24 Likes

Thank you. Very in-depth tutorial filled with goodies. I have recently gotten into lua and this is definetly something that will help me during my journey.

1 Like

Thanks, glad it can be (a bit) of use to others :slight_smile:

1 Like

Oh also, i don’t know if you included this or not, but i’d recommend trying to make a NativeUI menu with snippets of code. For me it helped a lot.

1 Like

infinitely grateful for much information to continue on this journey

2 Likes

:pray: Thanks for your dedication to help

2 Likes

Im looking for a dev to hire for our LEO RP server if you could DM me we need help!!!

ENG/
Good evening Excuse me for disturbing you I have a question would you know how I could change the color of the sky myself to my liking on five m? As if I created a graphics pack myself, please?

FRENCH/
Bonsoir Excuse moi de te déranger j’aurais une question est-ce que tu saurais comment je pourrais modifier moi même la couleur du ciel a ma guise sur five m? Comme si je créais moi même un pack graphique stp?

Vemom How long have you been developing …

“Developing” since I was about 8 or 9 years old (which is about 28 years ago now today) or so (in DOS, started with bat/batch files and ASCII art style ‘select case’ games, then switched to QBasic, Visual Basic for dos and others). And there it basically started and from there on I basically ‘rolled’ into the rest of the stuff like C++, PHP, C#, .NET in general, embedded stuff and more :wink:

NOTE: I’m no longer active on FiveM or so though BTW, just replying every now and then when I receive a message in my inbox from the forums or Github.

Can’t find GTA5.exe file to launch FiveM

Sorry man, but I think you would need to ask help in the general FiveM forums for such problems for a broader response and/or support (if you don’t have it resolved by now yourself :slight_smile: )

Thank you for the info

1 Like