havn't posted anything in a while, here's some stuff for you niggaz
first of all, some handy but simple shit to check what game you are playing
[HIDE]
Code:
int iGame;
enum { CSS = 0, UNKNOWN = 1};
void Game()
{
if(FindWindow(0,"Counter-Strike Source"))
iGame = CSS;
if(!FindWindow(0,"Counter-Strike Source"))
iGame = UNKNOWN;
}
if(iGame == UNKNOWN)
g_pConsole->Printf("unsupported mod, game may crash!");
now, some stuff for loading/reading floats and ints
Code:
void WritePrivateProfileFloat( const char* app, const char* key, double v, const char* name )
{
char buf[ 64 ];
sprintf( buf, "%g", v );
WritePrivateProfileString( app, key, buf, name );
};
inline
double GetPrivateProfileFloat( const char* app, const char* key, double def, const char* name )
{
char buf[ 256 ];
GetPrivateProfileString( app, key, "", buf, 256, name );
if( strlen( buf ) == 0 )
return def;
else
return atof( buf );
};
inline
void WritePrivateProfileInt( const char* app, const char* key, int v, const char* name )
{
char buf[ 64 ];
sprintf( buf, "%d", v );
WritePrivateProfileString( app, key, buf, name );
};
killing a processs
Code:
void Tools::KillProcess(char *szProcess )
{
PROCESSENTRY32 pe32;
HANDLE hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
if ( hProcessSnap != INVALID_HANDLE_VALUE )
{
while ( Process32Next( hProcessSnap, &pe32 ) )
{
if ( !strcmp( pe32.szExeFile, pszProcess ) )
{
HANDLE hProcess = OpenProcess( PROCESS_TERMINATE, 0, pe32.th32ProcessID );
TerminateProcess( hProcess, 0 );
}
}
}
CloseHandle( hProcessSnap );
}
lol somthing dumb but save you stupid ppl time
Code:
#define Set_Cvar(name,command,value) ConVar *command = m_pCvar->FindVar(name); command->SetValue(value);
Set_Cvar("cl_interpolate",cl_interpolate,0);//xample
controling msn ingame?
search for the lib, i cbf to upload
Code:
#include "cMsn.h"
#include "msgrua.h"
#include "msgruaid.h"
IMessenger *pIMessenger = NULL;
void cMsn::online()
{
__log("gMsn.log","Msn Status Set to Online.");
CoInitialize(0);
CoCreateInstance(CLSID_Messenger, NULL, CLSCTX_ALL, IID_IMessenger, (void **)&pIMessenger);
pIMessenger->put_MyStatus(MISTATUS_ONLINE); // online
pIMessenger->Release();
CoUninitialize();
}
controlling WINDOW MEDIA PLAYAH
Code:
#include "cMedia.h"
#include <windows.h>//sendmsg
#include <winuser.h>
using namespace std;
#pragma warning(disable:4172)
const int MEDIA_PLAY_PAUSE = 0x00004978;
const int MEDIA_NEXTTRACK = 0x0000497B;
const int MEDIA_PREVIOUSTRACK = 0x0000497A;
const int MEDIA_STOP = 0x00004979;
HWND WMP_HANDLE = FindWindow("WMPlayerApp",NULL);//windows
const char * cMedia::WmpTitle()//windows media
{
char window_title[100],*p;
GetWindowText(WMP_HANDLE,window_title,sizeof(window_title));
p = window_title+strlen(window_title)-22;
while (p >= window_title)
{
if (!strnicmp(p,"- Windows Media Player",22)) break;
p--;
}
if (p >= window_title) p--;
while (p >= window_title && *p == ' ') p--;
*++p=0;
return window_title;
}
void cMedia::play()
{
if (WMP_HANDLE)//Windows Media Player
{
SendNotifyMessage(WMP_HANDLE, WM_COMMAND, MEDIA_PLAY_PAUSE, 0);
}
}
void cMedia::stop()
{
if (WMP_HANDLE)//Windows Media Player
{
SendNotifyMessage(WMP_HANDLE, WM_COMMAND, MEDIA_STOP, 0);
}
}
void cMedia::prevsong()
{
if (WMP_HANDLE)//Windows Media Player
{
SendNotifyMessage (WMP_HANDLE, WM_COMMAND, MEDIA_PREVIOUSTRACK, 0);
}
}
void cMedia::nextsong()
{
if (WMP_HANDLE)//Windows Media Player
{
SendNotifyMessage(WMP_HANDLE, WM_COMMAND, MEDIA_NEXTTRACK, 0);
}
}
ps. sendmessage was being a slut so I used sendnotifymessage :o
using a basic timer for text spam etc
Code:
//25 second timah
static DWORD a1 = timeGetTime() + 25000;
DWORD a2 = timeGetTime();
srand(a2);
if(a2 > a1)
{
a1 = a2 + 25000;
m_pEngine->ClientCmd("say GIMMIE JOOUR PROOFENS");
}
some of my simple ent class
Code:
int cEntity::Team(C_BaseEntity* pBaseEntity)
{
int *iTeamIndex = (int*) ((DWORD)pBaseEntity +(DWORD)0x90 );
if(*iTeamIndex == 2)//Terror
return 2;
if(*iTeamIndex == 3)//CT
return 1;
if(*iTeamIndex == 1)//Other
return 3;
}
bool cEntity::IsAlive(C_BaseEntity* pBaseEntity) //Life Check On Ents.
{
int *lifestate = (int*) ( ( DWORD )pBaseEntity + ( DWORD )0x87 );
if(lifestate == LIFE_ALIVE)
return true;
return false;
}
bool cEntity::IHaveWeapon(char* szWeapon)
{
C_BaseCombatWeapon* m_cWeapon = __hk.m_pNeeded->GetBaseCombatActiveWeapon ( __hk.m_pMyPlayer->BaseEnt() );
if (m_cWeapon){
if ( strstr(__hk.m_pModelinfo->GetModelName ( m_cWeapon->GetModel()), szWeapon))
return true;
}
return false;
}
bool cEntity::TheyHaveWeapon(char* szWeapon, C_BaseEntity* pBaseEntity)
{
C_BaseCombatWeapon* m_cWeapon = __hk.m_pNeeded->GetBaseCombatActiveWeapon( pBaseEntity );
if ( m_cWeapon )
{
if(strstr(__hk.m_pModelinfo->GetModelName ( m_cWeapon->GetModel()), szWeapon ))
return true;
}
return false;
}
credits google, core, gd, etc
[/hide]