Raised This Month: $ Target: $400
 0% 

How to get the coordinate of gunpoint


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
akn
Junior Member
Join Date: Aug 2009
Old 08-24-2009 , 05:24   Re: How to get the coordinate of gunpoint
Reply With Quote #1

Quote:
Originally Posted by Arkshine View Post
You can get exactly the position, I don't see the problem. But the position would be different for each weapons.
that is the problem, each weapon have different position to calculate, not a possible solution.
Quote:
About TE_BEAMENTPOINT, I don't understand what you want to do.
when using TE_BEAMENTPOINT, you could use "playerID|0x1000" to ask the engine to draw a line from the position we want, I want to find out the method draw the line with input "playerID|0x1000", then we may find the position coordinate there.
akn is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-24-2009 , 05:40   Re: How to get the coordinate of gunpoint
Reply With Quote #2

Quote:
that is the problem, each weapon have different position to calculate, not a possible solution.
If you are that obsessed to get absolutely the exact position and viewing your own trace, you will do it. I don't see the problem to hardcode the position offset.

Quote:
when using TE_BEAMENTPOINT, you could use "playerID|0x1000" to ask the engine to draw a line from the position we want, I want to find out the method draw the line with input "playerID|0x1000", then we may find the position coordinate there.
It attaches the point to the weapon attachment. If we can't retrieve this point with amxx native, how you can expect to find it by viewing the source of this message (which is impossible since there is no source available for the engine itself ) ?! Though all the model informations are loaded in memory but it's done client-side and you can't access it with a server-side plugin.
__________________
Arkshine is offline
akn
Junior Member
Join Date: Aug 2009
Old 08-24-2009 , 10:27   Re: How to get the coordinate of gunpoint
Reply With Quote #3

thanks, arkshine, I will try to find other ways
akn is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-24-2009 , 10:31   Re: How to get the coordinate of gunpoint
Reply With Quote #4

There are no others ways. ( at least using an Amxx plugin )
__________________
Arkshine is offline
akn
Junior Member
Join Date: Aug 2009
Old 08-25-2009 , 01:42   Re: How to get the coordinate of gunpoint
Reply With Quote #5

Quote:
Originally Posted by Arkshine View Post
There are no others ways. ( at least using an Amxx plugin )
At least there is one way I found, post code in next post
akn is offline
akn
Junior Member
Join Date: Aug 2009
Old 08-25-2009 , 01:51   Re: How to get the coordinate of gunpoint
Reply With Quote #6

currently it works only for left handed, I am try to make it fit right handed

