Quantcast

Jump to content

» «
Photo

Clarification on "Stepping Through" the SHV.NET Structure

6 replies to this topic
OfficerJohnson
  • OfficerJohnson

    Crackhead

  • Members
  • Joined: 07 Jan 2018
  • United-States

#1

Posted 4 weeks ago

Hello again. Sorry to bother you all again. As usual, I'll get right to the point.

So I'm starting to get the hang of how to read the structure of how you call the functions in SHV.NET. I do have a few that still need some clarifying:

1) What is the GTA namespace? Looking through SHV.NET's documentation, I don't see it anywhere.

2) GTA.Native is technically the natives from Native DB, correct?

Okay. Now for this next part, please be aware I have basic knowledge of computer programming basics (mostly C++). What confuses me and requires some further clarification is the use of the . (Dot) operator when accessing a function under the namespace (Ex: UI.ShowSubtitle). My understanding is that we are accessing the ShowSubtitle() function under the UI namespace, correct?

Here's where there is further confusion. I have noticed some scripts w/ source code show something like "Game.Player.Character" but if I follow that structure, where is the Character part? Shouldn't it be "World.Player.Character" instead?

So to end this, if someone could help clarify how to read through the structure in a very simple (even remedial manner), it would help.

Ex: I'd like to play an anim on my PED. What would be the . (Dot) hierarchy to step through to get the function necessary for this to work?

Jitnaught
  • Jitnaught

    Grass tastes bad

  • Members
  • Joined: 24 Aug 2013
  • United-States

#2

Posted 4 weeks ago

The GTA namespace is the SHVDN API. If it's not in the documentation that's because they have a using GTA; at the top of the file so that you don't have to type it each time you want to use a class/function within it.

 

The GTA.Native namespace is for calling native functions directly. The Hash enum within the GTA.Native namespace contains all of the native functions which can be found on the NativeDB.

 

Game is a class within the GTA namespace. Player is a variable within the Game class which returns a variable of the Player type (class). The Player class contains the Character variable which returns a variable of the Ped type.

 

Play animation:

Game.Player.Character.Task.PlayAnimation(...); //replace ... with necessary parameters

OfficerJohnson
  • OfficerJohnson

    Crackhead

  • Members
  • Joined: 07 Jan 2018
  • United-States

#3

Posted 4 weeks ago

 

The GTA namespace is the SHVDN API. If it's not in the documentation that's because they have a using GTA; at the top of the file so that you don't have to type it each time you want to use a class/function within it.

 

The GTA.Native namespace is for calling native functions directly. The Hash enum within the GTA.Native namespace contains all of the native functions which can be found on the NativeDB.

 

Game is a class within the GTA namespace. Player is a variable within the Game class which returns a variable of the Player type (class). The Player class contains the Character variable which returns a variable of the Ped type.

 

Play animation:

Game.Player.Character.Task.PlayAnimation(...); //replace ... with necessary parameters

Okay. Well this is where the confusion lies.

 

I am currently looking over the github of SHV.NET. I see two folders: "scripting" and "core". Under scripting, there is a "Game" folder. Under that, I see a Game.cs. In order to find "Game.Player.Character.Task. PlayAnimation", where should I be looking? Apologies for my ignorance. This was the initial point of the topic: to learn how to navigate to these areas when I come across them in source code scripts.


Jitnaught
  • Jitnaught

    Grass tastes bad

  • Members
  • Joined: 24 Aug 2013
  • United-States

#4

Posted 4 weeks ago

You're looking at version 3 of the source code which is not the current implementation. You should look at version 2 instead (until v3 is released) since v3 has capabilities v2 doesn't.

 

The easiest way to find where something is in the source code is simply to just search for it (e.g. search for "PlayAnimation").

 

Or you can assume that ".Task" returns something from the "Tasks.cpp" file and search for PlayAnimation there directly.

 

To find it manually without knowledge of SHVDN you would have to look through each class's file, starting from the beginning. First you look through the Game.cpp file where you would find the Player variable is of the type Player. Now you go in the Player.cpp file and search for Character which you would find out is of the Ped type. Next go to the Ped.cpp file and search for Task, which would tell you that it returns _tasks, which is of type Tasks. That leads you to Tasks.cpp which contains the PlayAnimation function.

  • OfficerJohnson likes this

OfficerJohnson
  • OfficerJohnson

    Crackhead

  • Members
  • Joined: 07 Jan 2018
  • United-States

#5

Posted 4 weeks ago

You're looking at version 3 of the source code which is not the current implementation. You should look at version 2 instead (until v3 is released) since v3 has capabilities v2 doesn't.

 

The easiest way to find where something is in the source code is simply to just search for it (e.g. search for "PlayAnimation").

 

Or you can assume that ".Task" returns something from the "Tasks.cpp" file and search for PlayAnimation there directly.

 

To find it manually without knowledge of SHVDN you would have to look through each class's file, starting from the beginning. First you look through the Game.cpp file where you would find the Player variable is of the type Player. Now you go in the Player.cpp file and search for Character which you would find out is of the Ped type. Next go to the Ped.cpp file and search for Task, which would tell you that it returns _tasks, which is of type Tasks. That leads you to Tasks.cpp which contains the PlayAnimation function.

Ohhhhhhhhhhhhhhhhh...

See, this further shows my ignorance. I am not very familiar with GitHub at all. If you didn't tell me I was in the wrong version (and I didn't notice the little branch selection), then I probably never would have noticed that and would have continued to struggle. This was a HUUUUUUUUGE HELP!


OfficerJohnson
  • OfficerJohnson

    Crackhead

  • Members
  • Joined: 07 Jan 2018
  • United-States

#6

Posted 4 weeks ago

Okay. Been rereading your comments, @Jitnaught , and I think I'm getting why we say "Game.Player.Character.Task.PlayAnim()."

When I look under "Game.hpp", there's a "^Player" variable. When I look at the cpp, it says "gcnew Player", so if I see this "^" symbol, it means it will return a class or references a class?

That would explain why this makes sense then:

"Game.Player.Character.CurrentVehicle"

According to the logic, I'm able to access a member function of the Vehicle class, right?

---------------------------------------
Further, so "using" makes us able to shorthand our calls, correct?

Using GTA;
"Game.Player.Character.Task.PlayAnim"

Using GTA;
UsingGTA.Game;
"Player.Character.Task.PlayAnim"

These two would lead to the same thing, right?

Jitnaught
  • Jitnaught

    Grass tastes bad

  • Members
  • Joined: 24 Aug 2013
  • United-States

#7

Posted 4 weeks ago

The ^ is C++ /CLR syntax for a reference to an object on the managed heap. gcnew creates an object on the heap and returns a reference. C# does not have ^ (all objects are created on the managed heap) so it's best to just ignore it, and gcnew is just new in C#.

 

Yes you would be able to access any variables, functions, and events of the instance of that class.

 

Correct, using makes it so you don't have to type the namespace every time you want to use a class from it. This doesn't work for classes though unless you use using static instead.

using static GTA.Math;

This only works for classes with static members within it, i.e. a class which you don't have to instantiate to use it's members. GTA.Game would be one of those, but GTA.Vehicle would not since it has to be instantiated to be used.

Read up on it here.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users