Raised This Month: $ Target: $400
 0% 

Solved HUD Message When Looking at Player


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
hellmonja
Senior Member
Join Date: Oct 2015
Old 05-19-2016 , 11:05   HUD Message When Looking at Player
Reply With Quote #1

I made a simple plugin where you can take the C4 from your bot teammate by being in a certain distance and pressing the USE key while aiming at it. I got this idea from CSGO and since I play with bots this is really handy.

It works perfectly but I was thinking of placing a HUD message when you aim at a bot teammate carrying a C4 to inform in other players. Like maybe it would say, "Press the USE key to take the C4 from your Bot teammate" or something like that. Thing is, I don't how to do this. How do hook this 'event ' of aiming at a player?

Here's the whole code. And before you say 'this looks familiar', you're right. Its from joaquimandrade and ConnorMcLeod's Easy Weapon Trade plugin.

PHP Code:
#include <amxmodx>
#include <fakemeta_util>
#include <hamsandwich>

new const Plugin[] = "C4 Bot Swap"
new const Author[] = "joaquimandrade and ConnorMcLeod"
new const Version[] = "1.0"
const MaxSlots 32
new Float:TradeMaxDistance 300.0

public plugin_init()
{
    
register_plugin(Plugin,Version,Author)
    
RegisterHam(Ham_ObjectCaps,"player","Use_Button")
}

getLookingAt(id)
{
    static 
Float:start[3],Float:viewOffset[3],Float:path[3],Float:dest[3]
    
    
pev(id,pev_origin,start);
    
pev(id,pev_view_ofs,viewOffset);
    
xs_vec_add(start,viewOffset,start);
    
    
pev(id,pev_v_angle,path);
    
engfunc(EngFunc_MakeVectors,path);
    
global_get(glb_v_forward,path);
    
    
xs_vec_mul_scalar(path,TradeMaxDistance,dest);
    
xs_vec_add(start,dest,dest);
    
    
engfunc(EngFunc_TraceLine,start,dest,0,id,0);
    
    new 
hit get_tr2(0,TR_pHit)
    
    return 
<= hit <= MaxSlots  hit 0
}

C4_Swap(id)
{
    new 
idLookingAt getLookingAt(id)
            
    if(
idLookingAt && (get_user_team(id) == get_user_team(idLookingAt)) && is_user_bot(idLookingAt))
    {
        
fm_transfer_user_gun(idLookingAtidCSW_C4);
    }
}

public 
Use_Button(id)
{
    if(
is_user_connected(id))
    {
        if(
pev(id,pev_button) & IN_USE)
        {
            
C4_Swap(id);
        }
    }


Last edited by hellmonja; 06-25-2017 at 04:21. Reason: Solved...
hellmonja is offline
 


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 18:37.


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