Raised This Month: $100 Target: $400
 25% 

CS 1.6 Custom 3rd Person View


Post New Thread Reply   
 
Thread Tools Display Modes
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-15-2011 , 08:09   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #51

Try this :

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

#define VERSION "0.0.2"

#define MAX_PLAYERS    32

#define USE_TOGGLE 3

new g_iPlayerCamera[MAX_PLAYERS+1]

new 
g_iMaxPlayers

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

    
RegisterHam(Ham_Spawn"player""CBasePlayer_Spawn_Post"1)
    
register_forward(FM_SetView"SetView")
    
RegisterHam(Ham_Think"trigger_camera""Camera_Think")

    
g_iMaxPlayers get_maxplayers()
}

public 
CBasePlayer_Spawn_Postid )
{
    if( !
is_user_alive(id) )
    {
        return
    }

    new 
iEnt g_iPlayerCamera[id]
    if( !
pev_valid(iEnt) )
    {
        static 
iszTriggerCamera
        
if( !iszTriggerCamera )
        {
            
iszTriggerCamera engfunc(EngFunc_AllocString"trigger_camera")
        }
        
iEnt engfunc(EngFunc_CreateNamedEntityiszTriggerCamera)
        
set_kvd(0KV_ClassName"trigger_camera")
        
set_kvd(0KV_fHandled0)
        
set_kvd(0KV_KeyName"wait")
        
set_kvd(0KV_Value"999999")
        
dllfunc(DLLFunc_KeyValueiEnt0)

        
set_pev(iEntpev_spawnflagsSF_CAMERA_PLAYER_TARGET|SF_CAMERA_PLAYER_POSITION)
        
set_pev(iEntpev_flagspev(iEntpev_flags) | FL_ALWAYSTHINK)

        
dllfunc(DLLFunc_SpawniEnt)

        
g_iPlayerCamera[id] = iEnt
 
//   }

        
new Float:flMaxSpeediFlags pev(idpev_flags)
        
pev(idpev_maxspeedflMaxSpeed)

        
ExecuteHam(Ham_UseiEntididUSE_TOGGLE1.0)

        
set_pev(idpev_flagsiFlags)
        
// depending on mod, you may have to send SetClientMaxspeed here.
        // engfunc(EngFunc_SetClientMaxspeed, id, flMaxSpeed)
        
set_pev(idpev_maxspeedflMaxSpeed)
    }
}

public 
SetView(idiEnt)
{
    if( 
is_user_alive(id) )
    {
        new 
iCamera g_iPlayerCamera[id]
        if( 
iCamera && iEnt != iCamera )
        {
            new 
szClassName[16]
            
pev(iEntpev_classnameszClassNamecharsmax(szClassName))
            if( !
equal(szClassName"trigger_camera") ) // should let real cams enabled
            
{
                
engfunc(EngFunc_SetViewidiCamera// shouldn't be always needed
                
return FMRES_SUPERCEDE
            
}
        }
    }
    return 
FMRES_IGNORED
}

public 
client_disconnect(id)
{
    new 
iEnt g_iPlayerCamera[id]
    if( 
pev_valid(iEnt) )
    {
        
engfunc(EngFunc_RemoveEntityiEnt)
    }
    
g_iPlayerCamera[id] = 0
}

public 
client_putinserver(id)
{
    
g_iPlayerCamera[id] = 0
}

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

public 
Camera_ThinkiEnt )
{
    static 
id
    
if( !(id get_cam_owneriEnt )) )
    {
        return
    }

    static 
Float:fVecPlayerOrigin[3], Float:fVecCameraOrigin[3], Float:fVecAngles[3], Float:fVecBack[3]

    
pev(idpev_originfVecPlayerOrigin)
    
pev(idpev_view_ofsfVecAngles)
    
fVecPlayerOrigin[2] += fVecAngles[2]

    
pev(idpev_v_anglefVecAngles)

    
// See player from front ?
    //fVecAngles[0] = 15.0
    //fVecAngles[1] += fVecAngles[1] > 180.0 ? -180.0 : 180.0

    
angle_vector(fVecAnglesANGLEVECTOR_FORWARDfVecBack)

    
//Move back to see ourself (150 units)
    
