Documentation / API Reference
  • Main page
  • Natives
  • Wiki updates
    • Guides
      • 1. Introduction into scripting 2. Creating your first script 3. Globals 4. TriggerScriptEvent
    • Classes
      • Ped Player Vehicle Object

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.

  1. Go to the Scripts folder, which is located with launcher (Create a folder if it doesn't exist).

scripts_folder

  1. Create a file with extension .cpp.
    Pay attention to the file type. It should show up as a C++ Source, not a text file.

create_file_cpp

  1. Open Visual Studio Code and open your Scripts folder.

vs_open_folder

  1. Open file first.cpp(or whatever you named your script) and write our first code.

vs_first_code

Explanation

- A script function that is executed once when the script is run.


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

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

searching_setentity

And... It seems we found what we need!
Let's move on to writing code.

Result

result

Explanation

- With this function we get our Ped.

- A function to change the transparency of an Entity.


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