GetPlayerInfo for Source (TF2, CSS-Beta Engine)

On martes, 7 de septiembre de 2010 0 comentarios

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(pNamePCharpReturnCodeInteger): Pointercdecl;

  
// This is translated from the SDK.
  
player_info_s = ^player_info_t;
  
player_info_t packed record
    name
:             array[0..MAX_PLAYER_NAME_LENGTHof Char;
    
userID:           Integer;
    
guid:             array[0..SIGNED_GUID_LEN 1of Char;
    
friendsID:        Cardinal; { uint32 }
    
friendsName:      array[0..MAX_PLAYER_NAME_LENGTHof Char;
    
fakeplayer:       Boolean;
    
ishltv:           Boolean;
    
customFiles:      array[0..MAX_CUSTOM_FILESof Cardinal; { CRC32_t }
    
filesDownloaded:  Byte;
  
end;

  
// SDK Functions.
  
sdkIsConnected = function(): Booleanstdcall;
  
sdkGetPlayerInfo = function(ent_numIntegerpinfoplayer_info_s): Booleanstdcall;
  
sdkGetLocalPlayer = function(): Integerstdcall;

var
  
// Vars we need.
  
EngineFactoryCreateInterfaceFn;
  
pEnginePointer;

  
// SDK Functions.
  
pIsConnectedsdkIsConnected;
  
pGetPlayerInfosdkGetPlayerInfo;
  
pGetLocalPlayersdkGetLocalPlayer;
// Function to calculate the pointer to a function. function MakePointer(PtrPointerIndexDWord): Pointer; begin
  Result 
:= Pointer(Pointer(DWord(Ptr^) + Index 4)^); end;
// This is our main thread, hence the name. procedure MainThread();
var
  
hEngineTHandle;
  
pInfoplayer_info_t;
  
IInteger; 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(pEngine8);
  
pGetLocalPlayer := MakePointer(pEngine12);
  
pIsConnected := MakePointer(pEngine26);

  
// Keep on going forever :D
  
while do
  
begin
    
// If we are connected to a server.
    
if pIsConnected then
    begin
      
// Grab player information and show a messagebox.
      
pGetPlayerInfo(pGetLocalPlayer, @pInfo);
      
MessageBox(0pInfo.namenil0);
    
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(dwReasonDWord);
var
  
ThreadIDLongWord; begin
  
case dwReason of
    DLL_PROCESS_ATTACH
BeginThread(nil0, @MainThreadnil0ThreadID);
  
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