AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Code Snippets/Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=83)
-   -   CS 1.6 Custom 3rd Person View (https://forums.alliedmods.net/showthread.php?t=65427)

OneEyed 01-08-2008 07:04

CS 1.6 Custom 3rd Person View
 
1 Attachment(s)
Hey guys, I was messing around and made my own 3rd person camera. This camera has several different things compared with using set_view from engine module.

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)

Heres the code using ENGINE module. It can be converted to FAKEMETA tho.

Code:
//Call this wherever you want. Create_PlayerCamera( id ) {     new entid;     while( (entid = find_ent_by_class(entid, "PlayerCamera")) != 0)         if( entity_get_edict( entid, EV_ENT_owner ) == id )         {             attach_view( id, entid );             return;         }             entid = create_entity("info_target");             if(entid)     {         entity_set_string(entid,EV_SZ_classname,"PlayerCamera");         entity_set_model(entid,"models/w_usp.mdl");         entity_set_int( entid, EV_INT_solid, SOLID_TRIGGER);         entity_set_int( entid, EV_INT_movetype, MOVETYPE_FLY );                  //Set owner         entity_set_edict( entid, EV_ENT_owner, id );         //Don't draw         entity_set_int( entid, EV_INT_rendermode, kRenderTransTexture);         entity_set_float( entid, EV_FL_renderamt, 0.0);         //Attach our view to this entity.         attach_view( id, entid );         //Think!         entity_set_float( entid, EV_FL_nextthink, get_gametime() );     }    } //Requires registering a Think method for "PlayerCamera" entity. // OR you could save the camera's entity ID in the function above // and call this in client_PostThink or wherever that gets called alot. public Think_PlayerCamera( entid ) {     new id = entity_get_edict( entid, EV_ENT_owner );         //Kill our entity if we hit USE key     new buttons = entity_get_int( id, EV_INT_button );     if(buttons & IN_USE)     {         attach_view( id, id );         remove_entity(entid);         return;     }     new Float:origin[3], Float:angle[3], Float:vBack[3];     entity_get_vector( id, EV_VEC_origin, origin );     entity_get_vector( id, EV_VEC_v_angle, angle );     angle_vector( angle, ANGLEVECTOR_FORWARD, vBack );     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_origin( entid, origin );     entity_set_vector( entid, EV_VEC_angles, angle );            //For thinking only     entity_set_float( entid, EV_FL_nextthink, get_gametime() ); }

That's it. You can change how the player can turn this off if you don't want to use my USE key method, just copy attach_view( id, id ); and remove_entity(entid); where you want to do it.

Here's a screenshot:

Alka 01-08-2008 07:53

Re: CS 1.6 Custom 3rd Person View
 
wow, this is so cool, and with fakemeta, this will be awesome. Good Job OneEyed. :wink:

Arkshine 01-08-2008 12:53

Re: CS 1.6 Custom 3rd Person View
 
Fakemeta way.

