Raised This Month: $344 Target: $400
 86%   Almost there!

See if it is pointed at a gun on the ground


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Tripaloski
Member
Join Date: Jul 2017
Old 08-08-2017 , 21:07   See if it is pointed at a gun on the ground
Reply With Quote #1

Is it possible to know if the player is targeting a weapon that is on the ground?
Tripaloski is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 08-09-2017 , 02:24   Re: See if it is pointed at a gun on the ground
Reply With Quote #2

pev(weaponent, pev_flags) & FL_ONGROUND
__________________
@Jailbreak Main Mod v2.6.6 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-09-2017 , 05:50   Re: See if it is pointed at a gun on the ground
Reply With Quote #3

Quote:
Originally Posted by Natsheh View Post
pev(weaponent, pev_flags) & FL_ONGROUND
Dropped weapons are weaponbox entities which are SOLID_TRIGGER. Traceline will ignore this entities, which means you can't know directly when a player is aiming at one. Don't believe? Try get_user_aiming and you'll see.

@OP, do you want to know when a player aims at a dropped weapon? Then try this:
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <xs>
#include <engine>

public plugin_init()
{
    
register_clcmd("test""ClientCommand_Test")
}

public 
ClientCommand_Test(id)
{
    new 
Float:PlayerOrigin[3], Float:PlayerViewOffset[3]
    
pev(idpev_originPlayerOrigin)
    
pev(idpev_view_ofsPlayerViewOffset)
    
xs_vec_add(PlayerOriginPlayerViewOffsetPlayerOrigin)
    
    new 
Float:PlayerViewAngle[3]
    
pev(idpev_v_anglePlayerViewAngle)
    
engfunc(EngFunc_MakeVectorsPlayerViewAngle)
    
global_get(glb_v_forwardPlayerViewAngle)
    
    new 
Float:EndOrigin[3], Float:TraceEndOrigin[3]
    
xs_vec_mul_scalar(PlayerViewAngle9999.0PlayerViewAngle)
    
xs_vec_add(PlayerOriginPlayerViewAngleEndOrigin)

    new 
TraceLineHandle create_tr2()
    
engfunc(EngFunc_TraceLinePlayerOriginEndOriginIGNORE_MONSTERSidTraceLineHandle)
    
get_tr2(TraceLineHandleTR_vecEndPosTraceEndOrigin)
    
free_tr2(TraceLineHandle)
    
    new 
Target FM_NULLENTEntityClassName[32], TraceModelHandlepHit
    
while((Target find_ent_in_sphere(TargetTraceEndOrigin25.0)))
    {
        
pev(Targetpev_classnameEntityClassNamecharsmax(EntityClassName))
        if(
equal(EntityClassName"weaponbox"))
        {
            
TraceModelHandle create_tr2()
            
engfunc(EngFunc_TraceModelPlayerOriginTraceEndOriginHULL_POINTTargetTraceModelHandle)
            
pHit get_tr2(TraceModelHandleTR_pHit)
            
free_tr2(TraceModelHandle)
            
            if(
pev_valid(pHit))
            {
                if(
pHit == Target)
                {
                                        
//add your code here
                    
client_print(idprint_chat"Aiming at a dropped weapon")
                    break
                }
            }  
        }
    }

__________________

Last edited by HamletEagle; 08-09-2017 at 06:42.
HamletEagle is offline
Tripaloski
Member
Join Date: Jul 2017
Old 08-09-2017 , 09:00   Re: See if it is pointed at a gun on the ground
Reply With Quote #4

HamletEagle, is working.
Is it possible to put a minimum distance between the player and the weapon (eg: 100) to appear the phrase?
And can you check it automatically?
Tripaloski is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-09-2017 , 09:12   Re: See if it is pointed at a gun on the ground
Reply With Quote #5

I know that right now it works across the entire map.
PHP Code:
xs_vec_mul_scalar(PlayerViewAngle9999.0PlayerViewAngle
Change 9999.0 by your desired maximum distance(100.0 as you said before).

To check automatically, you can use a task. If you explain what you are trying to do I can probably suggest a better way than a task.
__________________
HamletEagle is offline
Tripaloski
Member
Join Date: Jul 2017
Old 08-09-2017 , 09:34   Re: See if it is pointed at a gun on the ground
Reply With Quote #6

I wanted that when a player pointing to the gun appears a hud saying "Press +use for pick up gun"
Tripaloski is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-09-2017 , 10:23   Re: See if it is pointed at a gun on the ground
Reply With Quote #7

Make a global task in plugin_init(flag b so it always repeat at 1.0 seconds or so) then loop all players and execute the above code.
__________________
HamletEagle is offline
Tripaloski
Member
Join Date: Jul 2017
Old 08-09-2017 , 10:42   Re: See if it is pointed at a gun on the ground
Reply With Quote #8

Thank you for your help
Tripaloski is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 08-09-2017 , 12:45   Re: See if it is pointed at a gun on the ground
Reply With Quote #9

You can use get user origin mode = 3

And also you can change all weapons entity on ground solid to bbox then make atrace and get the entity id then reset the weapons entity back to its previous solid
__________________
@Jailbreak Main Mod v2.6.6 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Reply


Thread Tools
Display Modes

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 06:19.


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