PDA

View Full Version : retrieving the player model and then setting a new model


nattylife
07-17-2007, 06:36 PM
greets all.
im working with the serverplugin_empty example from the SDK. i would like to get the player model name of a player who has died (there will be a listener for player_death) and then based on that model name, replace it with a new model.

so i have something like this

FireGameEvent( KeyValues * event )
{
const char * name = event->GetName();

if( FStrEq( name, "player_death") )
{
int userId = event->GetInt( "userid");
const char* text = event->GetString( "text");
Msg( "Got player_say event: userid=%i text=%s\n", userId, text);

// if we get a headshot, change the model
if( event->GetInt( "headshot" ) )
{
if( playerinfomanager )
{
//IPlayerInfo *playerinfo = playerinfomanager->GetPlayerInfo( pEdict );
//const char* s_player_model = playerinfo->GetModelName();
}
}
}
}


i think i have to get to playerinfo->GetModelName but im not sure how toget the pEdict here. is this the right way to get the model or is there an easier way?

cin8
07-19-2007, 12:46 AM
i believe you want to do something like this. i'm not sure if will work in a server plugin however.
const char *szModelName = engine->GetClientConVarValue(engine->IndexOfEdict(edict()), "cl_playermodel");
SetModel(szModelName);