import es import gamethread import popuplib updaterate = 1 # How often the menu should update (in seconds) style = 2 # The style the spectators are shown ( 1 = hud hint, 2 = popup, 3 = toptext [You can set the updaterate pretty high with toptext]) max_length = 8 # The maximum length a name may have (Will be shortened otherwise: Absolute123 would be shortened to Absolu..) advert_time = 60 # an advert comes every advert_time\updaterate seconds info = es.AddonInfo() info.author = "AbSoLuTe" info.name = "Tell Spectator names" info.basename = "tellspec" info.version = "1.0" info.url = "http://addons.eventscripts.com/addons/view/%s"%info.basename info.description = "Shows your current spectators" es.ServerVar(info.basename, info.version, info.description + " made by " + info.author).makepublic() enabled = [] advert = 0 def load(): es.regsaycmd('!disable',"%s/disabled"%info.basename,"Disables or Enables the Menu") def unload(): es.unregsaycmd('!disable') def disabled(): uid = int(es.getcmduserid()) if uid in enabled: es.tell(uid,"#multi","#greenYou will no longer see the spectator menu") enabled.remove(uid) else: es.tell(uid,"#multi","#greenYou see the spectator menu again") enabled.append(uid) def player_connect(event_var): uid = event_var['userid'] enabled.append(int(uid)) def player_disconnect(event_var): uid = event_var['userid'] enabled.remove(int(uid)) def checkloop(): global advert if not advert: advert = 0 advert = advert + 1 if advert == advert_time: es.msg("#multi","#greenType #lightgreen'!disable'#green to toggle the spectator menu") for uid in es.getUseridList(): if es.getplayersteamid(uid) == "BOT": continue if not int(uid) in enabled: continue if not es.getplayerprop(uid, "CCSPlayer.baseclass.pl.deadflag"): spectators = "" comparehandle = es.getplayerhandle(uid) for specs in es.getUseridList(): if int(es.getplayerprop(specs, "CCSPlayer.baseclass.m_iObserverMode")) in (1,3,4): if es.getplayerprop(specs, 'CBasePlayer.m_hObserverTarget') == comparehandle: if es.getplayerprop(specs, "CCSPlayer.baseclass.pl.deadflag"): if len(es.getplayername(specs)) > max_length: realname = es.getplayername(specs)[:max_length-2] + ".." else: realname = es.getplayername(specs) if style == 3: spectators = spectators + "," + realname else: spectators = spectators + "\n " + realname if spectators: if style == 3: es.toptext(uid,1,"#grey","Current Spectators: " + spectators[1:]) elif style == 2: es.menu(1, uid, "Current spectators:" + spectators + "\nType !disable to disable") elif style == 1: es.usermsg('create', 'hud', 'HintText') es.usermsg('write', 'byte', 'hud', -1) es.usermsg('write', 'string', 'hud', "Current Spectators:" + spectators) es.usermsg('send', 'hud', uid) es.usermsg('delete', 'hud') gamethread.delayed(updaterate,checkloop) gamethread.delayed(updaterate,checkloop)