fVecCameraOrigin[0] = fVecPlayerOrigin[0] + (-fVecBack[0] * 150.0)
    
fVecCameraOrigin[1] = fVecPlayerOrigin[1] + (-fVecBack[1] * 150.0)
    
fVecCameraOrigin[2] = fVecPlayerOrigin[2] + (-fVecBack[2] * 150.0)

    
engfunc(EngFunc_TraceLinefVecPlayerOriginfVecCameraOriginIGNORE_MONSTERSid0)
    static 
Float:flFraction
    get_tr2
(0TR_flFractionflFraction)
    if( 
flFraction != 1.0 // adjust camera place if close to a wall
    
{
        
flFraction *= 150.0
        fVecCameraOrigin
[0] = fVecPlayerOrigin[0] + (-fVecBack[0] * flFraction)
        
fVecCameraOrigin[1] = fVecPlayerOrigin[1] + (-fVecBack[1] * flFraction)
        
fVecCameraOrigin[2] = fVecPlayerOrigin[2] + (-fVecBack[2] * flFraction)
    }

    
set_pev(iEntpev_originfVecCameraOrigin)
    
set_pev(iEntpev_anglesfVecAngles)

__________________
- tired and retired -
ConnorMcLeod is offline
alfahad
Junior Member
Join Date: Aug 2011
Old 08-15-2011 , 12:01   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #52

Awesome ! thanks connermcleod
i have another request , can u make the camera angles changes when the client write /cam1 , /cam2 , /cam3 . or by menu .. thnx
alfahad is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-15-2011 , 12:11   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #53

I won't bother to do that.
If i make something one day, it will be a menu that let you choose camera view with movement keys, but for now i don't plan to make it.
__________________
- tired and retired -
ConnorMcLeod is offline
alfahad
Junior Member
Join Date: Aug 2011
Old 08-15-2011 , 12:30   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #54

Ok np , thanks anyway
alfahad is offline
Row
BANNED
Join Date: Jun 2013
Location: Romania
Old 07-14-2013 , 12:06   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #55

Why dont use SET_USER_VIEW
Row is offline
~Ice*shOt
Veteran Member
Join Date: Mar 2009
Location: Lithuania
Old 08-19-2013 , 15:32   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #56

Quote:
Differences:
- Precision where your aiming is better.
- Your model isn't alpha'd.
- Your model stutters a bit with this method.
- Doesn't require rocket.mdl (uses a weapon file from mod thats already precached)
~Ice*shOt is offline
Send a message via Skype™ to ~Ice*shOt
Old 10-15-2015, 00:58
nico_barrera
This message has been deleted by nico_barrera.
amir saiaoud
Senior Member
Join Date: May 2015
Location: essaouira , maroc
Old 02-02-2016 , 13:46   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #57

Quote:
Originally Posted by ConnorMcLeod View Post
Try this :

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

#define VERSION "0.0.2"

#define MAX_PLAYERS    32

#define USE_TOGGLE 3

new g_iPlayerCamera[MAX_PLAYERS+1]

new 
g_iMaxPlayers

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

    
RegisterHam(Ham_Spawn"player""CBasePlayer_Spawn_Post"1)
    
register_forward(FM_SetView"SetView")
    
RegisterHam(Ham_Think"trigger_camera""Camera_Think")

    
g_iMaxPlayers get_maxplayers()
}

public 
CBasePlayer_Spawn_Postid )
{
    if( !
is_user_alive(id) )
    {
        return
    }

    new 
iEnt g_iPlayerCamera[id]
    if( !
pev_valid(iEnt) )
    {
        static 
iszTriggerCamera
        
if( !iszTriggerCamera )
        {
            
iszTriggerCamera engfunc(EngFunc_AllocString"trigger_camera")
        }
        
iEnt engfunc(EngFunc_CreateNamedEntityiszTriggerCamera)
        
set_kvd(0KV_ClassName"trigger_camera")
        
set_kvd(0KV_fHandled0)
        
set_kvd(0KV_KeyName"wait")
        
set_kvd(0KV_Value"999999")
        
dllfunc(DLLFunc_KeyValueiEnt0)

        
set_pev(iEntpev_spawnflagsSF_CAMERA_PLAYER_TARGET|SF_CAMERA_PLAYER_POSITION)
        
set_pev(iEntpev_flagspev(iEntpev_flags) | FL_ALWAYSTHINK)

        
dllfunc(DLLFunc_SpawniEnt)

        
g_iPlayerCamera[id] = iEnt
 
//   }

        
new Float:flMaxSpeediFlags pev(idpev_flags)
        
pev(idpev_maxspeedflMaxSpeed)

        
ExecuteHam(Ham_UseiEntididUSE_TOGGLE1.0)

        
set_pev(idpev_flagsiFlags)
        
// depending on mod, you may have to send SetClientMaxspeed here.
        // engfunc(EngFunc_SetClientMaxspeed, id, flMaxSpeed)
        
set_pev(idpev_maxspeedflMaxSpeed)
    }
}

