AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Max Distance. (https://forums.alliedmods.net/showthread.php?t=112928)

Merc3y 12-22-2009 06:46

Max Distance.
 
Does anyone know how to get max distance ?

Example like:

A terrorist is near a counter terrorist, then the terrorist the one who is near the counter terrorist will be slay right away.

Arkshine 12-22-2009 07:18

Re: Max Distance.
 
Use get_distance() or get_distance_f() to know the distance between 2 origins.

Merc3y 12-22-2009 07:45

Re: Max Distance.
 
Quote:

Originally Posted by Arkshine (Post 1026709)
Use get_distance() or get_distance_f() to know the distance between 2 origins.

I not too sure about this.

Maybe like this ?

PHP Code:

new cvar_maxdistance
 
public plugin_init( )
{
         
cvar_maxdistance register_cvar"maxdistance""600" )
}
 
new 
Float:fMyOrigin]
entity_get_vectoridEV_VEC_originfMyOrigin )
 
new 
Float:fTargetOrigin]
entity_get_vectortargetEV_VEC_originfTargetOrigin )
 
if ( ( 
get_distance_ffMyOriginfTargetOrigin ) > get_pcvar_numcvar_maxdistance ) )
{
      
user_killid )



Exolent[jNr] 12-22-2009 10:37

Re: Max Distance.
 
Of course that code alone won't work but your idea is correct.

Merc3y 12-22-2009 11:49

Re: Max Distance.
 
Quote:

Originally Posted by Exolent[jNr] (Post 1026893)
Of course that code alone won't work but your idea is correct.

Alright :), but i don't know which one to choose ?

Using playerprethink ?

Can give me some example ?

Exolent[jNr] 12-22-2009 12:02

Re: Max Distance.
 
This should work:
Code:
#include < amxmodx > #include < engine > #include < cstrike > const Float:MAX_DISTANCE = 300.0; public plugin_init( ) {     register_plugin( "Team Distance?", "0.0.1", "Exolent" ); } public client_PreThink( iPlayer ) {     if( is_user_alive( iPlayer ) && cs_get_user_team( iPlayer ) == CS_TEAM_CT ) {         static iPlayers[ 32 ], iNum;         get_players( iPlayers, iNum, "ae", "TERRORIST" );                 static iTarget;         for( new i = 0; i < iNum; i++ ) {             iTarget = iPlayers[ i ];                         if( entity_range( iPlayer, iTarget ) < MAX_DISTANCE ) {                 user_kill( iTarget );                 client_print( iTarget, print_chat, "You were too close to a CT." );             }         }     } }


All times are GMT -4. The time now is 04:13.

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