Raised This Month: $32 Target: $400
 8% 

CS 1.6 Custom 3rd Person View


Post New Thread Reply   
 
Thread Tools Display Modes
Altecaho
Senior Member
Join Date: Oct 2010
Old 10-16-2010 , 12:32   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #41

No command to set normal view again?
Altecaho is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-16-2010 , 15:08   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #42

Quote:
Originally Posted by Altecaho View Post
No command to set normal view again?
You need to re-read the first post.
__________________
fysiks is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-26-2011 , 15:07   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #43

Quote:
Originally Posted by fysiks View Post
Any chance of a Mod independent version of this? I was testing code for TFC and changing player models and would have really liked this since I was the only person on my listen server.
Code updated, no more specific cs code (maxspeed or camera wait offset)
Camera origin adjustements in case it would be in a solid place.
Real map cameras stay usabled.

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_bInCamera
//#define MarkUserInCamera(%0)        g_bInCamera |= 1<<(%0&31)
#define ClearUserInCamera(%0)        g_bInCamera &= ~(1<<(%0&31))
#define IsUserInCamera(%0)            ( g_bInCamera & 1<<(%0&31) )
#define ToggleUserCameraState(%0)    g_bInCamera ^= 1<<(%0&31)

new g_iMaxPlayers

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

    
register_clcmd("say /cam""ClCmd_ToggleCamera")

    
g_iMaxPlayers get_maxplayers()
}

public 
ClCmd_ToggleCameraid )
{
    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
    
}

    
ToggleUserCameraStateid )
    
CheckForward()

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

    
ExecuteHamHam_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( 
IsUserInCamera(id) && 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
    ClearUserInCamera
(id)
    
CheckForward()
}

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

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)
}

CheckForward()
{
    static 
HamHook:iHhCameraThinkiFhSetView
    
if( g_bInCamera )
    {
        if( !
iFhSetView )
        {
            
iFhSetView register_forward(FM_SetView"SetView")
        }
        if( !
iHhCameraThink )
        {
            
iHhCameraThink RegisterHam(Ham_Think"trigger_camera""Camera_Think")
        }
        else
        {
            
EnableHamForwardiHhCameraThink )
        }
    }
    else
    {
        if( 
iFhSetView )
        {
            
unregister_forward(FM_SetViewiFhSetView)
            
iFhSetView 0
        
}
        if( 
iHhCameraThink )
        {
            
DisableHamForwardiHhCameraThink )
        }
    }

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 01-30-2011 at 08:36.
ConnorMcLeod is offline
Ryokin
Senior Member
Join Date: Jan 2010
Old 03-06-2011 , 05:38   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #44

Quote:
Originally Posted by ConnorMcLeod View Post
Code updated, no more specific cs code (maxspeed or camera wait offset)
Camera origin adjustements in case it would be in a solid place.
Real map cameras stay usabled.

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_bInCamera
//#define MarkUserInCamera(%0)        g_bInCamera |= 1<<(%0&31)
#define ClearUserInCamera(%0)        g_bInCamera &= ~(1<<(%0&31))
#define IsUserInCamera(%0)            ( g_bInCamera & 1<<(%0&31) )
#define ToggleUserCameraState(%0)    g_bInCamera ^= 1<<(%0&31)
 
new g_iMaxPlayers
 
public plugin_init()
{
    
register_plugin("Camera View"VERSION"ConnorMcLeod")
 
    
register_clcmd("say /cam""ClCmd_ToggleCamera")
 
    
g_iMaxPlayers get_maxplayers()
}
 
public 
ClCmd_ToggleCameraid )
{
    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
    
}
 
    
ToggleUserCameraStateid )
    
CheckForward()
 
    new 
Float:flMaxSpeediFlags pev(idpev_flags)
    
pev(idpev_maxspeedflMaxSpeed)
 
    
ExecuteHamHam_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( 
IsUserInCamera(id) && 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
    ClearUserInCamera
(id)
    
CheckForward()
}
 
public 
client_putinserver(id)
{
    
g_iPlayerCamera[id] = 0
    ClearUserInCamera
(id)
}
 
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)
}
 
CheckForward()
{
    static 
HamHook:iHhCameraThinkiFhSetView
    
if( g_bInCamera )
    {
        if( !
iFhSetView )
        {
            
iFhSetView register_forward(FM_SetView"SetView")
        }
        if( !
iHhCameraThink )
        {
            
iHhCameraThink RegisterHam(Ham_Think"trigger_camera""Camera_Think")
        }
        else
        {
            
EnableHamForwardiHhCameraThink )
        }
    }
    else
    {
        if( 
iFhSetView )
        {
            
unregister_forward(FM_SetViewiFhSetView)
            
iFhSetView 0
        
}
        if( 
iHhCameraThink )
        {
            
DisableHamForwardiHhCameraThink )
        }
    }

this's much better than OneEyed's way ?
__________________
NH4CL + NaOH -> NH3 + H2O + NaCL
Ryokin is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 03-09-2011 , 18:01   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #45

hmm can you guys make a public release of this?
fully optimized, etc?
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 04-20-2011 , 18:11   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #46

I found 4 bugs on this
1. When shooting, the bullets don't go out of the weapon model attached to the player, but from the right side of the screen

2. Entities attached to the player model can't be seen when the player is using 3rd person mode

It should be like in this video: http://www.youtube.com/user/schmurge.../1/zvsRYYXh-eQ
3. When the field of view of the player is changed, the distance between the camera and the player is changed too

4. If the camera goes outside the map(like in water or something) it won't chase the player anymore. Will make a video about this if you guys are interested on fixing the plug-in and can't understand what I'm trying to say.

And a little suggestion:
Make a custom transparency changeable by a cvar. Not being able to see through your model is quite annoying...
Attached Thumbnails
Click image for larger version

Name:	fy_snow0007.jpg
Views:	3662
Size:	45.6 KB
ID:	85033   Click image for larger version

Name:	fy_snow0009.jpg
Views:	2933
Size:	58.3 KB
ID:	85034   Click image for larger version

Name:	fy_snow0011.jpg
Views:	3747
Size:	35.1 KB
ID:	85035  
__________________

Last edited by georgik57; 04-20-2011 at 18:17.
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-21-2011 , 01:38   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #47

What about using engine set_view native ?
(Transparency would re-introduce AddToFullPack and this way is already handled by engine native)
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 04-21-2011 , 03:17   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #48

Quote:
Originally Posted by ConnorMcLeod View Post
What about using engine set_view native ?
(Transparency would re-introduce AddToFullPack and this way is already handled by engine native)
i have no idea what you're talking about
i suck at amxx scripting ^^
also another bug:
5. The camera sometimes moves by itself o_O. I mean, it shakes, and the mouse isn't moving and it isn't because of the sensor...
This is the best camera. It's not lagging the server or things like that...Please maintain it and if you want make a official release of it.
__________________

Last edited by georgik57; 04-21-2011 at 03:20.
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
zippel
Member
Join Date: Mar 2011
Location: RF
Old 04-29-2011 , 06:19   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #49

there a bug with c4. After use, player can move around in the area of ​​bombs place.
zippel is offline
Send a message via ICQ to zippel Send a message via Skype™ to zippel
alfahad
Junior Member
Join Date: Aug 2011
Old 08-14-2011 , 21:45   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #50

can someone make the plugin works without /cam command ?
alfahad 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 05:43.


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