public 
SetView(idiEnt)
{
    if( 
is_user_alive(id) )
    {
        new 
iCamera g_iPlayerCamera[id]
        if( 
iCamera && iEnt != iCamera )
        {
            new 
szClassName[16]
            
pev(iEntpev_classnameszClassNamecharsmax(szClassName))
            if( !
equal(szClassName"trigger_camera") ) // should let real cams enabled
            
{
                
engfunc(EngFunc_SetViewidiCamera// shouldn't be always needed
                
return FMRES_SUPERCEDE
            
}
        }
    }
    return 
FMRES_IGNORED
}

public 
client_disconnect(id)
{
    new 
iEnt g_iPlayerCamera[id]
    if( 
pev_valid(iEnt) )
    {
        
engfunc(EngFunc_RemoveEntityiEnt)
    }
    
g_iPlayerCamera[id] = 0
}

public 
client_putinserver(id)
{
    
g_iPlayerCamera[id] = 0
}

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

public 
Camera_ThinkiEnt )
{
    static 
id
    
if( !(id get_cam_owneriEnt )) )
    {
        return
    }

    static 
Float:fVecPlayerOrigin[3], Float:fVecCameraOrigin[3], Float:fVecAngles[3], Float:fVecBack[3]

    
pev(idpev_originfVecPlayerOrigin)
    
pev(idpev_view_ofsfVecAngles)
    
fVecPlayerOrigin[2] += fVecAngles[2]

    
pev(idpev_v_anglefVecAngles)

    
// See player from front ?
    //fVecAngles[0] = 15.0
    //fVecAngles[1] += fVecAngles[1] > 180.0 ? -180.0 : 180.0

    
angle_vector(fVecAnglesANGLEVECTOR_FORWARDfVecBack)

    
//Move back to see ourself (150 units)
    
fVecCameraOrigin[0] = fVecPlayerOrigin[0] + (-fVecBack[0] * 150.0)
    
fVecCameraOrigin[1] = fVecPlayerOrigin[1] + (-fVecBack[1] * 150.0)
    
fVecCameraOrigin[2] = fVecPlayerOrigin[2] + (-fVecBack[2] * 150.0)

    
engfunc(EngFunc_TraceLinefVecPlayerOriginfVecCameraOriginIGNORE_MONSTERSid0)
    static 
Float:flFraction
    get_tr2
(0TR_flFractionflFraction)
    if( 
flFraction != 1.0 // adjust camera place if close to a wall
    
{
        
flFraction *= 150.0
        fVecCameraOrigin
[0] = fVecPlayerOrigin[0] + (-fVecBack[0] * flFraction)
        
fVecCameraOrigin[1] = fVecPlayerOrigin[1] + (-fVecBack[1] * flFraction)
        
fVecCameraOrigin[2] = fVecPlayerOrigin[2] + (-fVecBack[2] * flFraction)
    }

    
set_pev(iEntpev_originfVecCameraOrigin)
    
set_pev(iEntpev_anglesfVecAngles)

Can You Make It WIth Menu ? not automatic ?
__________________
amir saiaoud is offline
Send a message via Skype™ to amir saiaoud
MayroN
Junior Member
Join Date: Aug 2017
Location: Kyiv
Old 11-11-2017 , 14:04   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #58

I would like to add here that the 3rd person would be given only to Terrorists (but not to the Special Forces). How would my point be that it is necessary for the Fashion of the Dinosaurs ...

Thanks for the help
MayroN is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:26.


Powered by vBulletin®
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Theme made by Freecode