AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Teammate in range - help (https://forums.alliedmods.net/showthread.php?t=76034)

anakin_cstrike 08-17-2008 05:20

Teammate in range - help
 
Hi, i've made a script that does something if a players is at x distance from his teammate. The problem is that 'something' is aplyed to all teammate...also i want to check if a teammate is not in the player's range, distance (specified).
And make that 'something' only to one player...that is at x distance from his nearby teammate, if you understand what i mean.
Thanks.

ot_207 08-17-2008 08:47

Re: Teammate in range - help
 
This is a function that will help you find the closest teammate ->

PHP Code:

stock find_closest_team_mate(player,Float:radius)
{
    new 
id = -1
    
new Float:origin[3]
    new 
close = -1Float:minim 8908298.0
    pev
(player,pev_origin,origin)

    while ((
id engfunc(EngFunc_FindEntityInSphereidoriginradius)))
    {
        if (!
is_user_alive(id))
            continue
        if (!(
cs_get_user_team(id) == cs_get_user_team(player)))
            continue
        new 
Float:origin2[3]
        
pev(id,pev_origin,origin2)
        new 
Float:distanceFloat:difference[3]
        
xs_vec_sub(origin,origin2,difference)
        
distance xs_vec_len(difference)
        if (
distance minim)
        {
            
minim distance
            close 
id
        
}
    }

    return 
close    


Not tested but should work!


All times are GMT -4. The time now is 03:06.

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