Code:
    #include <amxmodx>     #include <fakemeta>     new const g_sCamclass[] = "PlayerCamera";     public plugin_init()     {         register_clcmd( "say /cam", "cmdCam" );         register_forward( FM_Think, "Think_PlayerCamera" );     }     public cmdCam( id )         Create_PlayerCamera( id );     Create_PlayerCamera( id )     {         new iEnt; static const sClassname[] = "classname";         while( ( iEnt = engfunc( EngFunc_FindEntityByString, iEnt, sClassname, g_sCamclass ) ) != 0 )         {             if( pev( iEnt, pev_owner) == id )             {                 engfunc( EngFunc_SetView, id, iEnt );                 return;             }         }         static const sInfo_target[] = "info_target";         iEnt = engfunc( EngFunc_CreateNamedEntity, engfunc( EngFunc_AllocString, sInfo_target ) )         if( !iEnt )             return;                 static const sCam_model[] = "models/w_usp.mdl";         set_pev( iEnt, pev_classname, g_sCamclass );         engfunc( EngFunc_SetModel, iEnt, sCam_model );         set_pev( iEnt, pev_solid, SOLID_TRIGGER );         set_pev( iEnt, pev_movetype, MOVETYPE_FLY );         set_pev( iEnt, pev_owner, id );         set_pev( iEnt, pev_rendermode, kRenderTransTexture );         set_pev( iEnt, pev_renderamt, 0.0 );         engfunc( EngFunc_SetView, id, iEnt );         set_pev( iEnt, pev_nextthink, get_gametime() );     }     public Think_PlayerCamera( iEnt )     {         static sClassname[32];         pev( iEnt, pev_classname, sClassname, sizeof sClassname - 1 );         if( !equal( sClassname, g_sCamclass ) )             return FMRES_IGNORED;         static iOwner;         iOwner = pev( iEnt, pev_owner );         if( !is_user_alive( iOwner ) )             return FMRES_IGNORED;         static iButtons;         iButtons = pev( iOwner, pev_button );         if( iButtons & IN_USE )         {             engfunc( EngFunc_SetView, iOwner, iOwner );             engfunc( EngFunc_RemoveEntity, iEnt );             return FMRES_IGNORED;         }         static Float:fOrigin[3], Float:fAngle[3];         pev( iOwner, pev_origin, fOrigin );         pev( iOwner, pev_v_angle, fAngle );         static Float:fVBack[3];         angle_vector( fAngle, ANGLEVECTOR_FORWARD, fVBack );         fOrigin[2] += 20.0;         fOrigin[0] += ( -fVBack[0] * 150.0 );         fOrigin[1] += ( -fVBack[1] * 150.0 );         fOrigin[2] += ( -fVBack[2] * 150.0 );         engfunc( EngFunc_SetOrigin, iEnt, fOrigin );         set_pev( iEnt, pev_angles, fAngle );         set_pev( iEnt, pev_nextthink, get_gametime() );         return FMRES_HANDLED;     }

XxAvalanchexX 01-08-2008 14:36

Re: CS 1.6 Custom 3rd Person View
 
I'm jealous that you were able to get attach_view to work. Good job!

mut2nt 09-24-2008 15:35

Re: CS 1.6 Custom 3rd Person View
 
and how can i set it to normal?

Emp` 09-24-2008 15:38

Re: CS 1.6 Custom 3rd Person View
 
engine:
Code:

        attach_view( id, id );
        remove_entity(entid);

fakemeta:
Code:

            engfunc( EngFunc_SetView, iOwner, iOwner );
            engfunc( EngFunc_RemoveEntity, iEnt );


mut2nt 09-24-2008 15:46

Re: CS 1.6 Custom 3rd Person View
 
i get it :*! 10x!

niFe 02-12-2009 01:04

Re: CS 1.6 Custom 3rd Person View
 
ohhh yes oneEyed!! :D

ot_207 04-17-2009 11:47

Re: CS 1.6 Custom 3rd Person View
 
Here is my method, improved some things :), the model doesn't shake anymore.

PHP Code:

#include <amxmodx>
#include <engine>

new const pl_cm_class[] = "PlayerCamera"

public plugin_init()
{
    
register_clcmd"say /cam""cmdCam" )
    
register_think(pl_cm_class,"Think_PlayerCamera")
}

public 
cmdCam(id)
    
Create_PlayerCamera(id)

Create_PlayerCamera(id)
{
    new 
ent = -1
    
while ((ent find_ent_by_class(ent,pl_cm_class)) != 0)
    {
        if (
entity_get_edict(ent,EV_ENT_owner) == id)
        {
            
attach_view(id ent)
            return
        }
    }
    
ent create_entity("info_target")
    
    if( !
ent )
        return;
    
    
entity_set_string(entEV_SZ_classnamepl_cm_class)
    
    
entity_set_model(ent"models/w_usp.mdl")
    
    
entity_set_byte(entEV_INT_solidSOLID_TRIGGER)
    
entity_set_int(entEV_INT_movetypeMOVETYPE_FLYMISSILE)
    
    
entity_set_edict(entEV_ENT_ownerid)
    
    
entity_set_int(ent,EV_INT_rendermodekRenderTransTexture)
    
entity_set_float(entEV_FL_renderamt0.0 )
    
    
attach_view(id,ent)
    
entity_set_float(entEV_FL_nextthinkget_gametime())
}

public 
Think_PlayerCamera(ent)
{
    static 
owner
    owner 
entity_get_edict(ent,EV_ENT_owner)
    
    static 
iButtons;
    
iButtons entity_get_int(ownerEV_INT_button)
    
    if( 
iButtons IN_USE  || !is_user_alive(owner))
    {
        
attach_view(owner,owner)
        
remove_entity(ent)
        return 
PLUGIN_CONTINUE;
    }
    
    
    static 
Float:origin[3], Float:fAngle[3],Float:origin2[3];
    
entity_get_vector(owner,EV_VEC_origin,origin)
    
entity_get_vector(owner,EV_VEC_v_angle,fAngle)
    
    
origin2[0] = origin[0]
    
origin2[1] = origin[1]
    
origin2[2] = origin[2]
    
    static 
Float:fVBack[3];
    
angle_vectorfAngleANGLEVECTOR_FORWARDfVBack );
    
    
origin[2] += 20.0;
    
    
origin[0] += ( -fVBack[0] * 150.0 );
    
origin[1] += ( -fVBack[1] * 150.0 );
    
origin[2] += ( -fVBack[2] * 150.0 );
    
    
trace_line(owner,origin2,origin,origin)
    
    
entity_set_vector(ent,EV_VEC_origin,origin)
    
    
entity_get_vector(owner,EV_VEC_velocity,origin2)
    
entity_set_vector(ent,EV_VEC_velocity,origin2)
    
    
entity_set_vector(ent,EV_VEC_angles,fAngle)
    
entity_set_float(entEV_FL_nextthinkget_gametime())
    
    return 
PLUGIN_CONTINUE;



Emp` 04-17-2009 14:39

