Raised This Month: $ Target: $400
 0% 

Where player aim -> Same angle to object.


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 12-30-2008 , 14:46   Re: Where player aim -> Same angle to object.
Reply With Quote #6

Instead of the user's origin, I would suggest using the origin from his eyes:
PHP Code:
#include <amxmodx>
#include <fakemeta_util>

#define VERSION "1.0"

#define HEAD_POSITION    8
#define DESIRED_DISTANCE    100 // Change this to whatever.

new g_entid;

public 
plugin_init()
{
    
register_plugin"Moving an entity by the aim"VERSION"Dores" );
    
register_forwardFM_PlayerPreThink"Forward_PreThink" );
    
register_clcmd"say /ent""Cmd_Create" );
}

public 
Cmd_Createid )
{
    new 
Float:aimorigin];
    
fm_get_aim_originidaimorigin );
    
    
g_entid fm_create_entity"info_target" );
    
set_pevg_entidpev_classname"BlaBla" );
    
set_pevg_entidpev_movetypeMOVETYPE_FOLLOW );
    
set_pevg_entidpev_ownerid );
    
    
// ETC. - Create entity with your likings.
    
    
    
return PLUGIN_HANDLED;
}

public 
Forward_PreThinkid )
{
    if( !
is_user_aliveid ) )
        return 
FMRES_IGNORED;
    
    static 
Float:start], Float:Forward], Float:end];
    
engfuncEngFunc_GetBonePositionidHEAD_POSITIONstart );
    
pevidpev_v_angleForward );
    
engfuncEngFunc_MakeVectorsForward );
    
global_getglb_v_forwardForward );
    
end] = start] + Forward] * DESIRED_DISTANCE;
    
end] = start] + Forward] * DESIRED_DISTANCE;
    
end] = start]; // Height of the eyes.
    
engfuncEngFunc_SetOriging_entidend ); // Update the ent's origin.
    
    
return FMRES_IGNORED;

__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ

Last edited by Dores; 12-30-2008 at 19:29.
Dores 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 09:11.


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