This is how I did it in my plugin:
PHP Code:
enum
{
VIEW_NONE = 0,
VIEW_3RDPERSON,
}
new g_iPlayerView[ 33 ];
public plugin_init( )
{
RegisterHam( Ham_Player_ImpulseCommands, "player", "@HamPlayerImpulseCommands_Pre", 0 );
RegisterHam( Ham_Spawn, "player", "@HamSpawn_Post", 1 );
}
public client_connect( id )
{
g_iPlayerView[ id ] = VIEW_NONE;
}
public @HamSpawn_Post( id )
{
if( is_user_alive( id ) )
{
g_iPlayerView[ id ] = VIEW_NONE;
}
return HAM_IGNORED;
}
public @HamPlayerImpulseCommands_Pre( id )
{
if( ! is_user_alive( id ) )
return HAM_IGNORED;
if( pev( id, pev_impulse ) == 201 )
{
g_iPlayerView[ id ] = g_iPlayerView[ id ] == VIEW_3RDPERSON ? VIEW_NONE : VIEW_3RDPERSON;
set_view( id, g_iPlayerView[ id ] );
set_pev( id, pev_impulse, 0 );
}
return HAM_IGNORED;
}
__________________