Guest User

Untitled

a guest
Jan 13th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.21 KB | None | 0 0
  1. class Distance(object):
  2.     def __init__(self):
  3.         self.userids = []
  4.  
  5.     def start(self):
  6.         gamethread.delayedname(1, 'distance', self.checkDistance, ())
  7.  
  8.     def stop(self):
  9.         gamethread.cancelDelayed('distance')
  10.  
  11.     def checkDistance(self):
  12.         gamethread.delayedname(1, 'distance', self.checkDistance, ())
  13.         for i in self.userids:
  14.             x1, y1, z1 = es.getplayerlocation(i)
  15.             for j in playerlib.getUseridList('#ct, #alive'):
  16.                 x2,y2,z2 = es.getplayerlocation(j)
  17.                 distances[self.getDistance(x1,y1,z1,x2,y2,z2)] = j             
  18.             #if len(distances.keys()) > 0:
  19.                 #dist = min(distances.keys())
  20.                 #enemy = distances[dist]
  21.                 #usermsg.hudhint(i, 'Distance Radar:\n----------\n%s\nin %.2fm'% (es.getplayername(enemy), dist))
  22.             es.msg(i, distances)
  23.  
  24.     def getDistance(self, x1,y1,z1,x2,y2,z2):
  25.         return math.sqrt((x1-x2)**2 + (y1-y2)**2 + (z1-z2)**2)
  26.  
  27.     def add(self, userid):
  28.         if userid not in self.userids:
  29.             self.userids.append(userid)
  30.            
  31.     def remove(self, userid):
  32.         if userid in self.userids:
  33.             self.userids.remove(userid)
Add Comment
Please, Sign In to add comment