Raised This Month: $ Target: $400
 0% 

Fix attach_view issue please


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
SVC
Junior Member
Join Date: Mar 2021
Old 09-04-2022 , 18:44   Fix attach_view issue please
Reply With Quote #1

Hi, can someboy help me with the next code:

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);
    
        
// I think doesn't necessary explain what it does..
        
attach_view(iPlayeriWeapon);
        
        
register_think("__custom_weapon__""__think_custom_weapon__");
    }
}

public 
__think_custom_weapon__(const iEnt)
{
    new 
iOwner entity_get_edict(iEntEV_ENT_owner);

    static 
Float:fCoords[3];
    
entity_get_vector(iOwnerEV_VEC_originfCoords);

    
entity_set_origin(iEntfCoords);
    
    
/*
    Here I set custom-weapon's angles to the player's view-angles
    However even if I reverse they (more precisely the yaw-angle), the up/down view will be reverse "again"
    
    I can't explain better this, so when you test code you will see what i've saying
    */
    
    
static Float:fViewAngles[3];
    
entity_get_vector(iOwnerEV_VEC_v_anglefViewAngles);
    
    
// What I'm doing here is reverse the up/down angle (for testing) but doesn't not have effect
    
if (g_bInvertYaw)
        
fViewAngles[0] = -fViewAngles[0];
    
    
entity_set_vector(iEntEV_VEC_anglesfViewAngles);
    
entity_set_float(iEntEV_FL_nextthink0.001);

What I was looking for is trying to make a "fake-weapon" for testing purpouse, but I've a problem with weapon-angles

Sorry for my bad english, I really hope somebody helpme with this
SVC 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