WarCraft: Source

 

Near

Page history last edited by freddukes@... 1 yr ago

Near


 

The near command runs a check to see who is in range, then it will run the return function for every user inside... The return function takes 2 parameters; the first is the user that was inside the range, the second is the person that is running the near command from...

 

The correct syntax is:

 

wcs.Command(<userid>).Near(<distance>, <call-back function>, [optional: Identifier])

 

  • Userid - This is the user that will be running the Near command. The distance is relative to the user
  • Distance - The distance that you'd like to check for players inside... (in game units... around 40 game units per meter)
  • Call-back function - For every user within range, it'll run this function
  • Optional: Identifier - All the players who match this type of identification will only be checked.. e.g. '#ct' will check only ct's inside the range..
    • #all - all players
    • #ct - counter-terrorists
    • #t - terrorists
    • #spec - spectators
    • #un - unassigned (people who never joined a team or spec after connecting)
    • #dead - dead players
    • #alive - living players
    • #human - real players
    • #bot - bots

 


Example:

 

my_list = []

# Create a list

 

 

def player_say(ev):

    if ev['text'] == "test":

        filter = '#t'

        if ev['es_userteam'] == '2': then filter = '#ct'

        # The filter by default is terrorist... It then checks if the user is a terrorist, if so, overwrite the default filter with '#ct'... Otherwise, the player is a Counter-Terrorist, and the filter is left as '#t'

        wcs.Command(ev['userid']).Near(500, AddToList, filter)

        # Run the Near Command, and make the function AddToList

        es.tell(ev['userid'],'#green','There are %s players within 500 units of you (22.5m)'%len(my_list))

        # Tell the user how many enemies there are near him

 

def AddToList(enemy, userid):

    # The enemy is the person who is in range of the userid

    my_list.append(enemy)

    # Add their userid to list

Comments (0)

You don't have permission to comment on this page.