Raised This Month: $32 Target: $400
 8% 

Solved [HELP] Player Aim At Entity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DarthMan
Veteran Member
Join Date: Aug 2011
Old 03-09-2017 , 09:00   [HELP] Player Aim At Entity
Reply With Quote #1

Hello. This is the current code to display the map name on the panels when the player gets closer to them. Can someone modify the code to display them if player is aiming at the entity named target_name ? Thanks!

Code:
public display_map_name(task_id)
{
new ent
new entcount, entlist[32]
new panel
while ((ent = find_ent_by_tname(ent, "target_map")) !=0)
{
	entcount = find_sphere_class(ent, "player", 50.0, entlist, sizeof(entlist))
	//if (entcount > 0) client_print(0, print_chat, "Found %d players at panel %d.", entcount, panel + 1)
	for(new player_index; player_index < entcount; player_index++)
	{
		set_hudmessage(g_hud_colour[0], g_hud_colour[1], g_hud_colour[2], -1.0, -1.0, 0, 0.0, 2.0, 0.0, 0.0, 2)
		show_hudmessage(entlist[player_index], g_mapnames[g_mapselection[panel]])
	}	
	panel++
}
}

Last edited by Bugsy; 03-11-2017 at 11:06.
DarthMan is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-09-2017 , 10:23   Re: [HELP] Player Aim At Entity
Reply With Quote #2

PHP Code:
new iEntiBody
get_user_aiming
(idiEntiBody50.0)

if(
pev_valid(iEnt))
{
    new 
szClass[32]
    
pev(iEntpev_classnameszClasscharsmax(szClass))
    
    if(
equal(szClass"target_map"))
    {
        
// display HUD message for player "id"
    
}

__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
DarthMan
Veteran Member
Join Date: Aug 2011
Old 03-09-2017 , 11:49   Re: [HELP] Player Aim At Entity
Reply With Quote #3

Quote:
Originally Posted by OciXCrom View Post
PHP Code:
new iEntiBody
get_user_aiming
(idiEntiBody50.0)

if(
pev_valid(iEnt))
{
    new 
szClass[32]
    
pev(iEntpev_classnameszClasscharsmax(szClass))
    
    if(
equal(szClass"target_map"))
    {
        
// display HUD message for player "id"
    
}

Ty, I didnt know that iEnt can be declared inside the script. Thanks!
DarthMan is offline
DarthMan
Veteran Member
Join Date: Aug 2011
Old 03-09-2017 , 12:13   Re: [HELP] Player Aim At Entity
Reply With Quote #4

Quote:
Originally Posted by OciXCrom View Post
PHP Code:
new iEntiBody
get_user_aiming
(idiEntiBody50.0)

if(
pev_valid(iEnt))
{
    new 
szClass[32]
    
pev(iEntpev_classnameszClasscharsmax(szClass))
    
    if(
equal(szClass"target_map"))
    {
        
// display HUD message for player "id"
    
}

I get a run time error 10 now, saying native error (native "get user aiming") , line 158.
DarthMan is offline
Kotoamatsukami
Member
Join Date: Jan 2017
Location: Malaysia
Old 03-09-2017 , 12:35   Re: [HELP] Player Aim At Entity
Reply With Quote #5

Quote:
Originally Posted by DarthMan View Post
I get a run time error 10 now, saying native error (native "get user aiming") , line 158.
Hello.
I recently used the native too and I do believe the distance should be in integer, you can refer to the native information.

PHP Code:
native Float:get_user_aiming(index,&id,&bodydist=9999); 

Last edited by Kotoamatsukami; 03-09-2017 at 12:42.
Kotoamatsukami is offline
DarthMan
Veteran Member
Join Date: Aug 2011
Old 03-09-2017 , 12:42   Re: [HELP] Player Aim At Entity
Reply With Quote #6

Quote:
Originally Posted by Kotoamatsukami View Post
Hello.
I recently used the native too and I do believe the distance should be in integer, you can refer to the native information.

Code:
native Float:get_user_aiming(index,&id,&body,dist=9999);
I did change it to 50.

I did that for now, but it doesn't display the message on the panels, even if I put test on the emssage.

Code:
public display_map_name(id)
{
new ent, body
new entlist[32]
new panel
while ((ent = find_ent_by_tname(ent, "target_map")) !=0)
{
	//entcount = find_sphere_class(ent, "player", 50.0, entlist, sizeof(entlist))
	//if (entcount > 0) client_print(0, print_chat, "Found %d players at panel %d.", entcount, panel + 1)
	if ( is_user_connected(id) || is_user_alive(id) )
	{
		for(new player_index; player_index < get_user_aiming(id, ent, body, 50) ; player_index++)
		{
		set_hudmessage(g_hud_colour[0], g_hud_colour[1], g_hud_colour[2], -1.0, -1.0, 0, 0.0, 2.0, 0.0, 0.0, 2)
		show_hudmessage(entlist[player_index], g_mapnames[g_mapselection[panel]])
		}
	}	
	panel++
}
}

Last edited by DarthMan; 03-09-2017 at 13:06.
DarthMan is offline
Kotoamatsukami
Member
Join Date: Jan 2017
Location: Malaysia
Old 03-09-2017 , 13:16   Re: [HELP] Player Aim At Entity
Reply With Quote #7

First of all, I am just trying to help here and if this still doesn't help, I am sorry.

I will explain here what I am trying to do. Firstly, catch what the 'id' is aiming, and save the aimed target into 'iEnt'. Then, I check in the while loop if the aimed index( iEnt ) is equal to the entity that the user wanted to aim( ent ). So, I check it( ent == iEnt ). If it's equal then show the HUD message that you wanted to show to the user.

I might be wrong but any improvement or rectification towards my code is greatly welcomed.
Thank you..
PHP Code:
public display_map_nameid )
{
    new 
iEntbodyentlist32 ], panel
    
    get_user_aiming
idiEntbody50 )
    
    while( ( 
ent find_ent_by_tnameent"target_map" ) ) !=)
    {
        if ( 
is_user_connectedid ) && ent == iEnt )
        {
            
set_hudmessageg_hud_colour], g_hud_colour], g_hud_colour], -1.0, -1.000.02.00.00.0)
            
