Hi, I am going to show you how to figure out how to use the stack.
pretend L was your lua_State pointer, if you do L->luabase, then you get a pointer CBaseLuaInterface class, which contains all of your functions for that state of lua. Why does this matter? If you don't want to be a douche, then you won't use the Gayry (or blackawp) headers, and you will make the headers by yourself, and that was just a headstart in the right direction.
Stack Manipulation:
Did you know that you could use the lua stack functions without creating a function? You didn't? Well you don't know much then...
you can create a hook in C++, and call lua functions to get info you needed. For example, can you not find that pony riders name in darkrp on your esp? It might be because you are using the c++ function that reports their steam name; not their in-game name. There's a fix for that!
To find a player's name in lua, that is simple:
Code:
Entity(entindex):Nick();
-- or the real way
FindMetaTable("Player").Nick(Entity(entindex));
Now we can use the lua stack to get it into c++.
Code:
LU->PushSpecial(0); // push the global table
LU->GetField(-1, "FindMetaTable"); // get FindMetaTable off the global table
LU->PushString("Player", 0); // push the string Player
LU->Call(1, 1); // call FindMetaTable with one argument and get one return
LU->GetField(-1, "Nick"); // get FindMetaTable("Player").Nick
LU->GetField(-2, "Entity"); // get the entity function off the global table
LU->PushNumber(ply->entindex()); // push the player's entity index
LU->Call(1, 1); // pop the entindex and entity function off the table and get the return
LU->Call(1, 1); // pop the entity and the Nick function off the stack and get the return
const char* _name = LU->GetString(-1); // get the name from the return
LU->Pop(2); // pop the table and the return off the stack
and ta da now you have your in-game name
Use the stack to your advantage. Good day.