Fix for amb343 - tfc_clearmodel didn't function as advertised.

This commit is contained in:
Steve Dudenhoeffer 2007-07-17 02:18:04 +00:00
parent 7b6d4ce699
commit 8316318c31
2 changed files with 32 additions and 1 deletions

View File

@ -22,6 +22,12 @@
#define PD_SENTRY_OWNER 83 + LINUXOFFSET #define PD_SENTRY_OWNER 83 + LINUXOFFSET
#define PD_TIMER_OWNER 932 + LINUXOFFSET #define PD_TIMER_OWNER 932 + LINUXOFFSET
// If somehow TFC updates, the following two offsets can be updated by
// disassembling CBaseEntity::KeyValuePartThree(KeyValueData_s *)
#define PD_REPLACE_MODEL 170 + LINUXOFFSET
#define PD_REPLACE_SKIN 172 + LINUXOFFSET
#define MAX_TRACE 13 #define MAX_TRACE 13
//#define NADE_OFFSET 24 //#define NADE_OFFSET 24

View File

@ -81,6 +81,30 @@ static cell AMX_NATIVE_CALL TFC_ClearModel(AMX *amx, cell *params) {
edict_t* pPlayer = INDEXENT(iIndex); edict_t* pPlayer = INDEXENT(iIndex);
if (pPlayer->pvPrivateData == NULL)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Player has no private data, cannot clear model!");
return 0;
}
// PD_REPLACE_MODEL is the string_t for the replacement model
// setting it to 0 will reset the model properly
*( (int*)pPlayer->pvPrivateData + PD_REPLACE_MODEL) = 0;
// PD_REPLACE_SKIN is the integer setting for the skin, by default
// it is 0.
*( (int*)pPlayer->pvPrivateData + PD_REPLACE_SKIN) = 0;
return 1;
/*
// the old, buggy method here
int iIndex = params[1];
CHECK_PLAYER(iIndex)
edict_t* pPlayer = INDEXENT(iIndex);
char szModel[32]; char szModel[32];
memset(szModel, 0x0, strlen(szModel)); memset(szModel, 0x0, strlen(szModel));
@ -137,6 +161,7 @@ static cell AMX_NATIVE_CALL TFC_ClearModel(AMX *amx, cell *params) {
(g_engfuncs.pfnSetClientKeyValue)(iIndex, (g_engfuncs.pfnGetInfoKeyBuffer)(pPlayer), "model", szModel); (g_engfuncs.pfnSetClientKeyValue)(iIndex, (g_engfuncs.pfnGetInfoKeyBuffer)(pPlayer), "model", szModel);
return 1; return 1;
*/
} }
// Vexd end :) // Vexd end :)