Raised This Month: $ Target: $400
 0% 

Set player camera


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 10-10-2009 , 06:03   Set player camera
Reply With Quote #1

I like this method,but it lags ( when moving you see you going like a lager and it annoys :/ ), is there are any other ways to set the players view ( not set_view (but it not lags) ) ???
PHP Code:
//Call this wherever you want.
Create_PlayerCameraid )
{
    new 
entid;
    while( (
entid find_ent_by_class(entid"PlayerCamera")) != 0)
        if( 
entity_get_edictentidEV_ENT_owner ) == id )
        {
            
attach_viewidentid );
            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_intentidEV_INT_solidSOLID_TRIGGER);
        
entity_set_intentidEV_INT_movetypeMOVETYPE_FLY );
        
         
//Set owner
        
entity_set_edictentidEV_ENT_ownerid );
        
//Don't draw
        
entity_set_intentidEV_INT_rendermodekRenderTransTexture);
        
entity_set_floatentidEV_FL_renderamt0.0);
        
//Attach our view to this entity.
        
attach_viewidentid ); 
        
//Think!
        
entity_set_floatentidEV_FL_nextthinkget_gametime() );
    }   
}
public 
Think_PlayerCameraentid )
{
    new 
id entity_get_edictentidEV_ENT_owner );
    
    
//Kill our entity if we hit USE key
    
new buttons entity_get_intidEV_INT_button );
    if(
buttons IN_USE)
    {
        
attach_viewidid );
        
remove_entity(entid);
        return;
    }

    new 
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 );   
    
    
//For thinking only
    
entity_set_floatentidEV_FL_nextthinkget_gametime() );

__________________

Last edited by xbatista; 10-10-2009 at 06:11.
xbatista is offline
Send a message via Skype™ to xbatista
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 10-10-2009 , 06:12   Re: Set player camera
Reply With Quote #2

http://forums.alliedmods.net/showpos...0&postcount=29
__________________
xPaw is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 10-10-2009 , 06:25   Re: Set player camera
Reply With Quote #3

Thanks,that do 70% less lag, but still doesn't = set_view
The Think is same ^ :
PHP Code:
Create_PlayerCameraid 

    new 
iEnt g_iCam[id]
    if( !
is_valid_ent(iEnt) )
    {
        
iEnt create_entity("trigger_camera")

        
entity_set_string(iEnt,EV_SZ_classname,"PlayerCamera");
        
entity_set_int(iEntEV_INT_spawnflagsSF_CAMERA_PLAYER_TARGET|SF_CAMERA_PLAYER_POSITION)
        
entity_set_edictiEntEV_ENT_ownerid );

        
DispatchSpawn(iEnt)
        
set_pdata_float(iEntm_flWait999999.04)

        
g_iCam[id] = iEnt
    
}

    
ExecuteHamHam_UseiEntidid31.0)

    
//entity_set_int(id, EV_INT_flags, entity_get_int(id, EV_INT_flags) & ~FL_FROZEN)   

__________________
xbatista is offline
Send a message via Skype™ to xbatista
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-10-2009 , 06:29   Re: Set player camera
Reply With Quote #4

There is not better than the code using trigger_camera atm. If you are not happy, find another method yourself.
__________________
Arkshine is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 10-10-2009 , 06:34   Re: Set player camera
Reply With Quote #5

Quote:
f you are not happy, find another method yourself.
I'm happy
and thanks for the info
And what the effect it does? ( why reset speed? )
PHP Code:
entity_set_int(idEV_INT_flagsentity_get_int(idEV_INT_flags) & ~FL_FROZEN)
    
cs_reset_user_maxspeed(id
__________________

Last edited by xbatista; 10-10-2009 at 06:40.
xbatista is offline
Send a message via Skype™ to xbatista
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 10-10-2009 , 06:41   Re: Set player camera
Reply With Quote #6

Freezes player and resets maxspeed to default.
__________________
hleV is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 10-10-2009 , 06:51   Re: Set player camera
Reply With Quote #7

Quote:
Originally Posted by hleV View Post
Freezes player and resets maxspeed to default.
I just don't understand why he do it.
Btw
PHP Code:
ExecuteHamHam_UseiEntidid31.0
(argument 5)
when I respawn it sets the view 3rdperson, second spawn - view none, third spawn - the 3rdperson...
PHP Code:
public fwd_PlayerSpawn(id)
{
    if ( !
is_user_alive(id) )
        return;

    
//set_view( id, CAMERA_3RDPERSON);
    
Create_PlayerCameraid 

__________________
xbatista is offline
Send a message via Skype™ to xbatista
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 10-10-2009 , 07:54   Re: Set player camera
Reply With Quote #8

This solves the bug :
PHP Code:
    ExecuteHamHam_UseiEntidid01.0);
    
ExecuteHamHam_UseiEntidid31.0); 
I don't know what the 5's argument use types are, but I just tryied this method
__________________
xbatista is offline
Send a message via Skype™ to xbatista
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-10-2009 , 07:58   Re: Set player camera
Reply With Quote #9

enum { USE_OFF, USE_ON, USE_SET, USE_TOGGLE };

5th param is that.
__________________
Arkshine is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 10-10-2009 , 08:12   Re: Set player camera
Reply With Quote #10

thanks
__________________
xbatista is offline
Send a message via Skype™ to xbatista
Reply



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 22:34.


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