Raised This Month: $51 Target: $400
 12% 

Find POS of end of weapon


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrimsonGT
Veteran Member
Join Date: Oct 2007
Location: Gainesville, FL
Old 10-04-2008 , 10:28   Find POS of end of weapon
Reply With Quote #1

*solved*
__________________

Last edited by CrimsonGT; 01-01-2009 at 05:54.
CrimsonGT is offline
SAMURAI16
BANNED
Join Date: Sep 2006
Old 10-04-2008 , 11:07   Re: Find POS of end of weapon
Reply With Quote #2

how would i do this in CS:S
Code:
#include <hacks> new g_iHooks[MAXPLAYERS + 1] = { -1, ... }; new Float:endOrigin[3], iIndex = -1; public OnPluginStart() {     HookEvent("weapon_fire",weapon_fire_event); } public Action:weapon_fire_event(Handle:event, const String:name[], bool:dontBroadcast) {     new client = GetClientOfUserId(GetEventInt(event,"userid"));         if(!IsClientConnected(client) && !IsClientInGame(client) && !IsPlayerAlive(client))         return Plugin_Continue;         static String:weapon[64];     GetEventString(event,"weapon",weapon,sizeof(weapon));         if(StrEqual(weapon,"knife"))         return Plugin_Continue;         decl Float:ClientOrigin[3],Float:weaponOrigin[3];     GetClientAbsOrigin(client,ClientOrigin);     GetWeaponOrigin(client,weaponOrigin);         ClientOrigin[2] -= 6;         // now here add your trace beam     // do it from ClientOrigin to WeaponOrigin         return Plugin_Continue;     } public call_TraceAttack(client, inflictor, attacker, damage, hitbox, hitgroup) {     if(!inflictor || !attacker)         return Hacks_Continue;         decl Float:origin[3],Float:angles[3];     GetClientAbsOrigin(attacker,origin);     GetClientEyeAngles(attacker,angles);         new Handle:trace = TR_TraceRayEx(origin,angles,MASK_SHOT,RayType_Infinite);         if(TR_DidHit(trace) && IsClientInGame(attacker))     {         iIndex = attacker;         TR_GetEndPosition(endOrigin, trace);         CloseHandle(trace);     }         CloseHandle(trace);             return Hacks_Continue; } public OnClientPutInServer(client) {     g_iHooks[client] = Hacks_Hook(client, HACKS_HTYPE_TRACEATTACK, call_TraceAttack, false); }     public OnClientDisconnect(client) {     Hacks_Unhook(g_iHooks[client]); }   public GetWeaponOrigin(client,Float:origin[3]) {     client = iIndex;     CopyVector(origin,endOrigin); } stock CopyVector(Float:v1[3],Float:v2[3]) {     v1[0] = v2[0];     v1[1] = v2[1];     v1[2] = v2[2]; }

Maybe this could help you

Last edited by SAMURAI16; 10-04-2008 at 11:10.
SAMURAI16 is offline
Send a message via MSN to SAMURAI16
CrimsonGT
Veteran Member
Join Date: Oct 2007
Location: Gainesville, FL
Old 10-04-2008 , 13:45   Re: Find POS of end of weapon
Reply With Quote #3

Well TraceAttack is not available for TF2. Otherwise the only thing I can tell your doing different is using GetClientAbsOrigin and I used GetClientEyeAngles and GetClientEyePosition. Would this make much difference?
__________________
CrimsonGT is offline
SAMURAI16
BANNED
Join Date: Sep 2006
Old 10-04-2008 , 13:59   Re: Find POS of end of weapon
Reply With Quote #4

maybe you could use this:
Code:
// modify here public your_weapon_fire_event(client) {     new Float:clientOrigin[3],Float:aimOrigin[3];     GetClientAbsOrigin(client,clientOrigin);     GetAimOrigin(client,aimOrigin);         clientOrigin[2] -= 6;         // make TEbeam from clientOrigin to aimOrigin }         stock GetAimOrigin(client, Float:hOrigin[3]) {     new Float:vAngles[3], Float:fOrigin[3];     GetClientEyePosition(client,fOrigin);     GetClientEyeAngles(client, vAngles);     new Handle:trace = TR_TraceRayFilterEx(fOrigin, vAngles, MASK_SHOT, RayType_Infinite, TraceEntityFilterPlayer);     if(TR_DidHit(trace))     {         TR_GetEndPosition(hOrigin, trace);         CloseHandle(trace);         return 1;     }     CloseHandle(trace);     return 0; } public bool:TraceEntityFilterPlayer(entity, contentsMask) {      return entity > GetMaxClients(); }
SAMURAI16 is offline
Send a message via MSN to SAMURAI16
CrimsonGT
Veteran Member
Join Date: Oct 2007
Location: Gainesville, FL
Old 10-04-2008 , 18:05   Re: Find POS of end of weapon
Reply With Quote #5

*solved*
__________________

Last edited by CrimsonGT; 01-01-2009 at 05:54.
CrimsonGT is offline
Kigen
BANNED
Join Date: Feb 2008
Old 10-04-2008 , 19:34   Re: Find POS of end of weapon
Reply With Quote #6

Ensure WeaponOriginOffset is the right Offset?
Kigen is offline
CrimsonGT
Veteran Member
Join Date: Oct 2007
Location: Gainesville, FL
Old 10-04-2008 , 20:05   Re: Find POS of end of weapon
Reply With Quote #7

How would I go about that?
__________________
CrimsonGT is offline
Kigen
BANNED
Join Date: Feb 2008
Old 10-04-2008 , 21:09   Re: Find POS of end of weapon
Reply With Quote #8

Well, first log what its being set to or print it.

PrintToChatAll("WeaponIndex %d WepOriginOff %d", WeaponIndex, WeaponOriginOffset);

Also, almost forgot, might be a good idea to get the Offset in OnPluginStart(). Seeing as an Offset shouldn't change during game play. ( DO REMEMBER THAT THERE ARE DIFFERENT OFFSETS FOR DIFFERENT WEAPONS IF YOU WERE TO PRE-LOAD IT. )

Last edited by Kigen; 10-04-2008 at 21:11.
Kigen is offline
CrimsonGT
Veteran Member
Join Date: Oct 2007
Location: Gainesville, FL
Old 10-04-2008 , 22:26   Re: Find POS of end of weapon
Reply With Quote #9

WeaponIndex: 1018 WeaponOriginOffset 716

It prints that wether I set the offset in onpluginstart() or leave it in the function. It is still drawing from 0,0,0 as the BeamOrigin for some reason though... I am clueless.
__________________
CrimsonGT is offline
CrimsonGT
Veteran Member
Join Date: Oct 2007
Location: Gainesville, FL
Old 10-04-2008 , 23:36   Re: Find POS of end of weapon
Reply With Quote #10

Okay so heres what I figured out. I ran a GetEdictClassname on the players weapon, and it returned tf_weapon_syringegun_medic. Its entitynetclass is CTFSyringeGun. Heres the results of the little test script I made...

CTFSyringeGun & m_vecAbsOrigin = -1
CTFSyringeGun & m_vecOrigin = 716
tf_weapon_syringegun_medic & m_vecAbsOrigin = -1
tf_weapon_syringegun_medic & m_vecOrigin = -1

Problem is, when I use the one that returns 716 (the one I was using initally, it draws the BeamOrigin from 0,0,0. So I am just at a loss now. Any help would be great.
__________________

Last edited by CrimsonGT; 10-04-2008 at 23:42.
CrimsonGT 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 03:32.


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