Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!   (86,346 visits to this link)

    2. News

    1. GTA Online

      1. Find Lobbies & Players
      2. Guides & Strategies
      3. Vehicles
      4. Content Creator
      5. Help & Support
    2. Crews

      1. Events
      2. Recruitment
    1. Grand Theft Auto Series

    2. GTA Next

    3. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    4. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    5. GTA Chinatown Wars

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    9. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    12. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    3. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption 2

    2. Red Dead Redemption

    3. Rockstar Games

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Forum Support

    2. Site Suggestions

Sign in to follow this  
OfficerJohnson

Clarification on "Stepping Through" the SHV.NET Structure

Recommended Posts

OfficerJohnson

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?

Share this post


Link to post
Share on other sites
Jitnaught

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

Share this post


Link to post
Share on other sites
OfficerJohnson

 

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.

Share this post


Link to post
Share on other sites
Jitnaught

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.

Share this post


Link to post
Share on other sites
OfficerJohnson

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!

Share this post


Link to post
Share on other sites
OfficerJohnson

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?

Share this post


Link to post
Share on other sites
Jitnaught

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.