AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Find POS of end of weapon (https://forums.alliedmods.net/showthread.php?t=78455)

CrimsonGT 10-04-2008 10:28

Find POS of end of weapon
 
*solved*

SAMURAI16 10-04-2008 11:07

Re: Find POS of end of weapon
 
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

CrimsonGT 10-04-2008 13:45

Re: Find POS of end of weapon
 
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?

SAMURAI16 10-04-2008 13:59

Re: Find POS of end of weapon
 
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(); }

CrimsonGT 10-04-2008 18:05

Re: Find POS of end of weapon
 
*solved*

Kigen 10-04-2008 19:34

Re: Find POS of end of weapon
 
Ensure WeaponOriginOffset is the right Offset?

CrimsonGT 10-04-2008 20:05

Re: Find POS of end of weapon
 
How would I go about that?

Kigen 10-04-2008 21:09

Re: Find POS of end of weapon
 
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. )

CrimsonGT 10-04-2008 22:26

Re: Find POS of end of weapon
 
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 10-04-2008 23:36

Re: Find POS of end of weapon
 
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.


All times are GMT -4. The time now is 05:27.

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