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

Detect players origins


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
raizo11
BANNED
Join Date: Dec 2013
Location: https://t.me/pump_upp
Old 09-05-2019 , 07:00   Detect players origins
Reply With Quote #1

I want to detect if 2 or more players from terrorsits is close to 1 from Ct... Any ideea?

I can't think of other ways

Code:
public client_PreThink()
{ 
    static X[32], Y[32], XNum, YNum, Float:XOrigin[ 3 ], Float:YOrigin[ 3 ], Float:fDistance

    get_players(X, XNum, "ae", "TERRORIST") 
    get_players(Y, YNum, "ae", "CT") 

    pev(XNum, pev_origin, XOrigin)
    pev(YNum, pev_origin, YOrigin)

    fDistance = get_distance_f( XOrigin, YOrigin)

    if( fDistance <= 100.0)
    {
        if (XNum == 2 && YNum == 1) 
        { 
            // something
        } 
    }
}
raizo11 is offline
Send a message via ICQ to raizo11 Send a message via AIM to raizo11 Send a message via MSN to raizo11 Send a message via Yahoo to raizo11 Send a message via Skype™ to raizo11
E1_531G
Senior Member
Join Date: Dec 2017
Old 09-05-2019 , 07:02   Re: Detect players origins
Reply With Quote #2

XNum and YNum aren't indexes, they hold the amount of players.
__________________
My English is A0

Last edited by E1_531G; 09-05-2019 at 11:19.
E1_531G is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 09-05-2019 , 10:40   Re: Detect players origins
Reply With Quote #3

Don't use client think use a 1.0 loop task or entity think 1.0 sec length for such purpose.

Then use find entity in sphere natives.

Also your "way" doesn't work. As e1531G stated.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 09-05-2019 at 10:56.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
raizo11
BANNED
Join Date: Dec 2013
Location: https://t.me/pump_upp
Old 09-05-2019 , 18:15   Re: Detect players origins
Reply With Quote #4

already not working

Code:
#include <amxmodx>
#include <fakemeta>
#include <cstrike>
 
public plugin_init() 
{     
	register_forward(FM_TraceHull,"fm_tracehull",1);
}


public fm_tracehull(Float:start[3],Float:end[3],noMonsters,hull,id,trace)
{
	if(!is_user_connected(id) || !is_user_alive(id))
		return FMRES_IGNORED;
	
	new hit = get_tr2(trace,TR_pHit);

	if(!is_user_alive(hit))
		return FMRES_IGNORED;

	new CsTeams:team = cs_get_user_team(id)

	new Origin[3]
	get_user_origin(id, Origin);
	
	new enemycount=0
	
	new ent = -1
	while((ent = engfunc(EngFunc_FindEntityInSphere, ent, Origin, 150.0)) != 0)
	{
		if(!pev_valid(ent) || !is_user_alive(ent))
			continue
		
		if (team==cs_get_user_team(ent))
			continue
		
		enemycount++
		
		if (enemycount>1)
		{
			set_tr2(trace,TR_flFraction,1.0);
			client_print(0, print_chat, "[TEST]");
		}
	}

	return FMRES_IGNORED;
}

Last edited by raizo11; 09-05-2019 at 18:15.
raizo11 is offline
Send a message via ICQ to raizo11 Send a message via AIM to raizo11 Send a message via MSN to raizo11 Send a message via Yahoo to raizo11 Send a message via Skype™ to raizo11
JocAnis
Veteran Member
Join Date: Jun 2010
Old 09-05-2019 , 18:15   Re: Detect players origins
Reply With Quote #5

First time seeing client prethink without index...so its serverframe() ? Go with id there and loop
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)
JocAnis is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-05-2019 , 18:39   Re: Detect players origins
Reply With Quote #6

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <cstrike>
 
public plugin_init() 
{     
    
set_task0.1 "FindPlayers" , .flags="b" );
}


public 
FindPlayers()
{
    new 
iPlayers32 ] , iNum iPlayer Float:fOrigin] , iEntity iEnemyCount szName32 ];
    
    
get_playersiPlayers iNum "ae" "CT" );

    for ( new 
iNum i++ )
    {
        
iPlayer iPlayers];
        
        
peviPlayer pev_origin fOrigin );
        
        
iEntity = -1;
        
iEnemyCount 0;
        
        while( ( 
iEntity engfuncEngFunc_FindEntityInSphere iEntity fOrigin 150.0 ) ) != )
        {
            if ( 
is_user_aliveiEntity ) && ( cs_get_user_teamiEntity ) == CS_TEAM_T ) )
                
iEnemyCount++;
        }
        
        if ( 
iEnemyCount >= )
        {
            
get_user_nameiPlayer szName charsmaxszName ) );
            
client_printprint_chat "%d enemies near %s" iEnemyCount szName );
        }
    }

__________________

Last edited by Bugsy; 09-07-2019 at 00:13.
Bugsy is offline
raizo11
BANNED
Join Date: Dec 2013
Location: https://t.me/pump_upp
Old 09-05-2019 , 19:04   Re: Detect players origins
Reply With Quote #7

Thanks !
raizo11 is offline
Send a message via ICQ to raizo11 Send a message via AIM to raizo11 Send a message via MSN to raizo11 Send a message via Yahoo to raizo11 Send a message via Skype™ to raizo11
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 09-06-2019 , 06:38   Re: Detect players origins
Reply With Quote #8

Quote:
Originally Posted by Bugsy View Post
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <cstrike>
 
public plugin_init() 
{     
    
set_task0.1 "FindPlayers" , .flags="b" );
}


public 
FindPlayers()
{
    new 
iPlayers32 ] , iNum iPlayer Float:fOrigin] , iEntity iEnemyCount szName32 ];
    
    
get_playersiPlayers iNum "ae" "CT" );

    for ( new 
iNum i++ )
    {
        
iPlayer iPlayers];
        
        
peviPlayer pev_origin fOrigin );
        
        
iEntity = -1;
        
iEnemyCount 0;
        
        while( ( 
iEntity engfuncEngFunc_FindEntityInSphere iEntity fOrigin 150.0 ) ) != )
        {
            if ( 
is_user_aliveiEntity ) && ( cs_get_user_teamiEntity ) == CS_TEAM_T ) )
                
iEnemyCount++;
        }
        
        if ( 
iEnemyCount >= )
        {
            
get_user_nameiPlayer szName charsmaxszName ) );
            
client_printprint_chat "%d enemies near %s" iEnemyCount szName );
        }
    }

The variables could be created globally to avoid creating every 10th of a second.
__________________
edon1337 is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 09-06-2019 , 22:27   Re: Detect players origins
Reply With Quote #9

- was drunk enough to ask whoops-
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)

Last edited by JocAnis; 09-07-2019 at 08:43.
JocAnis is offline
Old 09-06-2019, 23:24
Bugsy
This message has been deleted by Bugsy.
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 01:22.


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