Raised This Month: $ Target: $400
 0% 

Detecting if aiming to a grenade


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 03-03-2010 , 04:45   Detecting if aiming to a grenade
Reply With Quote #1

I want to detect if the player is aiming to a grenade in the form of weapon_smokegrenade, weapon_flashbang or weapon_hegrenade. Tracemodel used like in this plugin, crashes.

If somebody has another way or a fix for this, I will appreciate it.
__________________
joaquimandrade is offline
Dr.G
Senior Member
Join Date: Nov 2008
Old 03-03-2010 , 06:23   Re: Detecting if aiming to a grenade
Reply With Quote #2

I would love the answer to this aswell! I tryed to get what the client was aiming at and the trace that model, but i only got crashes too....

This is what i tryed:

PHP Code:
public do_trace(id)
{    
    new 
iTargetbody
    
if(get_user_aiming(idiTargetbody) == 0.0 || iTarget 32)
        return
    
    new 
Float:start[3], Float:view_ofs[3]
    
pev(idpev_originstart)
    
pev(idpev_view_ofsview_ofs)
    
xs_vec_add(startview_ofsstart)
    
    new 
Float:dest[3]
    
pev(idpev_v_angledest)
    
engfunc(EngFunc_MakeVectorsdest)
    
global_get(glb_v_forwarddest)
    
xs_vec_mul_scalar(dest9999.0dest)
    
xs_vec_add(startdestdest)
    
    new 
iTrace create_tr2()
    
engfunc(EngFunc_TraceModelstartdestHULL_POINTiTargetiTrace)
    
    new 
iEnt get_tr2(iTraceTR_pHit)
    
    
//client_print(id, 3, "iEnt %d", iEnt)
    
    
if(has_grenade_mdl(iEnt))
    {
        
// Do something
    
}
    
free_tr2(iTrace)

Might be TOTALLY wrong. I havent used traceline much....
__________________
Dr.G is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 03-03-2010 , 11:40   Re: Detecting if aiming to a grenade
Reply With Quote #3

Solution: tracemodel against "weaponbox"'s. By the way what I'm doing is for grenades in the floor.
__________________
joaquimandrade is offline
Dr.G
Senior Member
Join Date: Nov 2008
Old 03-04-2010 , 02:21   Re: Detecting if aiming to a grenade
Reply With Quote #4

Good idea :) TY
__________________
Dr.G is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 03-04-2010 , 08:16   Re: Detecting if aiming to a grenade
Reply With Quote #5

joaquim, remember you should use vector (start / end) with a large distance between them.

I don't know why but OT_ said that in his wallblocker thread.
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
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 08:48.


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