Raised This Month: $12 Target: $400
 3% 

Solved Detect if player1 and player2 is aiming each other?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kotoamatsukami
Member
Join Date: Jan 2017
Location: Malaysia
Old 03-01-2017 , 12:56   Detect if player1 and player2 is aiming each other?
Reply With Quote #1

Hello, greetings.

I am working on a plugin, that use the features that I mentioned on the title. Is there any possible way to do this? If so, is it like;

PHP Code:
public Randomid )
{
    if( !
is_user_aliveid ) ) return;
    
    new 
id2body;
    
    
get_user_aimingidid2body )
    
get_user_aimingid2idbody )
    
    if( 
pevidpev_button ) & IN_USE && cs_get_user_teamid ) != cs_get_user_teamid2 ) )
    {
        
//......
    
}

Thank you for your time...

Last edited by Kotoamatsukami; 03-02-2017 at 10:20.
Kotoamatsukami is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-01-2017 , 13:36   Re: Detect if player1 and player2 is aiming each other?
Reply With Quote #2

Simply get both players' aiming entity and see if they are equal.

PHP Code:
new iEnt[2], iBody
get_user_aiming
(idiEnt[0], iBody)
get_user_aiming(id2iEnt[1], iBody)

if(
iEnt[0] == id2 && iEnt[1] == id)
{
    
// both players are aiming at each other

__________________

Last edited by OciXCrom; 03-01-2017 at 14:56.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 03-01-2017 , 14:08   Re: Detect if player1 and player2 is aiming each other?
Reply With Quote #3

Why not
iEnt[0] == id2 && iEnt[1] == id
?
__________________

Last edited by PRoSToTeM@; 03-01-2017 at 14:08.
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
Kotoamatsukami
Member
Join Date: Jan 2017
Location: Malaysia
Old 03-01-2017 , 14:41   Re: Detect if player1 and player2 is aiming each other?
Reply With Quote #4

Quote:
Originally Posted by OciXCrom View Post
Simply get both players' aiming entity and see if they are equal.

PHP Code:
new iEnt[2], iBody
get_user_aiming
(idiEnt[0], iBody)
get_user_aiming(id2iEnt[1], iBody)

if(
is_user_connected(iEnt[0]) && is_user_connected(iEnt[1]) && iEnt[0] == iEnt[1])
{
    
// both players are aiming at each other

Pardon me...
But, isn't your code will only operate if both 'id' and 'id2' are aiming at the same entity( not each other )?
For instant, I thought PRoSToTeM@'s lines should work if they are aiming each other?

Last edited by Kotoamatsukami; 03-01-2017 at 14:42.
Kotoamatsukami is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-01-2017 , 14:56   Re: Detect if player1 and player2 is aiming each other?
Reply With Quote #5

Yeah, my bad. I fixed my code.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Kotoamatsukami
Member
Join Date: Jan 2017
Location: Malaysia
Old 03-02-2017 , 02:28   Re: Detect if player1 and player2 is aiming each other?
Reply With Quote #6

Sorry for driving this out from the main context.
If I want the 'id2' to be an enemy to 'id', should I do
PHP Code:
new id2 read_data
Thank in advance...
Kotoamatsukami is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 03-02-2017 , 02:31   Re: Detect if player1 and player2 is aiming each other?
Reply With Quote #7

Quote:
Originally Posted by Kotoamatsukami View Post
Sorry for driving this out from the main context.
If I want the 'id2' to be an enemy to 'id', should I do
PHP Code:
new id2 read_data
Thank in advance...

if( get_user_team( id1 ) != get_user_team( id2 ) )
Craxor is offline
Send a message via ICQ to Craxor
Kotoamatsukami
Member
Join Date: Jan 2017
Location: Malaysia
Old 03-02-2017 , 03:50   Re: Detect if player1 and player2 is aiming each other?
Reply With Quote #8

Quote:
Originally Posted by Craxor View Post
if( get_user_team( id1 ) != get_user_team( id2 ) )
Thank you, sir.
I know how to distinguish the stance by using the cs_get_user_team native.
What I am trying to explain is actually how I can properly/exactly catch the index of the enemy( as I don't have a specific index( id2 ) for the enemy in my function...), is it simply by making the new 'id2'?
PHP Code:
new id2Ent], body
get_user_aiming
id2Ent], body 
Will these lines will automatically store the enemy's index into 'id2' ?
Sorry for any inconvenient...

Last edited by Kotoamatsukami; 03-02-2017 at 04:26.
Kotoamatsukami is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-02-2017 , 07:21   Re: Detect if player1 and player2 is aiming each other?
Reply With Quote #9

PHP Code:
new idiEnt[2], iBody
get_user_aiming
(idiEnt[0], iBody)
get_user_aiming(iEnt[0], iEnt[1], iBody)

// iEnt[0] = id's enemy
// iEnt[1] = id enemy's enemy = id 
__________________

Last edited by OciXCrom; 03-02-2017 at 07:22.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Kotoamatsukami
Member
Join Date: Jan 2017
Location: Malaysia
Old 03-02-2017 , 10:01   Re: Detect if player1 and player2 is aiming each other?
Reply With Quote #10

Like this?
PHP Code:
public Randomid )
{
    if( !
is_user_aliveid ) ) return;
    
    new 
iEnt], body;
    
    
get_user_aimingidiEnt], body )
    
get_user_aimingiEnt], iEnt], body )
    
    if( 
iEnt] == id && cs_get_user_teamid ) != cs_get_user_teamiEnt] ) )
    {
        
// do something ....
    
}

Sorry for being so opposite, I am here to clarify things up. Isn't your code is same as the original code that I posted at the first post?

My enormous apology, I am not being rude or picky. It's just that I'd like to hear your opinion on your code...
Kotoamatsukami is offline
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 05:14.


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