show_hudmessageentlistent ], g_mapnamesg_mapselectionpanel ] ] )
        }
        
    
panel++
    }    


Last edited by Kotoamatsukami; 03-09-2017 at 13:17.
Kotoamatsukami is offline
DarthMan
Veteran Member
Join Date: Aug 2011
Old 03-09-2017 , 13:23   Re: [HELP] Player Aim At Entity
Reply With Quote #8

Quote:
Originally Posted by Kotoamatsukami View Post
First of all, I am just trying to help here and if this still doesn't help, I am sorry.

I will explain here what I am trying to do. Firstly, catch what the 'id' is aiming, and save the aimed target into 'iEnt'. Then, I check in the while loop if the aimed index( iEnt ) is equal to the entity that the user wanted to aim( ent ). So, I check it( ent == iEnt ). If it's equal then show the HUD message that you wanted to show to the user.

I might be wrong but any improvement or rectification towards my code is greatly welcomed.
Thank you..
PHP Code:
public display_map_nameid )
{
    new 
iEntbodyentlist32 ], panel
    
    get_user_aiming
idiEntbody50 )
    
    while( ( 
ent find_ent_by_tnameent"target_map" ) ) !=)
    {
        if ( 
is_user_connectedid ) && ent == iEnt )
        {
            
set_hudmessageg_hud_colour], g_hud_colour], g_hud_colour], -1.0, -1.000.02.00.00.0)
            
show_hudmessageentlistent ], g_mapnamesg_mapselectionpanel ] ] )
        }
        
    
panel++
    }    

Sadly, it doesn't display anything
DarthMan is offline
DarthMan
Veteran Member
Join Date: Aug 2011
Old 03-09-2017 , 13:27   Re: [HELP] Player Aim At Entity
Reply With Quote #9

Quote:
Originally Posted by Kotoamatsukami View Post
First of all, I am just trying to help here and if this still doesn't help, I am sorry.

I will explain here what I am trying to do. Firstly, catch what the 'id' is aiming, and save the aimed target into 'iEnt'. Then, I check in the while loop if the aimed index( iEnt ) is equal to the entity that the user wanted to aim( ent ). So, I check it( ent == iEnt ). If it's equal then show the HUD message that you wanted to show to the user.

I might be wrong but any improvement or rectification towards my code is greatly welcomed.
Thank you..
PHP Code:
public display_map_nameid )
{
    new 
iEntbodyentlist32 ], panel
    
    get_user_aiming
idiEntbody50 )
    
    while( ( 
ent find_ent_by_tnameent"target_map" ) ) !=)
    {
        if ( 
is_user_connectedid ) && ent == iEnt )
        {
            
set_hudmessageg_hud_colour], g_hud_colour], g_hud_colour], -1.0, -1.000.02.00.00.0)
            
show_hudmessageentlistent ], g_mapnamesg_mapselectionpanel ] ] )
        }
        
    
panel++
    }    

I fixed the warning, but it sitll doesn't work.

Code:
public display_map_name( id )
{
    new iEnt, body, entlist[ 32 ], panel
    
    while( ( ent = find_ent_by_tname( ent, "target_map" ) ) !=0 )
    {
        if ( is_user_connected( id ) && ent == iEnt && get_user_aiming( id, iEnt, body, 50 ) )
        {
            set_hudmessage( g_hud_colour[ 0 ], g_hud_colour[ 1 ], g_hud_colour[ 2 ], -1.0, -1.0, 0, 0.0, 2.0, 0.0, 0.0, 2 )
            show_hudmessage( entlist[ id ], g_mapnames[ g_mapselection[ panel ] ] )
        }
        
        panel++
    }    
}
DarthMan is offline
DarthMan
Veteran Member
Join Date: Aug 2011
Old 03-09-2017 , 14:08   Re: [HELP] Player Aim At Entity
Reply With Quote #10

Code:
public display_map_name( i_Client )
{
	if ( ! is_user_connected( i_Client )  ||  ! is_user_alive( i_Client ))
	return;
	new i_Body, i_Target;	
	get_user_aiming( i_Client, i_Target, i_Body, 100 )

	if( pev_valid( i_Target ) != 2 )
	return;
	
	static sz_tname[ 32 ]; 
	pev( i_Target, pev_targetname, sz_tname, 31 )
	
	if ( !( equal( sz_tname, "target_map" ) ) )
		return;
	
	set_hudmessage( g_hud_colour[ 0 ], g_hud_colour[ 1 ], g_hud_colour[ 2 ], -1.0, -1.0, 0, 0.0, 2.0, 0.0, 0.0, 2 )
	show_hudmessage( i_Client, "Test" ) 
}
Still doesn't work
DarthMan is offline
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 04:56.


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