Raised This Month: $90 Target: $400
 22% 

CS 1.6 Custom 3rd Person View


Post New Thread Reply   
 
Thread Tools Display Modes
niFe
Senior Member
Join Date: Apr 2008
Location: Planet Green
Old 04-17-2009 , 15:52   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #11

Quote:
Originally Posted by ot_207 View Post
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
__________________
niFe is offline
PvtSmithFSSF
Senior Member
Join Date: Jul 2008
Old 04-17-2009 , 16:41   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #12

Nice =O
PvtSmithFSSF is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 04-18-2009 , 04:52   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #13

Quote:
Originally Posted by Emp` View Post
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)
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.

Last edited by ot_207; 04-18-2009 at 04:59.
ot_207 is offline
ZoRaN
Junior Member
Join Date: May 2009
Old 05-12-2009 , 08:35   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #14

Can somebody make this to force the camera on player? and to don't write /cam! thx
ZoRaN is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 05-12-2009 , 18:33   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #15

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!
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-12-2009 , 19:49   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #16

Quote:
Originally Posted by ot_207 View Post
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;

__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 05-15-2009 at 16:36.
Exolent[jNr] is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 05-13-2009 , 01:50   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #17

Because I wanted to make him think, not to give simply the code in his hands ;).
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
ZoRaN
Junior Member
Join Date: May 2009
Old 05-13-2009 , 08:30   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #18

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]

Last edited by ZoRaN; 05-13-2009 at 16:18.
ZoRaN is offline
Old 05-14-2009, 04:32
jahid420
This message has been deleted by Emp`. Reason: Spam
Old 05-15-2009, 07:51
ZoRaN
This message has been deleted by Exolent[jNr]. Reason: Don't bump until 2 weeks have passed since last post.
ZoRaN
Junior Member
Join Date: May 2009
Old 05-15-2009 , 09:47   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #19

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)
ZoRaN is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-15-2009 , 11:49   Re: CS 1.6 Custom 3rd Person View
Reply With Quote #20

Change

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

by

Code:
public FwdPlayerSpawn(id) {     if ( is_user_alive( id ) ) Create_PlayerCamera(id) }
Arkshine 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:15.


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