by The Acid
This was made for the CS:S beta, but it should work in TF2 (since its the SDK I am using).
Código PHP:
library PlayerInfoExample;
uses
Windows;
const
// From the SDK
MAX_PLAYER_NAME_LENGTH = 32;
MAX_CUSTOM_FILES = 4;
SIGNED_GUID_LEN = 32;
type
// From the SDK
CreateInterfaceFn = function(pName: PChar; pReturnCode: Integer): Pointer; cdecl;
// This is translated from the SDK.
player_info_s = ^player_info_t;
player_info_t = packed record
name: array[0..MAX_PLAYER_NAME_LENGTH] of Char;
userID: Integer;
guid: array[0..SIGNED_GUID_LEN + 1] of Char;
friendsID: Cardinal; { uint32 }
friendsName: array[0..MAX_PLAYER_NAME_LENGTH] of Char;
fakeplayer: Boolean;
ishltv: Boolean;
customFiles: array[0..MAX_CUSTOM_FILES] of Cardinal; { CRC32_t }
filesDownloaded: Byte;
end;
// SDK Functions.
sdkIsConnected = function(): Boolean; stdcall;
sdkGetPlayerInfo = function(ent_num: Integer; pinfo: player_info_s): Boolean; stdcall;
sdkGetLocalPlayer = function(): Integer; stdcall;
var
// Vars we need.
EngineFactory: CreateInterfaceFn;
pEngine: Pointer;
// SDK Functions.
pIsConnected: sdkIsConnected;
pGetPlayerInfo: sdkGetPlayerInfo;
pGetLocalPlayer: sdkGetLocalPlayer;
// Function to calculate the pointer to a function. function MakePointer(Ptr: Pointer; Index: DWord): Pointer; begin
Result := Pointer(Pointer(DWord(Ptr^) + Index * 4)^); end;
// This is our main thread, hence the name. procedure MainThread();
var
hEngine: THandle;
pInfo: player_info_t;
I: Integer; begin
// Wait for engine to load.
while (hEngine = 0) do
begin
hEngine := GetModuleHandle('engine.dll');
Sleep(100);
end;
// Get the pointer to CreateInterface for the engine.
EngineFactory := GetProcAddress(GetModuleHandle('engine.dll'), 'CreateInterface');
// Get the pointers to the client and the engine.
pEngine := EngineFactory('VEngineClient013', 0);
// Load SDK Functions.
pGetPlayerInfo := MakePointer(pEngine, 8);
pGetLocalPlayer := MakePointer(pEngine, 12);
pIsConnected := MakePointer(pEngine, 26);
// Keep on going forever :D
while 1 = 1 do
begin
// If we are connected to a server.
if pIsConnected then
begin
// Grab player information and show a messagebox.
pGetPlayerInfo(pGetLocalPlayer, @pInfo);
MessageBox(0, pInfo.name, nil, 0);
end;
Sleep(1000); // Wait for a while before showing doing it again.
end; end;
// All we do here is start the main thread. procedure DllMain(dwReason: DWord);
var
ThreadID: LongWord; begin
case dwReason of
DLL_PROCESS_ATTACH: BeginThread(nil, 0, @MainThread, nil, 0, ThreadID);
end; end;
begin
DllProc := @DllMain;
DllMain(DLL_PROCESS_ATTACH); end.
The GetPlayerInfo command can be used on other players too, you would have to translate chunks of the SDK to create ESP though :D
0 comentarios:
Publicar un comentario