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)

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.


All times are GMT -4. The time now is 01:28.

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