Re: CS 1.6 Custom 3rd Person View
 
Quote:

Originally Posted by ot_207 (Post 807584)
Here is my method, improved some things :), the model doesn't shake anymore.

Is there a reason for changing MOVETYPE_FLY to MOVETYPE_FLYMISSILE?

niFe 04-17-2009 14:52

Re: CS 1.6 Custom 3rd Person View
 
Quote:

Originally Posted by ot_207 (Post 807584)
Here is my method, improved some things :), the model doesn't shake anymore.

PHP Code:

#include <amxmodx>
#include <engine>

new const pl_cm_class[] = "PlayerCamera"

public plugin_init()
{
    
register_clcmd"say /cam""cmdCam" )
    
register_think(pl_cm_class,"Think_PlayerCamera")
}

public 
cmdCam(id)
    
Create_PlayerCamera(id)

Create_PlayerCamera(id)
{
    new 
ent = -1
    
while ((ent find_ent_by_class(ent,pl_cm_class)) != 0)
    {
        if (
entity_get_edict(ent,EV_ENT_owner) == id)
        {
            
attach_view(id ent)
            return
        }
    }
    
ent create_entity("info_target")
    
    if( !
ent )
        return;
    
    
entity_set_string(entEV_SZ_classnamepl_cm_class)
    
    
entity_set_model(ent"models/w_usp.mdl")
    
    
entity_set_byte(entEV_INT_solidSOLID_TRIGGER)
    
entity_set_int(entEV_INT_movetypeMOVETYPE_FLYMISSILE)
    
    
entity_set_edict(entEV_ENT_ownerid)
    
    
entity_set_int(ent,EV_INT_rendermodekRenderTransTexture)
    
entity_set_float(entEV_FL_renderamt0.0 )
    
    
attach_view(id,ent)
    
entity_set_float(entEV_FL_nextthinkget_gametime())
}

