I want to create function
PHP Code:
UTIL_SetModel(CPlayer->pEntity, "path to precached model");
With apply model for the player, so i have code, which reads offets from .games.txt
PHP Code:
/** SETENTITYMODEL */
g_pZombieConfig->GetOffset("SetEntityModel", &offset);
pass[0].flags = PASSFLAG_BYVAL;
pass[0].size = sizeof(char*);
pass[0].type = PassType_Basic;
g_pSetEntityModel = bintools->CreateVCall(offset, 0, 0, NULL, pass, 1);
g_CallWrappers.push_back(g_pSetEntityModel);
And i want to create function, which will apply model
But that code bellow, don't work and crash server
Somebody can help me?
PHP Code:
/**
* @brief Set the player model.
*
* @param pEntity The entity index.
* @param sModel The path to the player model.
**/
void UTIL_SetModel(CBaseEntity *pEntity, char *sModel)
{
unsigned char vstk[sizeof(CBaseEntity *) + sizeof(char *)];
unsigned char *vptr = vstk;
*(CBaseEntity **)vptr = pEntity;
vptr += sizeof(CBaseEntity *);
*(char *)vptr = *sModel;
// Set the player model
g_pSetEntityModel->Execute(vstk, NULL);
}
For example if i use that method to pass boolean, it work great
Spoiler
PHP Code:
/**
* @brief Remove all items from the player.
*
* @param pEntity The entity index.
* @param suit If true, will remove suit.
**/
void UTIL_RemoveAllItems(CBaseEntity *pEntity, bool suit)
{
unsigned char vstk[sizeof(CBaseEntity *) + sizeof(bool)];
unsigned char *vptr = vstk;
*(CBaseEntity **)vptr = pEntity;
vptr += sizeof(CBaseEntity *);
*(bool *)vptr = suit;
// Remove all items
g_pRemoveAllItems->Execute(vstk, NULL);
}
__________________