AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Detecting if aiming to a grenade (https://forums.alliedmods.net/showthread.php?t=120306)

joaquimandrade 03-03-2010 04:45

Detecting if aiming to a grenade
 
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.

Dr.G 03-03-2010 06:23

Re: Detecting if aiming to a grenade
 
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....

joaquimandrade 03-03-2010 11:40

Re: Detecting if aiming to a grenade
 
Solution: tracemodel against "weaponbox"'s. By the way what I'm doing is for grenades in the floor.

Dr.G 03-04-2010 02:21

Re: Detecting if aiming to a grenade
 
Good idea :) TY

joropito 03-04-2010 08:16

Re: Detecting if aiming to a grenade
 
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.


All times are GMT -4. The time now is 08:48.

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