public 
Think_PlayerCamera(ent)
{
    static 
owner
    owner 
entity_get_edict(ent,EV_ENT_owner)
    
    static 
iButtons;
    
iButtons entity_get_int(ownerEV_INT_button)
    
    if( 
iButtons IN_USE  || !is_user_alive(owner))
    {
        
attach_view(owner,owner)
        
remove_entity(ent)
        return 
PLUGIN_CONTINUE;
    }
    
    
    static 
Float:origin[3], Float:fAngle[3],Float:origin2[3];
    
entity_get_vector(owner,EV_VEC_origin,origin)
    
entity_get_vector(owner,EV_VEC_v_angle,fAngle)
    
    
origin2[0] = origin[0]
    
origin2[1] = origin[1]
    
origin2[2] = origin[2]
    
    static 
Float:fVBack[3];
    
angle_vectorfAngleANGLEVECTOR_FORWARDfVBack );
    
    
origin[2] += 20.0;
    
    
origin[0] += ( -fVBack[0] * 150.0 );
    
origin[1] += ( -fVBack[1] * 150.0 );
    
origin[2] += ( -fVBack[2] * 150.0 );
    
    
trace_line(owner,origin2,origin,origin)
    
    
entity_set_vector(ent,EV_VEC_origin,origin)
    
    
entity_get_vector(owner,EV_VEC_velocity,origin2)
    
entity_set_vector(ent,EV_VEC_velocity,origin2)
    
    
entity_set_vector(ent,EV_VEC_angles,fAngle)
    
entity_set_float(entEV_FL_nextthinkget_gametime())
    
    return 
PLUGIN_CONTINUE;




yoh you are awesome thanks! karmaed

PvtSmithFSSF 04-17-2009 15:41

Re: CS 1.6 Custom 3rd Person View
 
Nice =O

ot_207 04-18-2009 03:52

Re: CS 1.6 Custom 3rd Person View
 
Quote:

