View Single Post
BAILOPAN
Join Date: Jan 2004
Old 05-09-2007 , 10:50   Re: [GROUP PROJECT] Help me with ideas!
Reply With Quote #3

Just a short explanation of the "bintools" extension that recently got committed. This is a C++ API to let you do something like this (pseudo code, don't yell at me for not following the API exactly). Imagine that we're trying to call CBaseEntity::GiveNamedItem:

Code:
ParamInfo params[3] = { {Param_POD, 4, 0, }, {Param_POD, 4, 0}, {Param_POD, 4, 0} };

ICallWrapper *pCall = bintools->CreateThisCall(vtblIndex, NULL, params, 3);
This dynamically generates a C function which can decode an array holding 3 parameters of 4 bytes each.

To then call said function, you can do:
Code:
unsigned char stk[4*4];
*(CBaseEntity **)(stk + 0) = pEntity;
*(const char **)(stk + 4) = "weapon_ak47";
*(bool *)(stk + 8) = false;
*(bool *)(stk + 12) = false;
pCall->Execute(stk, NULL);
__________________
egg
BAILOPAN is offline