def restart(): """ Teleports player to first level """ userid = es.getcmduserid() if (es.getplayerteam(userid) != 1): entities = es.createentitylist('info_teleport_destination') for i in entities: if (es.entitygetvalue(i, 'targetname') == "timer_stage1"): x = es.getplayerprop( userid, "CBasePlayer.localdata.m_vecVelocity[0]") * -1 / 2 y = es.getplayerprop( userid, "CBasePlayer.localdata.m_vecVelocity[1]") * -1 / 2 z = es.getplayerprop( userid, "CBasePlayer.localdata.m_vecVelocity[2]") * -1 / 2 es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", es.createvectorstring(x, y, z)) gamethread.delayed( 0.01, es.setplayerprop, (userid, "CBasePlayer.localdata.m_vecBaseVelocity", es.createvectorstring(x, y, z))) startPos = es.entitygetvalue(i, 'origin').split(' ') startAng = es.entitygetvalue(i, 'angles').split(' ') gamethread.delayed( 0.01, es.setpos, (userid, startPos[0], startPos[1], startPos[2])) es.setang(userid, startAng[0], startAng[1], startAng[2])
def stageMenu_select(userid, choice, popupid): if (es.getplayerteam(userid) == 1): return if (userid in started): started.remove(userid) for a in range(1, 26): if (choice == '%s' % a): entities = es.createentitylist('info_teleport_destination') for b in entities: if (es.entitygetvalue(b, 'targetname') == "timer_stage%s" % a): x = es.getplayerprop( userid, "CBasePlayer.localdata.m_vecVelocity[0]") * -1 / 2 y = es.getplayerprop( userid, "CBasePlayer.localdata.m_vecVelocity[1]") * -1 / 2 z = es.getplayerprop( userid, "CBasePlayer.localdata.m_vecVelocity[2]") * -1 / 2 es.setplayerprop( userid, "CBasePlayer.localdata.m_vecBaseVelocity", es.createvectorstring(x, y, z)) gamethread.delayed( 0.01, es.setplayerprop, (userid, "CBasePlayer.localdata.m_vecBaseVelocity", es.createvectorstring(x, y, z))) startPos = es.entitygetvalue(b, 'origin').split(' ') startAng = es.entitygetvalue(b, 'angles').split(' ') es.setpos(userid, startPos[0], startPos[1], startPos[2]) es.setang(userid, startAng[0], startAng[1], startAng[2]) if (int(choice) > 7): gamethread.delayed(0.5, stageMenu.sendPage, (userid, (math.ceil(float(choice) / float(7))))) else: gamethread.delayed(0.5, stageMenu.send, (userid))
def bonusMenu_select(userid, choice, popupid): if (es.getplayerteam(userid) == 1): return for a in range(1, 4): if (choice == '%s' % a): entities = es.createentitylist('info_teleport_destination') for b in entities: if (es.entitygetvalue(b, 'targetname') == "timer_bonus%s" % a): x = es.getplayerprop( userid, "CBasePlayer.localdata.m_vecVelocity[0]") * -1 / 2 y = es.getplayerprop( userid, "CBasePlayer.localdata.m_vecVelocity[1]") * -1 / 2 z = es.getplayerprop( userid, "CBasePlayer.localdata.m_vecVelocity[2]") * -1 / 2 es.setplayerprop( userid, "CBasePlayer.localdata.m_vecBaseVelocity", es.createvectorstring(x, y, z)) gamethread.delayed( 0.01, es.setplayerprop, (userid, "CBasePlayer.localdata.m_vecBaseVelocity", es.createvectorstring(x, y, z))) startPos = es.entitygetvalue(b, 'origin').split(' ') startAng = es.entitygetvalue(b, 'angles').split(' ') es.setpos(userid, startPos[0], startPos[1], startPos[2]) es.setang(userid, startAng[0], startAng[1], startAng[2])
def getPushAngle(userid, view_angle, horiz, vert, vert_override=False): """ Pushes the player along his or her view vector. Call without underscore, i.e.: player.push(horiz, vert, vert_override) """ myVector = view_angle horzX = float(horiz) * float(myVector[0]) horzY = float(horiz) * float(myVector[1]) if str(vert_override) == '0': vertZ = float(myVector[2]) * float(vert) else: vertZ = vert myNewVector = es.createvectorstring(horzX, horzY, vertZ) es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", myNewVector)
def StopSpeed(userid): velocity_x = float( es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[0]')) velocity_y = float( es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[1]')) velocity_z = float( es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[2]')) myNewVector2 = es.createvectorstring(-velocity_x, -velocity_y, -velocity_z) es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", myNewVector2)
def vectors(): y = es.createvectorstring(3.5,4.5,6.8) if y != "3.500000,4.500000,6.800000": print("failed",y) else: print("success1",y) z = es.splitvectorstring(y) if z[0] != 3.5 or z[1] != 4.5 or round(z[2],1) != 6.8: print("failed2",z) else: print("success2",z)
def set_boost(userid, cp): steamid = es.getplayersteamid(userid) if cp == 0: client[steamid]["save_speed_stack"] += 1 myNewVector2 = es.createvectorstring(client[steamid]['save_speed'][0], client[steamid]['save_speed'][1], client[steamid]['save_speed'][2]) # es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", myNewVector) es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", myNewVector2) if client[steamid]["save_speed_stack"] > 1: esc.tell(userid, "#124,252,0[ Trikz] #245,0,61Speed has now been stacked (multiplier X%s" % client[steamid]["save_speed_stack"]) client[steamid]["save_speed_stack"] -= 1 else: client[steamid]["save_speed_stack_2"] += 1 myNewVector2 = es.createvectorstring(client[steamid]['save_speed_2'][0], client[steamid]['save_speed_2'][1], client[steamid]['save_speed_2'][2]) # es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", myNewVector) es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", myNewVector2) if client[steamid]["save_speed_stack_2"] > 1: esc.tell(userid, "#124,252,0[ Trikz] #245,0,61Speed has now been stacked (multiplier X%s" % client[steamid]["save_speed_stack"]) client[steamid]["save_speed_stack_2"] -= 1
def restart(): """ Teleports player to first level """ userid = es.getcmduserid() if (es.getplayerteam(userid) != 1): entities = es.createentitylist('info_teleport_destination') for i in entities: if (es.entitygetvalue(i, 'targetname') == "timer_stage1"): x = es.getplayerprop(userid, "CBasePlayer.localdata.m_vecVelocity[0]") * -1 / 2 y = es.getplayerprop(userid, "CBasePlayer.localdata.m_vecVelocity[1]") * -1 / 2 z = es.getplayerprop(userid, "CBasePlayer.localdata.m_vecVelocity[2]") * -1 / 2 es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", es.createvectorstring(x, y, z)) gamethread.delayed(0.01, es.setplayerprop, (userid, "CBasePlayer.localdata.m_vecBaseVelocity", es.createvectorstring(x, y, z))) startPos = es.entitygetvalue(i, 'origin').split(' ') startAng = es.entitygetvalue(i, 'angles').split(' ') gamethread.delayed(0.01, es.setpos, (userid, startPos[0], startPos[1], startPos[2])) es.setang(userid, startAng[0], startAng[1], startAng[2])
def bonusMenu_select(userid, choice, popupid): if (es.getplayerteam(userid) == 1): return for a in range(1,4): if (choice == '%s' % a): entities = es.createentitylist('info_teleport_destination') for b in entities: if (es.entitygetvalue(b, 'targetname') == "timer_bonus%s" % a): x = es.getplayerprop(userid, "CBasePlayer.localdata.m_vecVelocity[0]") * -1 / 2 y = es.getplayerprop(userid, "CBasePlayer.localdata.m_vecVelocity[1]") * -1 / 2 z = es.getplayerprop(userid, "CBasePlayer.localdata.m_vecVelocity[2]") * -1 / 2 es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", es.createvectorstring(x, y, z)) gamethread.delayed(0.01, es.setplayerprop, (userid, "CBasePlayer.localdata.m_vecBaseVelocity", es.createvectorstring(x, y, z))) startPos = es.entitygetvalue(b, 'origin').split(' ') startAng = es.entitygetvalue(b, 'angles').split(' ') es.setpos(userid, startPos[0], startPos[1], startPos[2]) es.setang(userid, startAng[0], startAng[1], startAng[2])
def push(users, *axes): '''Push a player in the given direction...''' # Get the given Vector... vector = vecmath.Vector(*axes) # Loop through all matching players... for userid in _get_matching_players(users): # Is the player dead? if es.getplayerprop(userid, 'CBasePlayer.pl.deadflag'): # Don't go further... continue # Push the player... es.setplayerprop(userid, 'CBasePlayer.localdata.m_vecBaseVelocity', es.createvectorstring(*vector))
def stageMenu_select(userid, choice, popupid): if (es.getplayerteam(userid) == 1): return if (userid in started): started.remove(userid) for a in range(1,26): if (choice == '%s' % a): entities = es.createentitylist('info_teleport_destination') for b in entities: if (es.entitygetvalue(b, 'targetname') == "timer_stage%s" % a): x = es.getplayerprop(userid, "CBasePlayer.localdata.m_vecVelocity[0]") * -1 / 2 y = es.getplayerprop(userid, "CBasePlayer.localdata.m_vecVelocity[1]") * -1 / 2 z = es.getplayerprop(userid, "CBasePlayer.localdata.m_vecVelocity[2]") * -1 / 2 es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", es.createvectorstring(x, y, z)) gamethread.delayed(0.01, es.setplayerprop, (userid, "CBasePlayer.localdata.m_vecBaseVelocity", es.createvectorstring(x, y, z))) startPos = es.entitygetvalue(b, 'origin').split(' ') startAng = es.entitygetvalue(b, 'angles').split(' ') es.setpos(userid, startPos[0], startPos[1], startPos[2]) es.setang(userid, startAng[0], startAng[1], startAng[2]) if (int(choice) > 7): gamethread.delayed(0.5, stageMenu.sendPage, (userid, (math.ceil(float(choice) / float(7))))) else: gamethread.delayed(0.5, stageMenu.send, (userid))
def pushto(users, location, force): '''Push a player to the given location...''' # Get the given Vector... vector = vecmath.Vector(location) # Loop through all matching players... for userid in _get_matching_players(users): # Is the player dead? if es.getplayerprop(userid, 'CBasePlayer.pl.deadflag'): # Don't go further... continue # Get the vector from the player location... vector -= vecmath.Vector(es.getplayerlocation(userid)) # Multiply the force... vector *= float(force) # Push the player... es.setplayerprop(userid, 'CBasePlayer.localdata.m_vecBaseVelocity', es.createvectorstring(*vector))
def player_say(event_var): """ Executed when a player talks. Run the chat commands """ message = event_var['text'].strip() userid = int(event_var['userid']) if message == "!surftimer": """ Admin menu """ if isAuthed(userid): adminPopup.send(userid) elif message.startswith("!wr"): """ Display world record time to all players """ sortedList = mk_sortDict(str(currentMap)) es.tell(userid, "#multi", "#green[Surf Timer] #default- #lightgreen%s holds the world record with time #default%s#lightgreen." % (mapDicts[str(currentMap)][sortedList[0][0]]["name"], formatTime(sortedList[0][1]))) elif message.startswith("!top"): """ Display a popup with all times for that map, or if a map was present as an argument, display for that map. !top // display current map records !top <map name> // displays <map name>'s current records """ if message.count(" "): mapName = " ".join(message.split()[1:]) else: mapName = str(currentMap) if mapName not in mapDicts: es.tell(userid, "#multi", "#green[Surf Timer] #default- #lightgreenSorry, we cannot find %s on the server." % mapName) return if "startpos" not in mapDicts[mapName]: return if "endpos" not in mapDicts[mapName]: return topMenu = popuplib.easymenu("topMenu%s" % userid, "_popup_choice",None) topMenu.settitle("[Map Records : %s]" % mapName) sortedList = mk_sortDict(mapName) if sortedList: lx = 1 for top in sortedList: topMenu.addoption('an', "Rank " + str(lx) + ": " + mapDicts[mapName][top[0]]["name"] + " " + formatTime(mapDicts[mapName][top[0]]["time"])) lx += 1 else: topMenu.addoption('an', "[No places recorded]") topMenu.send(userid) elif message.startswith("!pr"): """ Similar to a rank command. Tell the user their time or another person's time on that current map. !pr // displays their time for that map !pr <userid/name/steamid> // displays the user's time for that map TODO: Add in an additional [map] argument and test for the last argument and see if it's a dict item. If so, then they want information for that map. """ mapName = str(currentMap) if mapName not in mapDicts: return if "startpos" not in mapDicts[mapName]: return if "endpos" not in mapDicts[mapName]: return if message.count(" "): message = " ".join(message.split()[1:]) target = es.getuserid(message) else: target = userid if not target: es.tell(userid, "#multi", "#green[Surf Timer] #default- #lightgreenSorry, we cannot find %s on the server." % message) return steamid = es.getplayersteamid(target) (_pos, _len) = mk_sortDictIndex(mapName, steamid) for player in es.getUseridList(): if (_pos > 0): sortedList = mk_sortDict(str(currentMap)) dictObject = mapDicts[mapName][steamid] es.tell(player, "#multi", "#green[Surf Timer] #default- #lightgreen%s is ranked #default%s/%s #lightgreenwith time #default%s #lightgreen(#default+%s#lightgreen)." % (dictObject['name'], _pos, _len, formatTime(dictObject['time']), formatTime(dictObject['time'] - sortedList[0][1]))) else: es.tell(player, "#multi", "#green[Surf Timer] #default- #lightgreen%s has not yet completed this map." % es.getplayername(target)) elif message.startswith("!stage"): """ Opens a stage selection menu """ mapName = str(currentMap) global stageMenu stageMenu = popuplib.easymenu('stageMenu', '_popup_choice', stageMenu_select) stageMenu.settitle("[Stage Menu : %s]" % (mapName)) entities = es.createentitylist('info_teleport_destination') """ Create Stage Menu """ stages = 0 for a in range(1,26): for b in entities: if (es.entitygetvalue(b, 'targetname') == "timer_stage%s" % a): stageMenu.addoption('%s' % a, "Stage %s" % a) stages += 1 if (stages > 1): stageMenu.send(userid) if (userid in started): es.tell(userid, "#green", "Teleporting to a stage while the timer is active will clear your time") else: es.tell(userid, "#multi", "#green[Surf Timer] #default- #lightgreenThis is not a staged map.") elif message.startswith("!bonus"): """ Opens a bonus selection menu """ mapName = str(currentMap) global bonusMenu bonusMenu = popuplib.easymenu('bonusMenu', '_popup_choice', bonusMenu_select) bonusMenu.settitle("[Bonus Menu : %s]" % (mapName)) entities = es.createentitylist('info_teleport_destination') bonuses = 0 """ Set up bonus menu and count the number of bonuses (up to 3 bonuses) """ for a in range(1,4): for b in entities: if (es.entitygetvalue(b, 'targetname') == "timer_bonus%s" % a): bonuses += 1 bonusMenu.addoption('%s' % a, "Bonus %s" % a) if (bonuses > 1): bonusMenu.send(userid) elif (bonuses == 1): entities = es.createentitylist('info_teleport_destination') for i in entities: if (es.entitygetvalue(i, 'targetname') == "timer_bonus1"): x = es.getplayerprop(userid, "CBasePlayer.localdata.m_vecVelocity[0]") * -1 / 2 y = es.getplayerprop(userid, "CBasePlayer.localdata.m_vecVelocity[1]") * -1 / 2 z = es.getplayerprop(userid, "CBasePlayer.localdata.m_vecVelocity[2]") * -1 / 2 es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", es.createvectorstring(x, y, z)) gamethread.delayed(0.01, es.setplayerprop, (userid, "CBasePlayer.localdata.m_vecBaseVelocity", es.createvectorstring(x, y, z))) startPos = es.entitygetvalue(i, 'origin').split(' ') startAng = es.entitygetvalue(i, 'angles').split(' ') es.setpos(userid, startPos[0], startPos[1], startPos[2]) es.setang(userid, startAng[0], startAng[1], startAng[2]) else: es.tell(userid, "#multi", "#green[Surf Timer] #default- #lightgreenCurrent map has no bonuses.")
def setfx(args): if len(args) == 5: type = args[0] if not type in 'freeze|jetpack|god|noblock|burn|speed|health|armor|cash|gravity|ulti_immunity|disguiser|1stclip|2ndclip|longjump|lj|invisp|location|blind|evade': logging.log('wcs_setfx: '+type+' is not a valid type.') type = 0 uid = args[1] op = args[2] if not op in '=|+|-': op = "=" value = float(args[3]) time = float(args[4]) player = playerlib.getPlayer(uid) if type == 'freeze': if op == '=': speed = float(player.getSpeed()) wcsgroup.setUser(uid, 'speed', speed) if value >= 1: player.setSpeed(0) if time > 0: gamethread.delayed(time, player.setSpeed, speed, 0) else: logging.log('wcs_setfx: '+type+' can only use values 1 or 0.') if type == 'god': if op == '=': player.godmode(int(value)) if time > 0: gamethread.delayed(time, player.godmode, 0, 0) else: logging.log('wcs_setfx: '+type+' can only use values 1 or 0.') if type == 'ulti_immunity': if op == '=': wcsgroup.setUser(uid, 'ulti_immunity', value) if time > 0: if value == 1: value = 0 if value == 0: value = 1 wcsgroup.setUser(uid, 'ulti_immunity', value) else: logging.log('wcs_setfx: '+type+' can only use values 1 or 0.') if type == 'jetpack': if op == '=': player.jetpack(int(value)) if time > 0: gamethread.delayed(time, player.jetpack, 0, 0) else: logging.log('wcs_setfx: '+type+' can only use values 1 or 0.') if type == 'noblock': if op == '=': player.noblock(int(value)) if time > 0: gamethread.delayed(time, player.noblock, 0, 0) else: logging.log('wcs_setfx: '+type+' can only use values 1 or 0.') if type == 'burn': if op == '=': if value == 1: es.set('wcs_uid', uid) es.set('wcs_time', time) es.server.queuecmd('es wcs fire server_var(wcs_uid) server_var(wcs_time)') es.delayed(time, 'es wcs extinguish server_var(wcs_uid)') if value == 0: es.set('wcs_uid', uid) es.server.queuecmd('es wcs extinguish server_var(wcs_uid)') else: logging.log('wcs_setfx: '+type+' can only use values 1 or 0.') if type == 'speed': speed = float(player.getSpeed()) if op == '=': player.setSpeed(value) if time > 0: gamethread.delayed(time, player.setSpeed, speed, 0) if op == '+': player.setSpeed(value+speed) if time > 0: gamethread.delayed(time, player.setSpeed, speed, 0) if op == '-': player.setSpeed(speed-value) if time > 0: gamethread.delayed(time, player.setSpeed, speed, 0) if type == 'health': health = float(player.getHealth()) if op == '=': player.setHealth(value) if time > 0: gamethread.delayed(time, player.setHealth, health, 0) if op == '+': player.setHealth(value+health) if time > 0: gamethread.delayed(time, player.setHealth, health, 0) if op == '-': player.setHealth(health-value) if time > 0: gamethread.delayed(time, player.setHealth, health, 0) if type == 'armor': armor = float(player.getArmor()) if op == '=': player.setArmor(value) if time > 0: gamethread.delayed(time, player.setArmor, armor, 0) if op == '+': player.setArmor(value+armor) if time > 0: gamethread.delayed(time, player.setArmor, armor, 0) if op == '-': player.setArmor(armor-value) if time > 0: gamethread.delayed(time, player.setArmor, armor, 0) if type == 'cash': cash = float(player.getCash()) if op == '=': player.setCash(value) if time > 0: gamethread.delayed(time, player.setCash, cash, 0) if op == '+': player.setCash(value+cash) if time > 0: gamethread.delayed(time, player.setCash, cash, 0) if op == '-': player.setCash(cash-value) if time > 0: gamethread.delayed(time, player.setCash, cash, 0) if type == 'disguiser': team = player.teamid() if team == 2: if es.ServerVar('wcs_game') == cstrike: player.setModel('player/ct_urban') if time > 0: gamethread.delayed(time, player.setModel, 'player/t_pheonix', 0) if es.ServerVar('wcs_game') == dod: player.setModel('player/american_assault') if time > 0: gamethread.delayed(time, player.setModel, 'player/american_assault', 0) if team == 3: if es.ServerVar('wcs_game') == cstrike: player.setModel('player/t_phoenix') if time > 0: gamethread.delayed(time, player.setModel, 'player/ct_urban', 0) if es.ServerVar('wcs_game') == dod: player.setModel('player/german_assault') if es.ServerVar('wcs_game') == dod: player.setModel('player/american_assault') if time > 0: gamethread.delayed(time, player.setModel, 'player/german_assault', 0) if type == '1stclip': weapon = player.getPrimary() clip = float(player.getClip(weapon)) if op == '=': player.setClip(weapon, value) if time > 0: gamethread.delayed(time, player.setClip, (weapon,clip), 0) if op == '+': player.setClip(weapon, value+clip) if time > 0: gamethread.delayed(time, player.setClip, (weapon,clip), 0) if op == '-': player.setClip(weapon, clip-value) if time > 0: gamethread.delayed(time, player.setClip, (weapon,clip), 0) if type == '2ndclip': weapon = player.getSecondary() clip = float(player.getClip(weapon)) if op == '=': player.setClip(weapon, value) if time > 0: gamethread.delayed(time, player.setClip, (weapon,clip), 0) if op == '+': player.setClip(weapon, value+clip) if time > 0: gamethread.delayed(time, player.setClip, (weapon,clip), 0) if op == '-': player.setClip(weapon, clip-value) if time > 0: gamethread.delayed(time, player.setClip, (weapon,clip), 0) if type == 'gravity': if wcsgroup.getUser(uid, 'gravity') != None: gravity = float(wcsgroup.getUser(uid, 'gravity')) else: gravity = 1.0 if op == '=': expand.gravity(uid, value) wcsgroup.setUser(uid, 'gravity', value) if time > 0: gamethread.delayed(time, expand.gravity, (uid, gravity), 0) if op == '+': expand.gravity(uid, value+gravity) wcsgroup.setUser(uid, 'gravity', value+gravity) if time > 0: gamethread.delayed(time, expand.gravity, (uid, gravity), 0) if op == '-': expand.gravity(uid, gravity-value) wcsgroup.setUser(uid, 'gravity', gravity-value) if time > 0: gamethread.delayed(time, expand.gravity, (uid, gravity), 0) if type == 'invisp': try: invisp = int(wcsgroup.getUser(uid, 'invisp')) except: invisp = 255 if value > 100: value = 100 value2 = ((value - 100) * -2.55) if op == '=': player.setColor(255, 255, 255, value2) wcsgroup.setUser(uid, 'invisp', value2) if time > 0: gamethread.delayed(time, player.setColor, (255, 255, 255, invisp), 0) if op == '+': player.setColor(255, 255, 255, value2+invisp) wcsgroup.setUser(uid, 'invisp', value2+invisp) if time > 0: gamethread.delayed(time, player.setColor, (255, 255, 255, invisp), 0) if op == '-': player.setColor(255, 255, 255, invisp-value2) wcsgroup.setUser(uid, 'invisp', invisp-value2) if time > 0: gamethread.delayed(time, player.setColor, (255, 255, 255, invisp), 0) if type == 'longjump': longjump = float(wcsgroup.getUser(uid, 'longjump')) if op == '=': wcsgroup.setUser(uid, 'longjump', value) if time > 0: gamethread.delayed(time, wcsgroup.setUser, (uid, 'longjump', longjump), 0) if op == '+': wcsgroup.setUser(uid, 'longjump', value+longjump) if time > 0: gamethread.delayed(time, wcsgroup.setUser, (uid, 'longjump', longjump), 0) if op == '-': wcsgroup.setUser(uid, 'longjump', longjump-value) if time > 0: gamethread.delayed(time, wcsgroup.setUser, (uid, 'longjump', longjump), 0) if type == 'location': location = float(player.getLocation()) vector = es.createvectorstring(location) if op != '=': logging.log('wcs_setfx: Location uses = only as an operator.') if op == '=': player.setLocation(value) if time > 0: gamethread.delayed(time, player.setLocation, vector) if type == 'blind': if value > 100: value = 100 value2 = ((value - 100) * -2.55) if op == '=': player.blind(value2, time) else: logging.log('wcs_setfx: Blind uses = only as an operator.') if type == 'evade': evade = float(wcsgroup.getUser(uid, 'evade')) if op == '=': wcsgroup.setUser(uid, 'evade', value) if time > 0: gamethread.delayed(time, wcsgroup.setUser, (uid, 'evade', evade), 0) if op == '+': wcsgroup.setUser(uid, 'evade', value+evade) if time > 0: gamethread.delayed(time, wcsgroup.setUser, (uid, 'evade', evade), 0) if op == '-': wcsgroup.setUser(uid, 'evade', evade-value) if time > 0: gamethread.delayed(time, wcsgroup.setUser, (uid, 'evade', evade), 0)
def createvectorstring(argv): sv[argv[0]] = es.createvectorstring(*argv[1:])
def testSvar(self): y = es.createvectorstring(3.5, 4.5, 6.8) self.failUnless(y == "3.500000,4.500000,6.800000") z = es.splitvectorstring(y) self.failIf(z[0] != 3.5 or z[1] != 4.5 or round(z[2], 1) != 6.8)
def cp_menu_select(userid, choice, popupid): steamid = es.getplayersteamid(userid) velocity_x = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[0]')) velocity_y = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[1]')) velocity_z = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[2]')) timer = es.import_addon("queue_timer/plugins/timer") if timer.CheckPartner(userid): timer_id = timer.player[steamid]["timer_id"] state = timer.timer[timer_id]["state"] if int(choice) == 1: if timer.CheckPartner(userid): cp_menu(userid) else: player = playerlib.getPlayer(userid) client[steamid]["view_angles"] = player.getViewAngle() view_angles = client[steamid]["view_angles"] client[steamid]['snapshot_1'] = es.getplayerlocation(userid) client[steamid]['save_speed'] = (velocity_x, velocity_y, velocity_z) esc.tell(userid, '#124,252,0[ Trikz] #snowYou have saved your #yellow1st #245,61,0checkpoint') cp_menu(userid) if int(choice) == 2: if timer.CheckPartner(userid): cp_menu(userid) else: if client[steamid]['snapshot_1'] != (0, 0, 0): current_location = es.getplayerlocation(userid) location = client[steamid]['snapshot_1'] distance = vecmath.distance(current_location, location) player = playerlib.getPlayer(userid) view_angles = client[steamid]["view_angles"] timer.TimerSolo_Stop(userid) client[steamid]["time"] = time.time() player.setColor(255, 255, 255, 255) player.noblock(0) if client[steamid]["stop_speed"] == "On": es.server.queuecmd('es_setpos %s %s %s %s' % (userid, location[0], location[1], location[2])) velocity_x = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[0]')) velocity_y = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[1]')) velocity_z = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[2]')) myNewVector2 = es.createvectorstring(-velocity_x, -velocity_y, -velocity_z) es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", myNewVector2) gamethread.delayed(0.025, set_boost, args=(userid, 0)) else: es.server.queuecmd('es_setpos %s %s %s %s' % (userid, location[0], location[1], location[2])) velocity_x = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[0]')) velocity_y = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[1]')) velocity_z = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[2]')) myNewVector2 = es.createvectorstring(-velocity_x, -velocity_y, -velocity_z) es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", myNewVector2) if client[steamid]["save_angles"] == "On": es.server.queuecmd('es_xsetang %s %s %s %s' % ( userid, str(view_angles[0]), str(view_angles[1]), str(view_angles[2]))) else: esc.tell(userid, '#124,252,0[ Trikz] #245,0,61You have not set your 1st checkpoint.') cp_menu(userid) if int(choice) == 3: if timer.CheckPartner(userid): cp_menu(userid) else: player = playerlib.getPlayer(userid) client[steamid]["view_angles_2"] = player.getViewAngle() client[steamid]['snapshot_2'] = es.getplayerlocation(userid) client[steamid]['save_speed_2'] = (velocity_x, velocity_y, velocity_z) esc.tell(userid, '#124,252,0[ Trikz] #snowYou have saved your #yellow2nd #245,61,0checkpoint') cp_menu(userid) if int(choice) == 4: if timer.CheckPartner(userid): cp_menu(userid) else: if client[steamid]['snapshot_2'] != (0, 0, 0): current_location = es.getplayerlocation(userid) location = client[steamid]['snapshot_2'] distance = vecmath.distance(current_location, location) player = playerlib.getPlayer(userid) view_angles = client[steamid]["view_angles_2"] client[steamid]["time"] = time.time() timer.TimerSolo_Stop(userid) player.setColor(255, 255, 255, 255) player.noblock(0) if client[steamid]["stop_speed"] == "On": es.server.queuecmd('es_setpos %s %s %s %s' % (userid, location[0], location[1], location[2])) velocity_x = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[0]')) velocity_y = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[1]')) velocity_z = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[2]')) myNewVector2 = es.createvectorstring(-velocity_x, -velocity_y, -velocity_z) es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", myNewVector2) gamethread.delayed(0.025, set_boost, args=(userid, 1)) else: es.server.queuecmd('es_setpos %s %s %s %s' % (userid, location[0], location[1], location[2])) velocity_x = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[0]')) velocity_y = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[1]')) velocity_z = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[2]')) myNewVector2 = es.createvectorstring(-velocity_x, -velocity_y, -velocity_z) es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", myNewVector2) if client[steamid]["save_angles"] == "On": es.server.insertcmd('es_xsetang %s %s %s %s' % ( userid, str(view_angles[0]), str(view_angles[1]), str(view_angles[2]))) else: esc.tell(userid, '#124,252,0[ Trikz] #245,0,61You have not set your 2nd checkpoint.') cp_menu(userid) if int(choice) == 5: if client[steamid]['stop_speed'] == "Off": esc.tell(userid, '#124,252,0[ Trikz] #snowYour speed will now be restored when teleporting!') client[steamid]['stop_speed'] = "On" cp_menu(userid) else: esc.tell(userid, '#124,252,0[ Trikz] #snowYou will not save speed anymore!') client[steamid]['stop_speed'] = "Off" cp_menu(userid) if int(choice) == 6: if client[steamid]['save_angles'] == "Off": esc.tell(userid, '#124,252,0[ Trikz] #snowYou will now save ur angles!') client[steamid]['save_angles'] = "On" cp_menu(userid) else: esc.tell(userid, '#124,252,0[ Trikz] #snowYou angles wont be saved!') client[steamid]['save_angles'] = "Off" cp_menu(userid) if int(choice) == 8: trikz_menu(userid)
def sm2es_keyPress(ev): userid = ev["userid"] timer = es.import_addon("queue_timer/plugins/timer") if es.exists("userid", userid): if ev['status'] == '0': return ply = playerlib.getPlayer(userid) if ply.isdead: return velocity_x = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[0]')) velocity_y = float(es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[1]')) steamid = es.getplayersteamid(userid) if ev["command"] == 'IN_MOVELEFT': if not ply.onGround() and client[steamid]["strafe_sync"] == "On": if not client[steamid]["view_angle"] == ply.viewVector(): if not client[steamid]["last_k"] == 0: if timer.CheckPartner(userid): timer_id = timer.player[steamid]["timer_id"] state = timer.timer[timer_id]["state"] if state == 2: return else: myNewVector = es.createvectorstring((velocity_x ** 0.1) * 18, (velocity_y ** 0.1) * 18) myNewVector2 = es.createvectorstring((velocity_x ** 0.1) * 18, (velocity_y ** 0.1) * 18) es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", myNewVector) es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", myNewVector2) client[steamid]["view_angle"] = ply.viewVector() client[steamid]["last_k"] = 0 else: myNewVector = es.createvectorstring((velocity_x ** 0.1) * 18, (velocity_y ** 0.1) * 18) myNewVector2 = es.createvectorstring((velocity_x ** 0.1) * 18, (velocity_y ** 0.1) * 18) es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", myNewVector) es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", myNewVector2) client[steamid]["view_angle"] = ply.viewVector() client[steamid]["last_k"] = 0 if ev['command'] == 'IN_MOVERIGHT': if not ply.onGround() and client[steamid]["strafe_sync"] == "On": if not client[steamid]["view_angle"] == ply.viewVector(): if not client[steamid]["last_k"] == 1: if timer.CheckPartner(userid): timer_id = timer.player[steamid]["timer_id"] state = timer.timer[timer_id]["state"] if state == 2: return else: myNewVector = es.createvectorstring((velocity_x ** 0.1) * 18, (velocity_y ** 0.1) * 18) myNewVector2 = es.createvectorstring((velocity_x ** 0.1) * 18, (velocity_y ** 0.1) * 18) es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", myNewVector) es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", myNewVector2) client[steamid]["view_angle"] = ply.viewVector() client[steamid]["last_k"] = 0 else: myNewVector = es.createvectorstring((velocity_x ** 0.1) * 18, (velocity_y ** 0.1) * 18) myNewVector2 = es.createvectorstring((velocity_x ** 0.1) * 18, (velocity_y ** 0.1) * 18) es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", myNewVector) es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", myNewVector2) client[steamid]["view_angle"] = ply.viewVector() client[steamid]["last_k"] = 0
def testSvar(self): y = es.createvectorstring(3.5,4.5,6.8) self.failUnless(y == "3.500000,4.500000,6.800000") z = es.splitvectorstring(y) self.failIf(z[0] != 3.5 or z[1] != 4.5 or round(z[2],1) != 6.8)
def player_say(event_var): """ Executed when a player talks. Run the chat commands """ message = event_var['text'].strip() userid = int(event_var['userid']) if message == "!surftimer": """ Admin menu """ if isAuthed(userid): adminPopup.send(userid) elif message.startswith("!wr"): """ Display world record time to all players """ sortedList = mk_sortDict(str(currentMap)) es.tell( userid, "#multi", "#green[Surf Timer] #default- #lightgreen%s holds the world record with time #default%s#lightgreen." % (mapDicts[str(currentMap)][sortedList[0][0]]["name"], formatTime(sortedList[0][1]))) elif message.startswith("!top"): """ Display a popup with all times for that map, or if a map was present as an argument, display for that map. !top // display current map records !top <map name> // displays <map name>'s current records """ if message.count(" "): mapName = " ".join(message.split()[1:]) else: mapName = str(currentMap) if mapName not in mapDicts: es.tell( userid, "#multi", "#green[Surf Timer] #default- #lightgreenSorry, we cannot find %s on the server." % mapName) return if "startpos" not in mapDicts[mapName]: return if "endpos" not in mapDicts[mapName]: return topMenu = popuplib.easymenu("topMenu%s" % userid, "_popup_choice", None) topMenu.settitle("[Map Records : %s]" % mapName) sortedList = mk_sortDict(mapName) if sortedList: lx = 1 for top in sortedList: topMenu.addoption( 'an', "Rank " + str(lx) + ": " + mapDicts[mapName][top[0]]["name"] + " " + formatTime(mapDicts[mapName][top[0]]["time"])) lx += 1 else: topMenu.addoption('an', "[No places recorded]") topMenu.send(userid) elif message.startswith("!pr"): """ Similar to a rank command. Tell the user their time or another person's time on that current map. !pr // displays their time for that map !pr <userid/name/steamid> // displays the user's time for that map TODO: Add in an additional [map] argument and test for the last argument and see if it's a dict item. If so, then they want information for that map. """ mapName = str(currentMap) if mapName not in mapDicts: return if "startpos" not in mapDicts[mapName]: return if "endpos" not in mapDicts[mapName]: return if message.count(" "): message = " ".join(message.split()[1:]) target = es.getuserid(message) else: target = userid if not target: es.tell( userid, "#multi", "#green[Surf Timer] #default- #lightgreenSorry, we cannot find %s on the server." % message) return steamid = es.getplayersteamid(target) (_pos, _len) = mk_sortDictIndex(mapName, steamid) for player in es.getUseridList(): if (_pos > 0): sortedList = mk_sortDict(str(currentMap)) dictObject = mapDicts[mapName][steamid] es.tell( player, "#multi", "#green[Surf Timer] #default- #lightgreen%s is ranked #default%s/%s #lightgreenwith time #default%s #lightgreen(#default+%s#lightgreen)." % (dictObject['name'], _pos, _len, formatTime(dictObject['time']), formatTime(dictObject['time'] - sortedList[0][1]))) else: es.tell( player, "#multi", "#green[Surf Timer] #default- #lightgreen%s has not yet completed this map." % es.getplayername(target)) elif message.startswith("!stage"): """ Opens a stage selection menu """ mapName = str(currentMap) global stageMenu stageMenu = popuplib.easymenu('stageMenu', '_popup_choice', stageMenu_select) stageMenu.settitle("[Stage Menu : %s]" % (mapName)) entities = es.createentitylist('info_teleport_destination') """ Create Stage Menu """ stages = 0 for a in range(1, 26): for b in entities: if (es.entitygetvalue(b, 'targetname') == "timer_stage%s" % a): stageMenu.addoption('%s' % a, "Stage %s" % a) stages += 1 if (stages > 1): stageMenu.send(userid) if (userid in started): es.tell( userid, "#green", "Teleporting to a stage while the timer is active will clear your time" ) else: es.tell( userid, "#multi", "#green[Surf Timer] #default- #lightgreenThis is not a staged map." ) elif message.startswith("!bonus"): """ Opens a bonus selection menu """ mapName = str(currentMap) global bonusMenu bonusMenu = popuplib.easymenu('bonusMenu', '_popup_choice', bonusMenu_select) bonusMenu.settitle("[Bonus Menu : %s]" % (mapName)) entities = es.createentitylist('info_teleport_destination') bonuses = 0 """ Set up bonus menu and count the number of bonuses (up to 3 bonuses) """ for a in range(1, 4): for b in entities: if (es.entitygetvalue(b, 'targetname') == "timer_bonus%s" % a): bonuses += 1 bonusMenu.addoption('%s' % a, "Bonus %s" % a) if (bonuses > 1): bonusMenu.send(userid) elif (bonuses == 1): entities = es.createentitylist('info_teleport_destination') for i in entities: if (es.entitygetvalue(i, 'targetname') == "timer_bonus1"): x = es.getplayerprop( userid, "CBasePlayer.localdata.m_vecVelocity[0]") * -1 / 2 y = es.getplayerprop( userid, "CBasePlayer.localdata.m_vecVelocity[1]") * -1 / 2 z = es.getplayerprop( userid, "CBasePlayer.localdata.m_vecVelocity[2]") * -1 / 2 es.setplayerprop( userid, "CBasePlayer.localdata.m_vecBaseVelocity", es.createvectorstring(x, y, z)) gamethread.delayed( 0.01, es.setplayerprop, (userid, "CBasePlayer.localdata.m_vecBaseVelocity", es.createvectorstring(x, y, z))) startPos = es.entitygetvalue(i, 'origin').split(' ') startAng = es.entitygetvalue(i, 'angles').split(' ') es.setpos(userid, startPos[0], startPos[1], startPos[2]) es.setang(userid, startAng[0], startAng[1], startAng[2]) else: es.tell( userid, "#multi", "#green[Surf Timer] #default- #lightgreenCurrent map has no bonuses." )