Originally Posted by Emp` (Post 807749)
Is there a reason for changing MOVETYPE_FLY to MOVETYPE_FLYMISSILE?

The reason for setting it is because MOVETYPE_FLY doesn't allow the camera to move (set velocity)

ZoRaN 05-12-2009 07:35

Re: CS 1.6 Custom 3rd Person View
 
Can somebody make this to force the camera on player? and to don't write /cam! thx

ot_207 05-12-2009 17:33

Re: CS 1.6 Custom 3rd Person View
 
add this to your code
PHP Code:

// plugin init
RegisterHam(Ham_Spawn"player""fw_spawn_post"1)

public 
fw_spawn_post(id)
{
 if (!
is_user_alive)
  return 
HAM_IGNORED
 
 client_cmd
(id"say /cam")
 
 return 
HAM_IGNORED


Dont forget to remove the moment when the USE key is checked!
That's all!

Exolent[jNr] 05-12-2009 18:49

Re: CS 1.6 Custom 3rd Person View
 
Quote:

Originally Posted by ot_207 (Post 826447)
add this to your code
PHP Code:

// plugin init
RegisterHam(Ham_Spawn"player""fw_spawn_post"1)

public 
fw_spawn_post(id)
{
 if (!
is_user_alive)
  return 
HAM_IGNORED
 
 client_cmd
(id"say /cam")
 
 return 
HAM_IGNORED


Dont forget to remove the moment when the USE key is checked!
That's all!

Why not just modify your original code?

PHP Code:

#include <amxmodx>
#include <engine>
#include <hamsandwich>

new const pl_cm_class[] = "PlayerCamera"

new g_remove[33]

public 
plugin_init()
{
    
//register_clcmd( "say /cam", "cmdCam" )
    
RegisterHam(Ham_Spawn"player""FwdPlayerSpawn"1)
    
RegisterHam(Ham_Killed"player""FwdPlayerDeath"1)
    
register_think(pl_cm_class,"Think_PlayerCamera")
}

public 
client_disconnect(client)
{
    
g_remove[client] = 1
}

public 
FwdPlayerSpawn(id)
{
    if( 
is_user_alive(id) )
    {
        
Create_PlayerCamera(id)
    }
}

public 
FwdPlayerDeath(client)
{
    
g_remove[client] = 1
}

Create_PlayerCamera(id)
{
    new 
ent = -1
    
while ((ent find_ent_by_class(ent,pl_cm_class)) != 0)
    {
        if (
entity_get_edict(ent,EV_ENT_owner) == id)
        {
            
attach_view(id ent)
            return
        }
    }
    
ent create_entity("info_target")
    
    if( !
ent )
        return;
    
    
entity_set_string(entEV_SZ_classnamepl_cm_class)
    
    
entity_set_model(ent"models/w_usp.mdl")
    
    
entity_set_byte(entEV_INT_solidSOLID_TRIGGER)
    
entity_set_int(entEV_INT_movetypeMOVETYPE_FLYMISSILE)
    
    
entity_set_edict(entEV_ENT_ownerid)
    
    
entity_set_int(ent,EV_INT_rendermodekRenderTransTexture)
    
entity_set_float(entEV_FL_renderamt0.0 )
    
    
attach_view(id,ent)
    
entity_set_float(entEV_FL_nextthinkget_gametime())
}

public 
Think_PlayerCamera(ent)
{
    static 
owner
    owner 
entity_get_edict(ent,EV_ENT_owner)
    
    if( 
g_remove[owner] )
    {
        
g_remove[owner] = 0
        attach_view
(owner,owner)
        
remove_entity(ent)
        return 
PLUGIN_CONTINUE;
    }
    
    static 
Float:origin[3], Float:fAngle[3],Float:origin2[3];
    
entity_get_vector(owner,EV_VEC_origin,origin)
    
entity_get_vector(owner,EV_VEC_v_angle,fAngle)
    
    
origin2[0] = origin[0]
    
origin2[1] = origin[1]
    
origin2[2] = origin[2]
    
    static 
Float:fVBack[3];
    
angle_vectorfAngleANGLEVECTOR_FORWARDfVBack );
    
    
origin[2] += 20.0;
    
    
origin[0] += ( -fVBack[0] * 150.0 );
    
origin[1] += ( -fVBack[1] * 150.0 );
    
origin[2] += ( -fVBack[2] * 150.0 );
    
    
trace_line(owner,origin2,origin,origin)
    
    
entity_set_vector(ent,EV_VEC_origin,origin)
    
    
entity_get_vector(owner,EV_VEC_velocity,origin2)
    
entity_set_vector(ent,EV_VEC_velocity,origin2)
    
    
entity_set_vector(ent,EV_VEC_angles,fAngle)
    
entity_set_float(entEV_FL_nextthinkget_gametime())
    
    return 
PLUGIN_CONTINUE;



ot_207 05-13-2009 00:50

Re: CS 1.6 Custom 3rd Person View
 
Because I wanted to make him think, not to give simply the code in his hands ;).

ZoRaN 05-13-2009 07:30

Re: CS 1.6 Custom 3rd Person View
 
its not working,when i enter in game and select ct or t its blocked.
[IMG]http://img9.**************/my.php?image=dontwork.jpg[/IMG][IMG]http://img9.**************/img9/4864/dontwork.th.jpg[/IMG]

[IMG]http://img9.**************/my.php?image=dontwork.jpg[/IMG]

ZoRaN 05-15-2009 08:47

Re: CS 1.6 Custom 3rd Person View
 
here is the error.i run the plugin in debug mode.
[ENGINE] Invalid player 1 (not in-game)
[AMXX] Run time error 10: native error (native "attach_view")
[AMXX] [0] cam.sma::Create_PlayerCamera (line 60)
[AMXX] [1] cam.sma::FwdPlayerSpawn (line 24)

Arkshine 05-15-2009 10:49

Re: CS 1.6 Custom 3rd Person View
 
Change

Code:
public FwdPlayerSpawn(id) {     Create_PlayerCamera(id) }

by

Code:
public FwdPlayerSpawn(id) {     if ( is_user_alive( id ) ) Create_PlayerCamera(id) }

Exolent[jNr] 05-15-2009 15:37

Re: CS 1.6 Custom 3rd Person View
 
Quote:

Originally Posted by arkshine (Post 827912)
Change

Code:
public FwdPlayerSpawn(id) {     Create_PlayerCamera(id) }

by

Code:
public FwdPlayerSpawn(id) {     if ( is_user_alive( id ) ) Create_PlayerCamera(id) }

Oops. Forgot about that.

ZoRaN 05-16-2009 05:12

Re: CS 1.6 Custom 3rd Person View
 
thx its working.

kishorawake 05-22-2009 10:35

Re: CS 1.6 Custom 3rd Person View
 
i m going a bit noob ,tthis file is not compiling with1.81 and amxx file cannot be created can u plz post teh amxx file be helpfull

kishorawake 05-22-2009 10:35

Re: CS 1.6 Custom 3rd Person View
 
dear moderator can you just post the amxx file for it as it is not locally compiling

Driving To Heaven 06-26-2009 05:34

Re: CS 1.6 Custom 3rd Person View
 
I need 3Dwiew. When press e, not show normal wiew.
Good player model.
Good crosshair.

This code. When press e, not show normal wiew
But bad player model and crosshair not up when shooting.

PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <engine>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "tpt"

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
RegisterHamHam_Spawn"player""fwSpawnPost")
}

public 
plugin_precache() precache_model("models/rpgrocket.mdl")

public 
fwSpawnPostid )
    if( 
is_user_aliveid ) ) set_viewidCAMERA_3RDPERSON 

This code. When press e, show normal wiew.
But good player model, and good crosshair.

PHP Code:

#include <amxmodx> 
#include <hamsandwich> 
#include <engine> 

#define PLUGIN "thirdperson" 
#define VERSION "1.0" 
#define AUTHOR "" 

new const pl_cm_class[] = "PlayerCamera" 

public plugin_init() 

    
register_pluginPLUGINVERSIONAUTHOR 
    
register_thinkpl_cm_class"Think_PlayerCamera" 
    
RegisterHam(Ham_Spawn"player""fwHamSpawn"1


public 
fwHamSpawnid 
    if( 
is_user_aliveid ) ) Create_PlayerCameraid ); 

Create_PlayerCamera(id)  
{  
    new 
ent = -1  
    
while ((ent find_ent_by_class(ent,pl_cm_class)) != 0)  
    {  
        if (
entity_get_edict(ent,EV_ENT_owner) == id)  
        {  
            
attach_view(id ent)  
            return  
        }  
    }  
    
ent create_entity("info_target")  
     
    if( !
ent 
        return;  
     
    
entity_set_string(entEV_SZ_classnamepl_cm_class)  
     
    
entity_set_model(ent"models/w_usp.mdl")  
     
    
entity_set_byte(entEV_INT_solidSOLID_TRIGGER)  
    
entity_set_int(entEV_INT_movetypeMOVETYPE_FLYMISSILE)  
     
    
entity_set_edict(entEV_ENT_ownerid)  
     
    
entity_set_int(ent,EV_INT_rendermodekRenderTransTexture)  
    
entity_set_float(entEV_FL_renderamt0.0 )  
     
    
attach_view(id,ent)  
    
entity_set_float(entEV_FL_nextthinkget_gametime())  
}  

public 
Think_PlayerCamera(ent)  
{  
    static 
owner  
    owner 
entity_get_edict(ent,EV_ENT_owner)  
     
    static 
iButtons;  
    
iButtons entity_get_int(ownerEV_INT_button)  
     
    if( 
iButtons IN_USE  || !is_user_alive(owner))  
    {  
        
attach_view(owner,owner)  
        
remove_entity(ent)  
        return 
PLUGIN_CONTINUE;  
    }  
     
     
    static 
Float:origin[3], Float:fAngle[3],Float:origin2[3];  
    
entity_get_vector(owner,EV_VEC_origin,origin)  
    
entity_get_vector(owner,EV_VEC_v_angle,fAngle)  
     
    
origin2[0] = origin[0]  
    
origin2[1] = origin[1]  
    
origin2[2] = origin[2]  
     
    static 
Float:fVBack[3];  
    
angle_vectorfAngleANGLEVECTOR_FORWARDfVBack );  
     
    
origin[2] += 20.0;  
     
    
origin[0] += ( -fVBack[0] * 150.0 );  
    
origin[1] += ( -fVBack[1] * 150.0 );  
    
origin[2] += ( -fVBack[2] * 150.0 );  
     
    
trace_line(owner,origin2,origin,origin)  
     
    
entity_set_vector(ent,EV_VEC_origin,origin)  
     
    
entity_get_vector(owner,EV_VEC_velocity,origin2)  
    
entity_set_vector(ent,EV_VEC_velocity,origin2)  
     
    
entity_set_vector(ent,EV_VEC_angles,fAngle)  
    
entity_set_float(entEV_FL_nextthinkget_gametime())  
     
    return 
PLUGIN_CONTINUE;  



vermillioN25 07-08-2009 10:38

Re: CS 1.6 Custom 3rd Person View
 
Whats better? Fakemeta or engine?

@Driving to Heaven
Well, I'm not a good script, so try this:

Code:

#include <amxmodx>
#include <engine>

#define PLUGIN "3rd Camera View"
#define VERSION "1.0"
#define AUTHOR ""

new const pl_cm_class[] = "PlayerCamera"

public plugin_init()
{
    register_clcmd( "say /cam", "cmdCam" )
    register_think(pl_cm_class,"Think_PlayerCamera")
}

public cmdCam(id)
    Create_PlayerCamera(id)

Create_PlayerCamera(id)
{
    new ent = -1
    while ((ent = find_ent_by_class(ent,pl_cm_class)) != 0)
    {
        if (entity_get_edict(ent,EV_ENT_owner) == id)
        {
        attach_view(id , ent)
        return
        }
    }
    ent = create_entity("info_target")
   
    if( !ent )
    return;
   
    entity_set_string(ent, EV_SZ_classname, pl_cm_class)
   
    entity_set_model(ent, "models/w_usp.mdl")
   
    entity_set_byte(ent, EV_INT_solid, SOLID_TRIGGER)
    entity_set_int(ent, EV_INT_movetype, MOVETYPE_FLYMISSILE)
   
    entity_set_edict(ent, EV_ENT_owner, id)
   
    entity_set_int(ent,EV_INT_rendermode, kRenderTransTexture)
    entity_set_float(ent, EV_FL_renderamt, 0.0 )
   
    attach_view(id,ent)
    entity_set_float(ent, EV_FL_nextthink, get_gametime())
}

public Think_PlayerCamera(ent)
{
    static owner
    owner = entity_get_edict(ent,EV_ENT_owner)
   
    static iButtons;
    iButtons = entity_get_int(owner, EV_INT_button)
   
    /* USE E BUTTON REMOVE
if( iButtons & IN_USE  || !is_user_alive(owner))
    {
        attach_view(owner,owner)
        remove_entity(ent)
        return PLUGIN_CONTINUE;
    }
    */
   
    static Float:origin[3], Float:fAngle[3],Float:origin2[3];
    entity_get_vector(owner,EV_VEC_origin,origin)
    entity_get_vector(owner,EV_VEC_v_angle,fAngle)
   
    origin2[0] = origin[0]
    origin2[1] = origin[1]
    origin2[2] = origin[2]
   
    static Float:fVBack[3];
    angle_vector( fAngle, ANGLEVECTOR_FORWARD, fVBack );
   
    origin[2] += 20.0;
   
    origin[0] += ( -fVBack[0] * 150.0 );
    origin[1] += ( -fVBack[1] * 150.0 );
    origin[2] += ( -fVBack[2] * 150.0 );
   
    trace_line(owner,origin2,origin,origin)
   
    entity_set_vector(ent,EV_VEC_origin,origin)
   
    entity_get_vector(owner,EV_VEC_velocity,origin2)
    entity_set_vector(ent,EV_VEC_velocity,origin2)
   
    entity_set_vector(ent,EV_VEC_angles,fAngle)
    entity_set_float(ent, EV_FL_nextthink, get_gametime())
   
    return PLUGIN_CONTINUE;
}




Or this

Code:


public Think_PlayerCamera(ent)
{

   
/* USE E BUTTON REMOVE
    static owner
    owner = entity_get_edict(ent,EV_ENT_owner)
   
    static iButtons;
    iButtons = entity_get_int(owner, EV_INT_button)
   

if( iButtons & IN_USE  || !is_user_alive(owner))
    {
        attach_view(owner,owner)
        remove_entity(ent)
        return PLUGIN_CONTINUE;
    }
    */

Tell me if works

Arkshine 07-08-2009 10:58

Re: CS 1.6 Custom 3rd Person View
 
engine here

amokossi 07-16-2009 03:38

Re: CS 1.6 Custom 3rd Person View
 
This could be very useful for Soccerjam right? Hm thinkling about to try to use it on SJ-Maps only.

ConnorMcLeod 07-21-2009 17:28

Re: CS 1.6 Custom 3rd Person View
 
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())



fysiks 07-21-2009 18:38

Re: CS 1.6 Custom 3rd Person View
 
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.

ConnorMcLeod 07-21-2009 19:27

Re: CS 1.6 Custom 3rd Person View
 
Quote:

Originally Posted by fysiks (Post 878255)
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.

For testing purpose on listenserver you can do :

sv_cheats 1; cam_command 1; restart

jasondoyle 12-14-2009 10:00

Re: CS 1.6 Custom 3rd Person View
 
could anybody please post the most updated version of this code please, engine or fakemeta i dont mind witch, ty

Arkshine 12-14-2009 10:08

Re: CS 1.6 Custom 3rd Person View
 
3 posts above you, you have a version using an alternate method which should provide "smooth moves".

jasondoyle 12-14-2009 10:09

Re: CS 1.6 Custom 3rd Person View
 
Quote:

Originally Posted by Arkshine (Post 1016727)
3 posts above you, you have a version using an alternate method which should provide "smooth moves".

ok thanks for the reply Arkshine.

does the camera get stuck in the wall sometimes when u turn corners or is it just me?

elec1shock 09-11-2010 22:22

Re: CS 1.6 Custom 3rd Person View
 
can u make the plugin start 3rd person at the begging of the round? all time 3rd person?? pls someone?

albert123 09-13-2010 01:48

Re: CS 1.6 Custom 3rd Person View
 
@Arkshine: how can i edit to make 3rd view like RE4 3rd view ? I really need it.

Hunter-Digital 09-13-2010 02:14

Re: CS 1.6 Custom 3rd Person View
 
You mean a little to the right ?

If you're telling arkshine I assume you're using his "fakemeta way" version:

replace:
Code:

        static Float:fVBack[3];
        angle_vector( fAngle, ANGLEVECTOR_FORWARD, fVBack );

        fOrigin[2] += 20.0;

        fOrigin[0] += ( -fVBack[0] * 150.0 );
        fOrigin[1] += ( -fVBack[1] * 150.0 );
        fOrigin[2] += ( -fVBack[2] * 150.0 );

with:
Code:

        static Float:fVBack[3];
        static Float:fVRight[3];
        angle_vector( fAngle, ANGLEVECTOR_FORWARD, fVBack );
        angle_vector( fAngle, ANGLEVECTOR_RIGHT, fVRight );

        fOrigin[2] += 20.0;

        fOrigin[0] += ( -fVBack[0] * 150.0 ) + ( fVRight[0] * 24.0 );
        fOrigin[1] += ( -fVBack[1] * 150.0 ) + ( fVRight[1] * 24.0 );
        fOrigin[2] += ( -fVBack[2] * 150.0 ) + ( fVRight[2] * 24.0 );

24 units to the right... if you want to the left, just place a - in front of each of the 3 fVRight when assigning fOrigin.

Note that the crosshair will be fairly off too.

albert123 09-13-2010 21:42

Re: CS 1.6 Custom 3rd Person View
 
Oh,thank

Hunter-Digital 09-14-2010 03:00

Re: CS 1.6 Custom 3rd Person View
 
Hmm, re-copy my code, I fixed something :}

albert123 09-14-2010 06:33

Re: CS 1.6 Custom 3rd Person View
 
Yeah, i copied it.


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

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