AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Set player camera (https://forums.alliedmods.net/showthread.php?t=105948)

xbatista 10-10-2009 06:03

Set player camera
 
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() );



xPaw 10-10-2009 06:12

Re: Set player camera
 
http://forums.alliedmods.net/showpos...0&postcount=29

xbatista 10-10-2009 06:25

Re: Set player camera
 
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)   



Arkshine 10-10-2009 06:29

Re: Set player camera
 
There is not better than the code using trigger_camera atm. If you are not happy, find another method yourself.

xbatista 10-10-2009 06:34

Re: Set player camera
 
Quote:

f you are not happy, find another method yourself.
I'm happy :o
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


hleV 10-10-2009 06:41

Re: Set player camera
 
Freezes player and resets maxspeed to default.

xbatista 10-10-2009 06:51

Re: Set player camera
 
Quote:

Originally Posted by hleV (Post 957455)
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 10-10-2009 07:54

Re: Set player camera
 
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

Arkshine 10-10-2009 07:58

Re: Set player camera
 
enum { USE_OFF, USE_ON, USE_SET, USE_TOGGLE };

5th param is that.

xbatista 10-10-2009 08:12

Re: Set player camera
 
thanks


All times are GMT -4. The time now is 22:34.

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