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-06-2022 , 16:32   Re: Fix attach_view issue please
Reply With Quote #6

Apparently attach_view was still stubborn even when it comes to AddToFullPack, I wrote a hybrid solution between the two, so I created 2 entities, and only inverted the angle for the owner in AddToFullPack. This method is very sketchy I know, but until someone comes up with a better one I guess you're stuck with this for now :/

PHP Code:
#include    AMXMODX
#include    ENGINE
#include    FAKEMETA

public plugin_init()
{
    
register_clcmd("__weapon__""__give_weapon__");
    
register_forward(FM_AddToFullPack"fw_addtofullpack"1)
}

public 
fw_addtofullpack(es_handle,e,ent,host,hostflags,player,pSet)
{
    if(
player) return FMRES_IGNORED;      
    if(!
pev_valid(ent)) return FMRES_IGNORED;
    new 
classname[32]
    
pev(ent,pev_classname,classname,31)
    if(!
equali(classname,"__custom_weapon__")) return FMRES_IGNORED   

    
if(pev(entpev_owner)!=host) return FMRES_IGNORED
    
static Float:fViewAngles[3];
    
get_es(es_handleES_AnglesfViewAngles);
    
fViewAngles[0] = -fViewAngles[0]
    
set_es(es_handleES_AnglesfViewAngles);
    return 
FMRES_IGNORED;
}

public 
__give_weapon__(const iPlayer)
{
    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);
    
    
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