Results 1 to 4 of 4

Thread: Find the shortest path to the player.

  1. #1
    Private
    Join Date
    Aug 2012
    Posts
    78
    Thanks
    20
    Thanked 10 Times in 5 Posts

    Find the shortest path to the player.

    Hey.
    Which to use function to check distances between players?
    I would like to check on a regular basis that the player is closer to me.

    I must use BulletTrace function?

  2. #2
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    It's like:

    PHP Code:

        players 
    getentarray("player""classname");
        
    playerNearestDistance 9999999999;
        
    playerNearest undefined;
        for (
    i=0i<players.sizei++)
        {
            if (
    self == players[i])
                continue;
            
    distanceToThis distancesquared(players[i].originself.origin);
            if (
    distanceToThis playerNearestDistance)
            {
                
    playerNearestDistance distanceToThis;
                
    playerNearest players[i];
            }
        }
        
        if (
    isDefined(playerNearest))
            
    iprintln("found the nearest player: "playerNearest.origin" id: "playerNearest getEntityNumber());
        else
            
    iprintln("no near player"); 
    timescale 0.01

  3. The Following User Says Thank You to kung foo man For This Useful Post:

    Moczulak (29th October 2013)

  4. #3
    Private
    Join Date
    Aug 2012
    Posts
    78
    Thanks
    20
    Thanked 10 Times in 5 Posts
    Thanks It works :P

  5. #4
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Kung, use isdefined(playerNearest) instead of playerNearest.

  6. The Following User Says Thank You to IzNoGoD For This Useful Post:

    kung foo man (30th October 2013)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •