View Single Post
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-21-2009 , 17:28   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #29

Working version with less code, with smoth moves :

PHP Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <fun>
#include <hamsandwich>

#define VERSION "0.0.1"

#define MAX_PLAYERS    32

#define    m_flWait        42

#define USE_TOGGLE 3

new g_iCam[MAX_PLAYERS+1]
new 
g_iMaxPlayers

public plugin_init()
{
    
register_plugin("Camera View"VERSION"ConnorMcLeod")

    
register_clcmd("say /cam""cam")
    
register_think("trigger_camera""Camera_Think")
    
g_iMaxPlayers get_maxplayers()
}

public 
camid )
{
    if( !
is_user_alive(id) )
    {
        return
    }
    new 
iEnt g_iCam[id]
    if( !
is_valid_ent(iEnt) )
    {
        
iEnt create_entity("trigger_camera")

        
entity_set_int(iEntEV_INT_spawnflagsSF_CAMERA_PLAYER_TARGET|SF_CAMERA_PLAYER_POSITION)

        
DispatchSpawn(iEnt)
        
set_pdata_float(iEntm_flWait999999.04)

        
g_iCam[id] = iEnt
    
}

    
ExecuteHamHam_UseiEntididUSE_TOGGLE1.0)

    
entity_set_int(idEV_INT_flagsentity_get_int(idEV_INT_flags) & ~FL_FROZEN)
    
cs_reset_user_maxspeed(id)
}

public 
client_disconnect(id)
{
    new 
iEnt g_iCam[id]
    if( !
is_valid_ent(iEnt) )
    {
        
g_iCam[id] = 0
        remove_entity
(iEnt)
    }
}

cs_reset_user_maxspeed(id)
{
    new 
Float:flMaxSpeed;
    switch ( 
get_user_weapon(id) )
    {
        case 
CSW_SG550CSW_AWPCSW_G3SG1 flMaxSpeed 210.0;
        case 
CSW_M249 flMaxSpeed 220.0;
        case 
CSW_AK47 flMaxSpeed 221.0;
        case 
CSW_M3CSW_M4A1 flMaxSpeed 230.0;
        case 
CSW_SG552 flMaxSpeed 235.0;
        case 
CSW_XM1014CSW_AUGCSW_GALILCSW_FAMAS flMaxSpeed 240.0;
        case 
CSW_P90 flMaxSpeed 245.0;
        case 
CSW_SCOUT flMaxSpeed 260.0;
        default : 
flMaxSpeed 250.0;
    }
    
set_user_maxspeed(idflMaxSpeed);
}

get_cam_owner(iEnt)
{
    static 
id
    
for(id 1id<=g_iMaxPlayersid++)
    {
        if( 
g_iCam[id] == iEnt )
        {
            return 
id
        
}
    }
    return 
0
}

public 
Camera_Think(entid)
{
    new 
id get_cam_owner(entid);
    if( !
id )
    {
        return
    }

    static 
Float:origin[3], Float:angle[3], Float:vBack[3];
    
entity_get_vectoridEV_VEC_originorigin );
    
entity_get_vectoridEV_VEC_v_angleangle );

    
angle_vectorangleANGLEVECTOR_FORWARDvBack );

    
origin[2] += 20.0//So we're closer to the eyes.

    //Move back to see ourself (150 units)
    
origin[0] += (-vBack[0] * 150.0);
    
origin[1] += (-vBack[1] * 150.0);
    
origin[2] += (-vBack[2] * 150.0);

    
entity_set_originentidorigin );
    
entity_set_vectorentidEV_VEC_anglesangle );  

    
entity_set_float(entidEV_FL_nextthinkget_gametime())

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 07-21-2009 at 17:31.
ConnorMcLeod is offline