Globals
This guide is uncompleted.
Example
Write values into global (All types).
Read value from global.
Local
Before you can create your first script, make sure you complete the first step.
- Go to the
Scripts
folder, which is located with launcher (Create a folder if it doesn't exist).
- Create a file with extension
.cpp
.
Pay attention to the file type. It should show up as aC++ Source
, not a text file.
- Open
Visual Studio Code
and open yourScripts
folder.
- Open file
first.cpp
(or whatever you named your script) and write our first code.
Explanation
- A script function that is executed once when the script is run.
- Let's get to the features of the game.
And so, now let's write something interesting.
For example, I wanted to make Player "semi-visible".
To do this, I will go to the page with functions and write in the search something like SetPlayer...
But the function we are trying to find is not here.
Let's try to go down one level and look for something more extensive, suitable not only for the players.
The Grand Theft Auto V
has different kinds of objects, functions for which we can use.
Entity
- This is the base essence of the game. Every object/ped/vehicle and etc is an Entity.
Object
- Object of the world or created by any scripts. They can be dynamic or static.
Ped
- From the word pedestrian. Bots that do not have network data (if we are talking about GTA Online
).
Player
- Our and network players. Have unique functions (namespace PLAYER
), relative to ordinary peds.
Hash
- Usually these are the names of vehicles/weapons/models and various objects in numerical format.
Cam/Camera
- Just cameras.
Pickup
- Highlighted objects that can be picked up. Like weapons or money/collectable items.
Blip
- Marks on the map and radar.
Having an idea about this, let's try to write in the search SetEntity...
And... It seems we found what we need!
Let's move on to writing code.
Result
Explanation
- With this function we get our Ped
.
- A function to change the transparency of an Entity
.
- End of the lesson.
Today we learned how to create scripts, studied the types of variables and had a little fun with code :)
Good work!
TriggerScriptEvent
This guide is uncompleted.
Example
Ped
Used in PedAt function.
Ped
Used in PlayerAt function.
Vehicle
Used in VehicleAt function.
Vehicle
Used in ObjectAt function.