Code:
//first person tracer #include <amxmodx> #include <cstrike> #include <fakemeta_stocks> #include <engine> #include <hamsandwich> #define VERSION "1.0" #define write_coord_f(%1)   engfunc(EngFunc_WriteCoord,%1) enum _:Coord_e { Float:x, Float:y, Float:z }; #define VectorAdd(%0,%1,%2)    ( %2[ x ] = %0[ x ] + %1[ x ], %2[ y ] = %0[ y ] + %1[ y ], %2[ z ] = %0[ z ] + %1[ z ] ) #define VectorScale(%0,%1,%2)  ( %2[ x ] = %1 * %0[ x ], %2[ y ] = %1 * %0[ y ], %2[ z ] = %1 * %0[ z ] ) #define max_weapon CSW_P90 #define min_weapon CSW_P228 #define weapon_size max_weapon-min_weapon+1 new Trie:g_tClassNames new dummy_ent[weapon_size] public plugin_precache() {   for(new int:i=0;i<weapon_size;i++) dummy_ent[i]=0;         g_tClassNames = TrieCreate()     RegisterHam(Ham_TraceAttack, "worldspawn", "TraceAttack", 1)     TrieSetCell(g_tClassNames, "worldspawn", 1)     RegisterHam(Ham_TraceAttack, "player", "TraceAttack", 1)     TrieSetCell(g_tClassNames, "player", 1)     register_forward(FM_Spawn, "Spawn", 1) } public plugin_init() {     register_plugin("First Person Tracers", VERSION, "akn") } public plugin_end() {     TrieDestroy(g_tClassNames) } public Spawn( iEnt ) {     if( pev_valid(iEnt) )     {         static szClassName[32]         pev(iEnt, pev_classname, szClassName, charsmax(szClassName))         if( !TrieKeyExists(g_tClassNames, szClassName) )         {             RegisterHam(Ham_TraceAttack, szClassName, "TraceAttack", 1)             TrieSetCell(g_tClassNames, szClassName, 1)         }     } } public TraceAttack(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType) {     new wid = get_user_weapon(iAttacker);     if( wid==CSW_KNIFE || wid==CSW_HEGRENADE || wid == CSW_SMOKEGRENADE || wid == CSW_FLASHBANG || wid == CSW_C4 ) return;       new float:end[3]     get_tr2(ptr, TR_vecEndPos, end)         Draw_from_gunpoint(iAttacker,wid,end); } public Draw_from_gunpoint(id, wid, const Float:end[3]) {   new Float:ori[3]={0,0,0};   new Float:offset[3];   new Float:vector[3];   new Float:angle[3];     wid=wid-min_weapon;   if(dummy_ent[wid]==0)   {     new classname[32];     dummy_ent[wid]=create_entity("worldspawn");     set_entity_visibility(dummy_ent[wid],0);     entity_set_vector(dummy_ent[wid],EV_VEC_origin,ori);     pev(id, pev_viewmodel2, classname, sizeof(classname)-1);     entity_set_model(dummy_ent[wid],classname);   }     entity_get_vector(id,EV_VEC_v_angle,angle);   angle[0]=0-angle[0];   entity_set_vector(dummy_ent[wid],EV_VEC_angles,angle);   engfunc(EngFunc_GetAttachment, dummy_ent[wid], 0, offset, angle);     entity_get_vector(id,EV_VEC_origin,ori);   pev(id,pev_view_ofs,vector);   if(vector[2]==12.0) ori[2]+=11; //duck   else ori[2]+=16; //stand   VectorAdd(ori,offset,ori); //left handed gunpoint     vector[0]=end[0]-ori[0];   vector[1]=end[1]-ori[1];   vector[2]=ori[2]-end[2];   vector_to_angle(vector,angle);   angle_vector(angle, ANGLEVECTOR_FORWARD, vector);   VectorScale(vector, 4096.0, vector);   Draw_tracer(ori,vector); } Draw_tracer(const Float:Source[3], const Float:Velocity[3]) {     message_begin( MSG_BROADCAST, SVC_TEMPENTITY );     write_byte( TE_USERTRACER );     write_coord_f( Source[0] );     write_coord_f( Source[1] );     write_coord_f( Source[2] );     write_coord_f( Velocity[0] );     write_coord_f( Velocity[1] );     write_coord_f( Velocity[2] );     write_byte( 20 ); //life     write_byte( 0 );  //color     write_byte( 3 );  //length     message_end(); }
Attached Thumbnails
Click image for larger version

Name:	2222.JPG
Views:	475
Size:	67.6 KB
ID:	48463  

Last edited by akn; 08-25-2009 at 02:18.
akn is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-25-2009 , 03:34   Re: How to get the coordinate of gunpoint
Reply With Quote #7

You still calculate the point origin and you don't start to the weapon attachment. And I don't like the creation of much entities. Though for sure it's an improvement since the start so good job to find this way.
__________________

Last edited by Arkshine; 08-25-2009 at 03:38.
Arkshine is offline
reez_q11
New Member
Join Date: Nov 2009
Location: jakarta
Old 07-12-2010 , 00:27   Re: How to get the coordinate of gunpoint
Reply With Quote #8

hi akn,

did u find the proper way? i'm also curious how to get that origin. i believe the origin is the same origin for the muzzle flash >_<. i need the origin to add smoke effect for the shoot, like in hostile intent...
reez_q11 is offline
Reply



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:07.


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