Raised This Month: $ Target: $400
 0% 

Fix attach_view issue please


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
zXCaptainXz
Member
Join Date: May 2017
Old 09-05-2022 , 13:30   Re: Fix attach_view issue please
Reply With Quote #2

I apologize in advance for the spaghetti code but I really couldn't think of any other way to accomplish your goal... I created a duplicate entity, made it invisible, and made the attach_view follow that entity instead, so I inverted the yaw for the real entity and kept it the same for the invisible one...

PHP Code:
#include    AMXMODX
#include    ENGINE

new bool:g_bInvertYaw;

public 
plugin_init()
{
    
register_clcmd("__weapon__""__give_weapon__");
    
register_clcmd("invert_angle""invert_angle");
}

public 
invert_angle() g_bInvertYaw = !g_bInvertYaw;

public 
__give_weapon__(const iPlayer)
{
    
// It's only for testing purpose; code can be improved a lot, I know :)...
    
    
new Float:fCoords[3];
    
entity_get_vector(iPlayerEV_VEC_originfCoords);
    
    
fCoords[2] += 35.0;
    
    new 
iWeapon create_entity("info_target");
    {
        
entity_set_origin(iWeaponfCoords);
        
entity_set_model(iWeapon"models/v_ak47.mdl");
        
        
entity_set_string(iWeaponEV_SZ_classname"__custom_weapon__");
        
entity_set_edict(iWeaponEV_ENT_owneriPlayer);
        
entity_set_float(iWeaponEV_FL_nextthink0.001);
        
set_rendering(iWeaponkRenderFxGlowShell2550255kRenderNormal5);
        
        
register_think("__custom_weapon__""__think_custom_weapon__");
        
        new 
iWeapon2 create_entity("info_target"
        
entity_set_model(iWeapon2"models/v_ak47.mdl");
        
entity_set_origin(iWeapon2fCoords);        
        
        
entity_set_int(iWeapon2EV_INT_rendermodekRenderTransAlpha)
        
entity_set_int(iWeapon2EV_FL_renderamt0)

        
attach_view(iPlayeriWeapon2);

        
        
entity_set_int(iWeaponEV_INT_iuser1iWeapon2);
    }
}

public 
__think_custom_weapon__(const iEnt)
{
    static 
iOwner 
    iOwner 
entity_get_edict(iEntEV_ENT_owner);
    static 
iEnt2 
    iEnt2 
entity_get_int(iEntEV_INT_iuser1);
    static 
Float:fCoords[3];
    
entity_get_vector(iOwnerEV_VEC_originfCoords);

    
entity_set_origin(iEntfCoords);
    
entity_set_origin(iEnt2fCoords);
        
    static 
Float:fViewAngles[3];
    
entity_get_vector(iOwnerEV_VEC_v_anglefViewAngles);
    
    
    
entity_set_vector(iEnt2EV_VEC_anglesfViewAngles);
    
    
fViewAngles[0] = -fViewAngles[0];
    
entity_set_vector(iEntEV_VEC_anglesfViewAngles);

    
entity_set_float(iEntEV_FL_nextthink0.001);

zXCaptainXz is offline
 



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 15:41.


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