Discuss Class indexing

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

HexMurder

Arcane Hacker
Dank Tier VIP
Dank Tier Donator
Jun 7, 2012
319
7,988
22
So i have been reading a book on C# lately. Just read about abstract classes, and properties, and wanted to see if i could implement them into a simple cs:go hack. (Whether this is the proper/most efficient way to do this is not what this discussion is about, so please hold those comments.) I made an abstract class which can/will be inherited by bother the localPlayer and enemy classes:

C++:
public abstract class BasePlayer
        {
            public abstract int Base { get; }
            public int health
            {
                get
                {
                    return Engine.mem.ReadInt32(Base + Offsets.oHealth);
                }
            }
            public int team
            {
                get
                {
                    return Engine.mem.ReadInt32(Base + Offsets.oTeam);
                }
            }
            public bool bDormant
            {
                get
                {
                    return Engine.mem.ReadBool(Base + Offsets.oDormant);
                }
            }
            public Vec3 position
            {
                get
                {
                    return Engine.mem.ReadVec3(Base + Offsets.oVecOrigin);
                }
            }
        }


Then i made a localplayer class that simply inherited the BasePlayer class, and specified what the base should be.
C++:
        public class LocalPlayer : BasePlayer
        {
            public override int Base
            {
                get
                {
                    return  Engine.mem.ReadInt32(CLIENT + Offsets.dw_LocalPlayer);
                }
            }
        }
this works great. i can call localplayer.health and it returns my health perfectly.

now my problem, which i couldn't seem to figure out was this.. Basically to read the correct entity i need to use the id of said entity. i.e CLIENT + Offsets.dw_entitylist + i*0x10;
So if i was going to implement the enemy class just like the localplayer class
C++:
        public class Enemy : BasePlayer 
        {
            public override int Base
            {
                get
                {
                    return Engine.mem.ReadInt32(CLIENT + Offsets.dw_EntityList);
                }
            }
        }
Would it be possible for me to somehow have an index or something to specifiy which Enemy i am reffering to? And how can I implement my enemy class to use it like this?
C++:
        public class Enemy : BasePlayer 
        {
            public override int Base
            {
                get
                {
                    return Engine.mem.ReadInt32(CLIENT + Offsets.dw_EntityList +[COLOR="#00FF00"] i * 0x10[/COLOR]);
                }
            }
        }
Thanks guys!
 

mambda

headass
Escobar Tier VIP
Trump Tier Donator
Jun 25, 2014
2,297
37,938
269
C++:
public class Enemy : BasePlayer
{
	int index;
	Enemy( int i ): index(i) { }
	
	public override int Base
    {
		get
		{
			return Engine.mem.ReadInt32(CLIENT + Offsets.dw_EntityList + index * 0x10);
		}
	}
}
usage: new Entity( <index> ).

i.e.

C++:
for( int i = 0; i < playerCount; i++)
{
    Entities[ i ] = new Entity( i ); // will read the first entity every single time.
}
idk if that method of constructors works in C# so you can just make a regular constructor to set index to whatever the input is.
 
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods