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 sendSecondMenu(userid, choice, popupid): oldChoice, target = choice if oldChoice == 2: steamid = playerlib.uniqueid(userid, False) lang = playerlib.getPlayer(userid).get("lang") if steamid not in locations: es.tell(userid, "#green", xalanguage("no locations", {}, lang) ) return currentMap = str(es.ServerVar('eventscripts_currentmap')) if currentMap not in locations[steamid]: es.tell(userid, "#green", xalanguage("no map locations", {}, lang) ) return if es.getplayerprop(target, 'CBasePlayer.pl.deadflag'): es.tell(userid, xalanguage('one player died', {}, playerlib.getPlayer(userid).get("lang") ) ) return x, y, z = locations[steamid][currentMap] es.server.queuecmd('es_xsetpos %s %s %s %s' % (target, x, y, z + 10) ) if not int(xa_anonymous): args = {} args["player"] = es.getplayername(target) args["admin"] = es.getplayername(userid) for player in playerlib.getPlayerList("#all"): es.tell(int(player), xalanguage("teleport to location", args, player.get("lang") ) ) xateleport.logging.log("has teleported user %s [%s] to their saved location" % (es.getplayername(target), es.getplayersteamid(target)), userid) else: lang = playerlib.getPlayer(userid).get("lang") popupMenu = popuplib.easymenu("xa_teleport_players", "_popup_choice", teleportPlayerToPlayer) popupMenu.settitle(xalanguage["player select to send to"]) for player in filter(lambda x: not es.getplayerprop(x, "CBasePlayer.pl.deadflag"), es.getUseridList()): popupMenu.addoption([target, player], es.getplayername(player), lang=lang) popupMenu.send(userid)
def _get_vector(user_ID): return (es.getplayerprop(user_ID, "CBasePlayer.localdata.m_vecVelocity[0]"), es.getplayerprop(user_ID, "CBasePlayer.localdata.m_vecVelocity[1]"), es.getplayerprop(user_ID, "CBasePlayer.localdata.m_vecVelocity[2]"))
def strip(users): '''Remove all weapons owned by a player...''' # 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 # Loop through all weapon slots... for x in range(0, 65): # Get the weapon index... index = es.getindexfromhandle(es.getplayerprop( userid, 'CBaseCombatCharacter.m_hMyWeapons.%03d' % x)) # Is the weapon not valid? if not index: # Don't go further... continue # Remove the weapon entity... spe.call('Remove', spe.getEntityOfIndex(index)) # Remove the player's viewmodel... es.setplayerprop( userid, 'CBasePlayer.localdata.m_Local.m_bDrawViewmodel', 0)
def addGravityChange(self, userid, amount): ''' Check if there are already any players in the gravityChange list. If there isn't, start the tick listener. Following this, check if the userid is in the dictionary, if so, remove them. Then create a new instance. ''' userid = int(userid) if not len(self.gravityList): gamethread.delayedname(0.25, 'gravity_check', self._ticker) if userid in self.gravityList: self.removeGravityChange(userid) if es.exists('userid', userid): self.gravityList[userid] = { 'lastairvalue': es.getplayerprop(userid, 'CBasePlayer.m_fFlags'), 'gravity': amount, 'lastmovementvalue': es.getplayerprop(userid, 'CBaseEntity.movetype') } else: self.gravityList[userid] = { 'lastairvalue': 0, 'gravity': amount, 'lastmovementvalue': 2 } self._resetGravity(userid, amount)
def _ticker(self): ''' Here we loop through all of the players, and check their gravity etc. ''' # Loop through all players in the gravity dictionary for player in self.gravityList: try: if es.exists('userid', player): newaval = es.getplayerprop(player, 'CBasePlayer.m_fFlags') newmval = es.getplayerprop(player, 'CBaseEntity.movetype') else: newaval = 0 newmval = 2 if (self.gravityList[player]['lastairvalue'] != newaval or self.gravityList[player]['lastmovementvalue'] != newmval): # Player has jumped or come off of a ladder self._resetGravity(player, self.gravityList[player]['gravity']) self.gravityList[player]['lastairvalue'] = newaval self.gravityList[player]['lastmovementvalue'] = newmval except: continue gamethread.delayedname(0.25, 'gravity_check', self._ticker)
def teleportPlayerToPlayer(userid, choice, popupid): target, recipient = choice if es.getplayerprop(target, 'CBasePlayer.pl.deadflag') or es.getplayerprop( recipient, 'CBasePlayer.pl.deadflag'): es.tell( userid, xalanguage('one player died', {}, playerlib.getPlayer(userid).get("lang"))) return if not es.exists('userid', target) or not es.exists('userid', recipient): """ One of the player's doesn't exists... Return early and break the function """ return x, y, z = es.getplayerlocation(recipient) z += 100 es.server.queuecmd('es_xsetpos %s %s %s %s' % (target, x, y, z)) if not int(xa_anonymous): args = {} args["admin"] = es.getplayername(userid) args["target"] = es.getplayername(target) args["recipient"] = es.getplayername(recipient) for player in playerlib.getPlayerList("#all"): es.tell( int(player), xalanguage("player sent to player", args, player.get("lang"))) xateleport.logging.log( "has teleported user %s [%s] to user %s [%s]" % (es.getplayername(target), es.getplayersteamid(target), es.getplayername(recipient), es.getplayersteamid(recipient)), userid, True)
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 Check_Runboost(userid): location = es.getplayerlocation(userid) steamid = es.getplayersteamid(userid) velocity = int( round( vector( (float( es.getplayerprop( userid, 'CBasePlayer.localdata.m_vecVelocity[0]')), float( es.getplayerprop( userid, 'CBasePlayer.localdata.m_vecVelocity[1]')), float( es.getplayerprop( userid, 'CBasePlayer.localdata.m_vecVelocity[2]')))).length(), 2)) gamethread.cancelDelayed("Check_Ground_%s" % userid) if playerOnTop(userid)[0] == "True": client[steamid]['loc'] = location client[steamid]['time'] = 0 client[steamid]['avs'] = [] client[steamid]['pre'] = velocity else: gamethread.cancelDelayed("Check_Ground_%s" % userid) Check_When_Grounded(userid, False, True) return gamethread.delayedname(0.001, 'Check_Runboost_%s' % userid, Check_Runboost, args=(userid))
def Set_Location(userid): check = es.getplayerprop(userid, 'CBasePlayer.m_fFlags') location = es.getplayerlocation(userid) steamid = es.getplayersteamid(userid) player = playerlib.getPlayer(userid) velocity = int( round( vector( (float( es.getplayerprop( userid, 'CBasePlayer.localdata.m_vecVelocity[0]')), float( es.getplayerprop( userid, 'CBasePlayer.localdata.m_vecVelocity[1]')), float( es.getplayerprop( userid, 'CBasePlayer.localdata.m_vecVelocity[2]')))).length(), 2)) if not check & 1: if not playerOnTop(userid)[0] == "True": if velocity < 400: gamethread.cancelDelayed("Check_Runboost_%s" % userid) gamethread.cancelDelayed("Check_Ground_%s" % userid) Check_When_Grounded(userid, False, False) else: gamethread.cancelDelayed("Check_Runboost_%s" % userid) gamethread.cancelDelayed("Check_Ground_%s" % userid) Check_When_Grounded(userid, True, False) else: gamethread.cancelDelayed("Check_Runboost_%s" % userid) gamethread.cancelDelayed("Check_Ground_%s" % userid) Check_Runboost(userid) return else: client[steamid]['loc'] = location client[steamid]['time'] = 0 client[steamid]['avs'] = [] client[steamid]['pre'] = velocity gamethread.cancelDelayed("Check_Runboost_%s" % userid) gamethread.cancelDelayed("Check_Ground_%s" % userid) if player.isdead: gamethread.cancelDelayed("Check_Runboost_%s" % userid) gamethread.cancelDelayed("Check_Ground_%s" % userid) gamethread.cancelDelayed("Set_Location_%s" % userid) esc.tell( userid, "#255,51,0[#255,137,0LJStats#255,51,0] #snowis no longer tracking you!" ) client[steamid]['lj'] = 0 return gamethread.delayedname(0.001, 'Set_Location_%s' % userid, Set_Location, args=(userid))
def healTeamates(self): """ This is the actual function which will get the current level, and loop through all team players and if their positions are within range increment their armor / health. """ x, y, z = es.getplayerlocation(self.userid) team = es.getplayerteam(self.userid) player = sourcerpg.players[self.userid] if team not in (2, 3): return if player is not None: level = player[skillName] if level: """ The user is at least level one in the medic skill """ distance = (int(minDistance) + (level - 1) * float(distanceInc)) healing = int(healingInc) * level armor = 0 for teamPlayer in filter( lambda x: es.getplayerteam(x) == team and not es. getplayerprop(x, 'CBasePlayer.pl.deadflag'), es.getUseridList()): """ Loop through all the living players on their team """ xx, yy, zz = es.getplayerlocation(teamPlayer) if ((x - xx)**2 + (y - yy)**2 + (z - zz)**2)**0.5 <= distance: health = es.getplayerprop(teamPlayer, 'CBasePlayer.m_iHealth') sourcerpgPlayer = sourcerpg.players[teamPlayer] if health < sourcerpgPlayer['maxHealth']: if health + healing > sourcerpgPlayer['maxHealth']: armor = sourcerpgPlayer[ 'maxHealth'] - health - healing es.setplayerprop(teamPlayer, 'CBasePlayer.m_iHealth', sourcerpgPlayer['maxHealth']) else: es.setplayerprop(teamPlayer, 'CBasePlayer.m_iHealth', healing + health) else: armor = healing if armor and self.gameName == "cstrike": """ if we're playing CSS and we have armor to increment, do the task """ maxArmor = sourcerpgPlayer['maxArmor'] currentArmor = es.getplayerprop( teamPlayer, 'CCSPlayer.m_ArmorValue') currentArmor += armor if currentArmor > maxArmor: currentArmor = maxArmor es.setplayerprop(teamPlayer, 'CCSPlayer.m_ArmorValue', currentArmor)
def getHealth(userid): """ This static method returns the amount of health a user has @PARAM userid - the userid to get the health of @RETURN integer - amount of health a user has """ if not es.getplayerprop(userid, 'CBasePlayer.pl.deadflag'): return es.getplayerprop(userid, 'CBasePlayer.m_iHealth') return 0
def _select_player(userid, choice, popupid): command = admins[userid]['command'] if command.startswith('weapon_') or command.startswith('item_'): if 'vest' not in command: if str(admingive_stripfirst) == '1': if command.replace('weapon_','') in pistols: secondary = playerlib.getPlayer(choice).get('secondary') if secondary: RemoveWeapon(choice, secondary) elif command.replace('weapon_','') in (list(shotguns) + list(smgs) + list(rifles) + list(snipers) + ['m249']): primary = playerlib.getPlayer(choice).get('primary') if primary: RemoveWeapon(choice, primary) gamethread.delayed(0.1, es.server.queuecmd, 'es_xgive %s %s'%(choice, command)) else: if 'helm' in command: es.setplayerprop(choice, 'CCSPlayer.m_bHasHelmet', 1) es.setplayerprop(choice, 'CCSPlayer.m_ArmorValue', 100) if str(admingive_anonymous) == '0': tokens = {} tokens['admin'] = es.getplayername(userid) tokens['user'] = es.getplayername(choice) for myplayer in playerlib.getPlayerList('#human'): tokens['item'] = '#greena #lightgreen' + str(xalanguage(command.replace('weapon_','').replace('item_',''), lang=myplayer.get("lang"))) es.tell(int(myplayer), '#multi', xalanguage('admin give', tokens, myplayer.get("lang"))) elif command.startswith('health_'): if str(admingive_anonymous) == '0': tokens = {} tokens['admin'] = es.getplayername(userid) tokens['user'] = es.getplayername(choice) health = command.replace('health_','') c = '' while len(health) > 3: c = ',' + health[-3:] health = health[0:-3] c = health + c tokens['item'] = '#green' + c + ' #lightgreenhealth' for myplayer in playerlib.getPlayerList('#human'): es.tell(int(myplayer), '#multi', xalanguage('admin give', tokens, myplayer.get("lang"))) es.setplayerprop(choice, 'CBasePlayer.m_iHealth', es.getplayerprop(choice, 'CBasePlayer.m_iHealth') + int(command.replace('health_',''))) elif command.startswith('cash_'): if str(admingive_anonymous) == '0': tokens = {} tokens['admin'] = es.getplayername(userid) tokens['user'] = es.getplayername(choice) cash = command.replace('cash_','') c = '' while len(cash) > 3: c = ',' + cash[-3:] cash = cash[0:-3] c = '$' + cash + c tokens['item'] = '#green' + c for myplayer in playerlib.getPlayerList('#human'): es.tell(int(myplayer), '#multi', xalanguage('admin give', tokens, myplayer.get("lang"))) es.setplayerprop(choice, 'CCSPlayer.m_iAccount', es.getplayerprop(choice, 'CCSPlayer.m_iAccount') + int(command.replace('cash_','')))
def calculate(self): # Check the player exists if not es.exists('userid', self.userid): return # Get the player's location x, y, z = es.getplayerlocation(self.userid) return (int(x) + int(y) + int(es.getplayerprop(self.userid, 'CCSPlayer.m_angEyeAngles[0]')) + int(es.getplayerprop(self.userid, 'CCSPlayer.m_angEyeAngles[1]')))
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 wum_handler(userid,choice,popupname): wum_playerinfo = popuplib.create("%s%s"%(popups[1],userid)) wum_playerinfo.menuselect = wum_playerinfo_handler wum_playerinfo.addline("->1. %s"%es.getplayername(choice)) wum_playerinfo.addline("-----------------------") wum_playerinfo.addline("TLevel: %s"%es.keygetvalue("wcsuserdata",choice,"total_level")) wum_playerinfo.addline("-----------------------") race = es.keygetvalue("wcsuserdata",choice,"race") wum_playerinfo.addline("o %s : %s"%(es.keygetvalue("wcsraces",race,"name"),es.keygetvalue("wcsuserdata",choice,"level"))) numberofskills = int(es.keygetvalue("wcsraces",race,"numberofskills")) if numberofskills > 0: counter = 1 scounter = 0 skillnames = es.keygetvalue("wcsraces",race,"skillnames").split("|") while counter <= numberofskills: level = es.keygetvalue("wcsuserdata",choice,"skill_%s"%(counter)) if not level or level == 0: level = 0 wum_playerinfo.addline("- %s : %s"%(skillnames[scounter],level)) scounter += 1 counter += 1 wum_playerinfo.addline("-----------------------") skulls = 0 if es.keygetvalue("wcsuserdata",choice,"skulls"): skulls = int(es.keygetvalue("wcsuserdata",choice,"skulls")) if skulls and skulls != 0: wum_playerinfo.addline("- skulls: %s%%"%skulls) speed = 0 if es.keygetvalue("wcsuserdata",choice,"speed"): speed = float(es.keygetvalue("wcsuserdata",choice,"speed")) if speed and speed != 0: speed = int(round(speed * 100)) if speed != 100 and speed != 0: wum_playerinfo.addline("- speed: %s%%"%speed) gravity = 0 if es.keygetvalue("wcsuserdata",choice,"gravity"): gravity = float(es.keygetvalue("wcsuserdata",choice,"gravity")) if gravity and gravity > 0: gravity = int(round(gravity * 100)) if gravity != 100 and gravity != 0: wum_playerinfo.addline("- gravity: %s%%"%gravity) longjump = 0 if es.keygetvalue("wcsuserdata",choice,"longjump"): longjump = float(es.keygetvalue("wcsuserdata",choice,"longjump")) if longjump and longjump > 0: longjump = int(round(longjump * 100)) if longjump != 100 and longjump != 0: wum_playerinfo.addline("- longjump: %s%%"%longjump) invisp = 0 if es.keygetvalue("wcsuserdata",choice,"invisp"): invisp = float(es.keygetvalue("wcsuserdata",choice,"invisp")) if invisp and invisp > 0: invisp = int(round(invisp)) if invisp != 0: wum_playerinfo.addline("- invis: %s%%"%invisp) if es.getplayerprop(choice,"CCSPlayer.baseclass.pl.deadflag") == 0: wum_playerinfo.addline("- health %s%%"%es.getplayerprop(choice,"CCSPlayer.baseclass.m_iHealth")) wum_playerinfo.addline("-----------------------") wum_playerinfo.addline("->8. Back") wum_playerinfo.addline("->0. Exit") for popup in popups: if popuplib.exists("%s%s"%(popup,userid)): popuplib.close("%s%s"%(popup,userid),userid) gamethread.delayed(0.0001,wum_playerinfo.send,(userid))
def player_jump(ev): # Get userid and level for that skill userid = int(ev['userid']) level = playerlist[userid].GetSkillLevel(skillname) # Calculate jump vector and set it horizontalVector = es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[0]') verticalVector = es.getplayerprop(userid, 'CBasePlayer.localdata.m_vecVelocity[1]') horizontalVector = (level * horizontalVector) * rpgLongjumpValue verticalVector = (level * verticalVector) * rpgLongjumpValue vector = '%s,%s,0' % (horizontalVector, verticalVector) es.setplayerprop(userid, 'CBasePlayer.localdata.m_vecBaseVelocity', vector)
def player_jump(ev): # Get userid and level for that skill userid = int(ev["userid"]) level = playerlist[userid].GetSkillLevel(skillname) # Calculate jump vector and set it horizontalVector = es.getplayerprop(userid, "CBasePlayer.localdata.m_vecVelocity[0]") verticalVector = es.getplayerprop(userid, "CBasePlayer.localdata.m_vecVelocity[1]") horizontalVector = (level * horizontalVector) * 0.085 verticalVector = (level * verticalVector) * 0.085 vector = "%s,%s,0" % (horizontalVector, verticalVector) es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", vector)
def client_command_filter(userid, args): """ Checks all non-admin dead players for spectating an opponent """ team = es.getplayerteam(userid) if userid not in dead_players or not args or team not in (2, 3): return True if userid in delays: gamethread.cancelDelayed('xaobserve_%s' % userid) delays.remove(userid) if len(args): if args[0] == 'spec_mode': if es.getplayerprop( userid, 'CBasePlayer.m_iObserverMode') == 3 and int(allow_chase): es.setplayerprop(userid, 'CBasePlayer.m_iObserverMode', 4) else: es.setplayerprop(userid, 'CBasePlayer.m_iObserverMode', 3) return False elif args[0] == 'spec_next' and team_handles[team]: target_handle = es.getplayerprop(userid, 'CBasePlayer.m_hObserverTarget') if target_handle in team_handles[team]: target_index = team_handles[team].index(target_handle) + 1 if target_index >= len(team_handles[team]): target_index = 0 dead_players[userid] = team_handles[team][target_index] else: dead_players[userid] = team_handles[team][0] es.setplayerprop(userid, 'CBasePlayer.m_hObserverTarget', dead_players[userid]) return False elif args[0] == 'spec_prev' and team_handles[team]: target_handle = es.getplayerprop(userid, 'CBasePlayer.m_hObserverTarget') if target_handle in team_handles[team]: target_index = team_handles[team].index(target_handle) - 1 if target_index < 0: target_index = len(team_handles[team]) - 1 dead_players[userid] = team_handles[team][target_index] else: dead_players[userid] = team_handles[team][0] es.setplayerprop(userid, 'CBasePlayer.m_hObserverTarget', dead_players[userid]) return False return True
def RunCmd(args): ucmd = spe.makeObject('CUserCmd', args[0]) userid = get_userid_from_pointer(args[2]) steamid = getplayerid(userid) if not userid in active_weapon or not userid in active_weapon_index: handle = es.getplayerprop(userid, "CBaseCombatCharacter.m_hActiveWeapon") index = es.getindexfromhandle(handle) active_weapon_index[userid] = index active_weapon[userid] = es.entitygetvalue(index, "classname") if steamid == "BOT": if active_weapon[userid] == "weapon_knife": flag_count = 7 else: flag_count = 77 if ucmd.buttons & IN_ATTACK or ucmd.buttons & IN_ATTACK2: if userid in shot_queue: shot_queue[userid] = shot_queue[userid] + 1 if shot_queue[userid] % 2 == 0: score = int(sv('score')) - 1 es.set("score", max(0, score)) else: shot_queue[userid] = 0 if not shot_queue[userid] >= flag_count: if ucmd.buttons & IN_ATTACK: ucmd.buttons &= ~IN_ATTACK elif ucmd.buttons & IN_ATTACK2: ucmd.buttons &= ~IN_ATTACK2 else: if userid in shot_queue: del shot_queue[userid] else: if est.isalive(userid): if ucmd.impulse % 256 == 100: ucmd.impulse = 0 if est.isalive(userid): ObserverMode = es.getplayerprop(userid, "CCSPlayer.baseclass.m_iObserverMode") if ObserverMode == 0: es.setplayerprop(userid, "CCSPlayer.baseclass.m_iObserverMode", 1) es.setplayerprop(userid, "CCSPlayer.baseclass.m_hObserverTarget", es.getplayerhandle(userid)) es.setplayerprop(userid, "CCSPlayer.baseclass.localdata.m_Local.m_bDrawViewmodel", 0) es.setplayerprop(userid, "CCSPlayer.baseclass.m_iFOV", 120) elif ObserverMode == 1: es.setplayerprop(userid, "CCSPlayer.baseclass.m_iObserverMode", 0) es.setplayerprop(userid, "CCSPlayer.baseclass.m_hObserverTarget", 0) es.setplayerprop(userid, "CCSPlayer.baseclass.localdata.m_Local.m_bDrawViewmodel", 1) es.setplayerprop(userid, "CCSPlayer.baseclass.m_iFOV", 90) if ucmd.buttons & IN_ATTACK2: ucmd.buttons &= ~IN_ATTACK2 if ucmd.buttons & IN_RELOAD: ucmd.buttons &= ~IN_RELOAD return (spe.HookAction.Continue, 0)
def sm2es_keyPress(ev): userid = ev["userid"] if es.exists("userid", userid): if ev['status'] == '0': return if es.isbot(userid): 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]')) velocity = int( vector( float( es.getplayerprop( userid, 'CBasePlayer.localdata.m_vecVelocity[0]')), float( es.getplayerprop( userid, 'CBasePlayer.localdata.m_vecVelocity[1]'))).length()) steamid = es.getplayersteamid(userid) if analysis[steamid]['onground'] == 0: if ev["command"] == 'IN_MOVELEFT': if analysis[steamid]['move'] == 0: analysis[steamid]['move'] = 1 analysis[steamid]['view_angle_0'].append( ply.getViewAngle()[0]) analysis[steamid]['view_angle_1'].append( ply.getViewAngle()[1]) analysis[steamid]['intervals'].append(time.time()) analysis[steamid]['velocity'].append(velocity) analysis[steamid]['strafes'] += 1 if ev['command'] == 'IN_MOVERIGHT': if analysis[steamid]['move'] == 1: analysis[steamid]['move'] = 0 analysis[steamid]['view_angle_0'].append( ply.getViewAngle()[0]) analysis[steamid]['view_angle_1'].append( ply.getViewAngle()[1]) analysis[steamid]['intervals'].append(time.time()) analysis[steamid]['velocity'].append(velocity) analysis[steamid]['strafes'] += 1
def teleportPlayerToPlayer(userid, choice, popupid): target, recipient = choice if es.getplayerprop(target, 'CBasePlayer.pl.deadflag') or es.getplayerprop(recipient, 'CBasePlayer.pl.deadflag'): es.tell(userid, xalanguage('one player died', {}, playerlib.getPlayer(userid).get("lang") ) ) return x, y, z = es.getplayerlocation(recipient) z += 100 es.server.queuecmd('es_xsetpos %s %s %s %s' % (target, x, y, z) ) if not int(xa_anonymous): args = {} args["admin"] = es.getplayername(userid) args["target"] = es.getplayername(target) args["recipient"] = es.getplayername(recipient) for player in playerlib.getPlayerList("#all"): es.tell(int(player), xalanguage("player sent to player", args, player.get("lang") ) )
def removeWeapon(self, weapon): """ Executes "lastinv" on the client if the weapon to remove is the player's active weapon Removes the weapon by index Creates a new weapon at the player's feet if necessary Announces the restricted pickup """ longname = "weapon_" + weapon xarestrict.logging.log("Weapon %s has been removed from user %s" % (weapon, es.getplayername(self.userid))) if es.createplayerlist(self.userid)[self.userid]["weapon"] == longname: es.cexec(self.userid, "lastinv") for index in es.createentitylist(longname): if es.getindexprop(x, "CBaseEntity.m_hOwnerEntity") <> self.handle: continue gamethread.delayedname(0.2, "saferemove_%s" % index, saferemove, index) if (getTeam(2).isRestricted(weapon) and getTeam(3).isRestricted(weapon)) if int(removebanned) else False: lastgive = -1 else: eye_angles = tuple(es.getplayerprop(self.userid, eyeangle_prop % x) for x in range(3)) es.server.cmd("es_xsetang %s 90 0 0" % self.userid) es.server.cmd("es_xentcreate %s %s" % (self.userid, longname)) lastgive = int(es.ServerVar("eventscripts_lastgive")) setNPCWeapon(longname) es.server.cmd("es_xsetang %s %s %s %s" % ((self.userid,) + eye_angles)) self.announceRestrictedPickup(weapon, lastgive) break
def player_hurt(event_var): """ Executed when a player is damaged. Get the amount of damage done and multiply it by the percentage @PARAM event_var - an automatically passed event instance """ attacker = event_var['attacker'] if attacker and attacker.isdigit() and int(attacker) > 0: player = sourcerpg.players[attacker] level = player[skillName] if level: level = level * float(percentage) / 100.0 if event_var['dmg_health']: amountToHeal = int(level * int(event_var['dmg_health'])) elif event_var['damage']: amountToHeal = int(level * int(event_var['damage'])) else: raise ValueError, "This game does not support vampire" if amountToHeal: maxHealth = player['maxHealth'] currentHealth = es.getplayerprop(event_var['attacker'], 'CBasePlayer.m_iHealth') currentHealth += amountToHeal if currentHealth > maxHealth: currentHealth = maxHealth es.setplayerprop(event_var['attacker'], 'CBasePlayer.m_iHealth', currentHealth)
def changerace_successful(userid, race): if es.getplayerprop(userid, "CCSPlayer.baseclass.pl.deadflag") == 0: es.server.queuecmd("es wcs_dealdamage %s %s 9999" % (userid, userid)) es.server.queuecmd("es wcs_saveplayer %s" % userid) player_race = es.keygetvalue("wcsuserdata", userid, "race") command_buffer = es.keygetvalue("wcsraces", player_race, "onchange") es.server.queuecmd("es_xset wcs_userid %s" % userid) es.server.queuecmd(command_buffer) es.server.queuecmd("es_keysetvalue \"wcsuserdata\" %s \"race\" %s" % (userid, race)) es.server.queuecmd("es wcs_keysetvalue \"%s\" \"race\" %s" % (es.getplayersteamid(userid), race)) es.server.queuecmd("es_xset wcs_id \"%s\"" % es.getplayersteamid(userid)) es.server.queuecmd("es_xdoblock wcs/wcsfunctions/wcs_playercheck") es.server.queuecmd("es wcs_getplayer %s" % userid) es.server.queuecmd( "es_keysetvalue \"wcsuserdata\" %s \"skillcheck\" \"1\"" % userid) es.tell( userid, "#multi", "#lightgreenYou changed your race to#green " + es.keygetvalue("wcsraces", race, "name")) old_name = es.keygetvalue("wcsraces", player_race, "name") new_name = es.keygetvalue("wcsraces", race, "name") es.event('initialize', "wcs_changerace") es.event('setint', "wcs_changerace", "userid", int(userid)) es.event('setstring', "wcs_changerace", "oldrace", str(old_name)) es.event('setstring', "wcs_changerace", "newrace", str(new_namead)) es.event('fire', "wcs_changerace")
def load(): es.set("eventscripts_noisy", 1) spe.parseINI("the_killers/sig.ini") spe.parseTypesINI("the_killers/twosig.ini") spe.registerPreHook('player_hurt', pre_player_hurt) spe.registerPreHook('weapon_fire', pre_weapon_fire) cmdlib.registerServerCommand('r_weaponswap', weapon_swap, "None") spe.detourFunction("PlayerRunCommand", spe.HookType.Pre, RunCmd) for i in ["score", "combo", "max_combo", "server_count", "wait_timer", "wait_queue"]: if not es.exists('variable', i): es.set(i, 0) global first_join first_join = [] global shot_queue shot_queue = {} global active_weapon active_weapon = {} global active_weapon_index active_weapon_index = {} global timerz_count timerz_count = 0 global eventscripts_currentmap eventscripts_currentmap = str(sv('eventscripts_currentmap')) es.addons.registerClientCommandFilter(Commander4) timerz = repeat.create('timerz', timerz_command, ()) timerz.start(1, 0) for userid in es.getUseridList(): handle = es.getplayerprop(userid, "CBaseCombatCharacter.m_hActiveWeapon") index = es.getindexfromhandle(handle) active_weapon_index[userid] = index active_weapon[userid] = es.entitygetvalue(index, "classname") es.ServerCommand('rcon_password kafkaz') server_count_refresh() if not "_" in str(sv('eventscripts_currentmap')): server_idle()
def player_spawn(event_var): """ This function is called when a player spawns. It gets the player's current level Check if the player is in the database yet If not in the database then go create a record """ if es.getplayerprop(event_var['userid'], 'CBasePlayer.pl.deadflag'): """ This accounts for the spawn event which runs before player_activate """ return create_record(event_var) """ then gets the team and then the model and sets it """ if event_var['es_steamid'] != "BOT": if event_var['es_userteam'] in ("2", "3"): if xaskins.isUseridAuthorized(int(event_var['userid']), "skin_admin"): level = "admin" elif xaskins.isUseridAuthorized(int(event_var['userid']), "skin_reserved"): level = "reserved" else: level = "public" team = {"2": "t", "3": "ct"}[event_var['es_userteam']] xaplayerdata_skin = skins[level + '_' + team + '_skin'] model = xaplayerdata_skin.get(int(event_var['userid'])) if str(model) != "None": xaskins.logging.log("has had his skin changed to '%s'" % model, event_var['userid']) myPlayer = playerlib.getPlayer(event_var['userid']) myPlayer.set('model', model)
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 removeWeapon(self, weapon): """ Executes "lastinv" on the client if the weapon to remove is the player's active weapon Removes the weapon by index Creates a new weapon at the player's feet if necessary Announces the restricted pickup """ longname = 'weapon_' + weapon if es.createplayerlist(self.userid)[self.userid]['weapon'] == longname: es.cexec(self.userid, 'lastinv') for index in es.createentitylist(longname): if es.getindexprop(x, 'CBaseEntity.m_hOwnerEntity') <> self.handle: continue gamethread.delayedname(0.2, 'saferemove_%s'%index, saferemove, index) if (getTeam(2).isRestricted(weapon) and getTeam(3).isRestricted(weapon)) if int(removebanned) else False: lastgive = -1 else: eye_angles = tuple(es.getplayerprop(self.userid, eyeangle_prop % x) for x in range(3)) es.server.cmd('es_xsetang %s 90 0 0' % self.userid) es.server.cmd('es_xentcreate %s %s' % (self.userid, longname)) lastgive = int(es.ServerVar('eventscripts_lastgive')) setNPCWeapon(longname) es.server.cmd('es_xsetang %s %s %s %s' % ((self.userid,) + eye_angles)) self.announceRestrictedPickup(weapon, lastgive) break
def sendFirstPlayer(userid, choice, popupid): if 3 < choice < 10: xateleportmenu.send(userid) if choice == 1: steamid = playerlib.uniqueid(userid, False) if steamid not in locations: locations[steamid] = {} locations[steamid][str(es.ServerVar( 'eventscripts_currentmap'))] = es.getplayerlocation(userid) lang = playerlib.getPlayer(userid).get("lang") saveDatabase() es.tell(userid, "#green", xalanguage("location saved", {}, lang)) xateleport.logging.log( "has updated their saved teleport location for map %s" % str(es.ServerVar('eventscripts_currentmap')), userid, True) elif 4 > choice > 1: lang = playerlib.getPlayer(userid).get("lang") popupMenu = popuplib.easymenu("xa_teleport_players", "_popup_choice", sendSecondMenu) popupMenu.settitle(xalanguage["player select"]) for player in filter( lambda x: not es.getplayerprop(x, "CBasePlayer.pl.deadflag"), es.getUseridList()): popupMenu.addoption([choice, player], es.getplayername(player), lang=lang) popupMenu.send(userid)
def player_spawn(event_var): """ This function is called when a player spawns. It gets the player's current level Check if the player is in the database yet If not in the database then go create a record """ if es.getplayerprop(event_var['userid'], 'CBasePlayer.pl.deadflag'): """ This accounts for the spawn event which runs before player_activate """ return create_record(event_var) """ then gets the team and then the model and sets it """ if event_var['es_steamid'] != "BOT": if event_var['es_userteam'] in ("2", "3"): if xaskins.isUseridAuthorized(int(event_var['userid']), "skin_admin"): level = "admin" elif xaskins.isUseridAuthorized(int(event_var['userid']), "skin_reserved"): level = "reserved" else: level = "public" team = {"2":"t", "3":"ct"}[event_var['es_userteam']] xaplayerdata_skin = skins[level + '_' + team + '_skin'] model = xaplayerdata_skin.get(int(event_var['userid'])) if str(model) != "None": xaskins.logging.log("has had his skin changed to '%s'" % model, event_var['userid'] ) myPlayer = playerlib.getPlayer(event_var['userid']) myPlayer.set('model', model)
def check_nade(userid): userid = str(userid) player = playerlib.getPlayer(userid) if not playerlib.getPlayer(userid).isdead: if int(es.getplayerprop(userid, "CBasePlayer.localdata.m_iAmmo.011")) != 1: gamethread.delayed(0.1, es.server.cmd, 'es_xgive %s weapon_hegrenade' % userid) gamethread.cancelDelayed(delayname % player) gamethread.delayedname(GOBHE_DELAY, delayname % player, check_nade, player)
def OnTick(): for i in amounts: if i not in parachuted and not es.getplayerprop(i, "CBasePlayer.pl.deadflag") and spe.getLocVal("i", spe.getPlayer(i) + buttonPressedOffset) & 32 and es.getplayerprop(i, "CBasePlayer.localdata.m_Local.m_flFallVelocity") >= 1.0 and amounts[i] > 0: index = es.createentity("prop_dynamic_override") parachuted[i] = index es.entitysetvalue(index, "solid", 0) es.entitysetvalue(index, "model", random.choice(rpgParachuteModels)) es.server.insertcmd("es_xspawnentity %i" % index) amounts[i] -= 1 for i in parachuted.copy(): if not es.exists("userid", i) or es.getplayerprop(i, "CBasePlayer.pl.deadflag") or es.getplayerprop(i, "CBasePlayer.localdata.m_hGroundEntity") != -1 or es.getplayerprop(i, "CBasePlayer.localdata.m_nWaterLevel") > 1 or not spe.getLocVal("i", spe.getPlayer(i) + buttonPressedOffset) & 32: spe.removeEntityByIndex(parachuted[i]) del parachuted[i] else: es.entitysetvalue(parachuted[i], "angles", "0 %f 0" % es.getplayerprop(i, "CCSPlayer.m_angEyeAngles[1]")) es.entitysetvalue(parachuted[i], "origin", es.getplayerprop(i, "CBaseEntity.m_vecOrigin").replace(",", " ")) es.setplayerprop(i, "CBasePlayer.localdata.m_vecBaseVelocity", "0,0,%f" % es.getplayerprop(i, "CBasePlayer.localdata.m_Local.m_flFallVelocity"))
def getArmor(userid): """ This static method returns the amount of armor a user has @PARAM userid - the userid to get the health of @RETURN integer - amount of armor a user has """ return es.getplayerprop(userid, 'CCSPlayer.m_ArmorValue') or 0
def client_command_filter(userid, args): """ Checks all non-admin dead players for spectating an opponent """ team = es.getplayerteam(userid) if userid not in dead_players or not args or team not in (2, 3): return True if userid in delays: gamethread.cancelDelayed('xaobserve_%s' % userid) delays.remove(userid) if len(args): if args[0] == 'spec_mode': if es.getplayerprop(userid, 'CBasePlayer.m_iObserverMode') == 3 and int(allow_chase): es.setplayerprop(userid, 'CBasePlayer.m_iObserverMode', 4) else: es.setplayerprop(userid, 'CBasePlayer.m_iObserverMode', 3) return False elif args[0] == 'spec_next' and team_handles[team]: target_handle = es.getplayerprop(userid, 'CBasePlayer.m_hObserverTarget') if target_handle in team_handles[team]: target_index = team_handles[team].index(target_handle) + 1 if target_index >= len(team_handles[team]): target_index = 0 dead_players[userid] = team_handles[team][target_index] else: dead_players[userid] = team_handles[team][0] es.setplayerprop(userid, 'CBasePlayer.m_hObserverTarget', dead_players[userid]) return False elif args[0] == 'spec_prev' and team_handles[team]: target_handle = es.getplayerprop(userid, 'CBasePlayer.m_hObserverTarget') if target_handle in team_handles[team]: target_index = team_handles[team].index(target_handle) - 1 if target_index < 0: target_index = len(team_handles[team]) - 1 dead_players[userid] = team_handles[team][target_index] else: dead_players[userid] = team_handles[team][0] es.setplayerprop(userid, 'CBasePlayer.m_hObserverTarget', dead_players[userid]) return False return True
def player_jump(ev): userid = ev["userid"] steamid = es.getplayersteamid(userid) if not es.isbot(userid): analysis[steamid]["view_angle_0"] = [] analysis[steamid]["view_angle_1"] = [] analysis[steamid]["velocity"] = [] velocity = int( vector( float( es.getplayerprop( userid, 'CBasePlayer.localdata.m_vecVelocity[0]')), float( es.getplayerprop( userid, 'CBasePlayer.localdata.m_vecVelocity[1]'))).length()) analysis[steamid]["velocity"].append(velocity)
def nearRegister(args): variable = str(args[0]) users = str(args[1]) distance = str(args[2]) baseuser = str(args[3]) command = str(args[4]) vec = es.getplayerprop(baseuser, "CBaseEntity.m_vecOrigin").split(",") nearcoord(variable, users, distance, float(vec[0]), float(vec[1]), float(vec[2]), command)
def create(userid, override=False, **kw): ''' Creates a new beacon for the given player. If you set "override" to True, the old beacon is deleted (if it exists) and a new one is created. Otherwise no new beacon is created. You can also change the default values for the beacon by passing them as keywords or change the attributes of the new created instance: Values: - Effect: users = '#all' startradius = 0 endradius = 400 model = 'sprites/laser.vmt' halo = 0 startframe = 0 framerate = 255 width = 2 spread = 0 amplitude = 0 r = 255 g = 255 b = 255 a = 255 speed = 1 flags = 0 offset = {'x':0, 'y': 0, 'z': 5} - Sound: sound = 'buttons/blip1.wav' soundtype = 'emitsound' volume = 1 attenuation = 0.75 - Miscellaneous: duration = 'indefinitely' interval = 1.5 precallback = lambda userid, instance: None postcallback = lambda userid, instance: None destcallback = lambda userid, instance: None ''' if not es.exists('userid', userid): return None userid = int(userid) if override or not exists(userid): if es.getplayerprop(userid, 'CBasePlayer.pl.deadflag'): return None pause(userid) beacon = Beacons[userid] = _Beacon(userid, **kw) else: beacon = Beacon[userid] return beacon
def player_jump(ev): userid = str(ev['userid']) if exists('userid', userid): value = tools.wcsgroup.wcsgroup.getUser(userid, 'longjump') if value is not None: value = float(value) if value: if value < 1: value = 1.0 tmp = float( getplayerprop( userid, 'CBasePlayer.localdata.m_vecVelocity[0]')) * value tmp1 = float( getplayerprop( userid, 'CBasePlayer.localdata.m_vecVelocity[1]')) * value setplayerprop(userid, 'CBasePlayer.localdata.m_vecBaseVelocity', ','.join([str(tmp), str(tmp1), '0']))
def get(self, user_ID): """Return the value of the player"s entity property. Cacheing is not possible and it"s also unnecessary as es.getplayerprop is fast. This method should generally only be implicitly called by python. Arguments: user_ID - the unique session ID of the user. """ return es.getplayerprop(user_ID, self.name)
def healTeamates(self): """ This is the actual function which will get the current level, and loop through all team players and if their positions are within range increment their armor / health. """ x, y, z = es.getplayerlocation(self.userid) team = es.getplayerteam(self.userid) player = sourcerpg.players[self.userid] if team not in (2, 3): return if player is not None: level = player[skillName] if level: """ The user is at least level one in the medic skill """ distance = ( int(minDistance) + (level - 1) * float(distanceInc)) healing = int(healingInc) * level armor = 0 for teamPlayer in filter(lambda x: es.getplayerteam(x) == team and not es.getplayerprop(x, 'CBasePlayer.pl.deadflag'), es.getUseridList()): """ Loop through all the living players on their team """ xx, yy, zz = es.getplayerlocation(teamPlayer) if ( (x - xx) ** 2 + (y - yy) ** 2 + (z - zz) ** 2 ) ** 0.5 <= distance: health = es.getplayerprop(teamPlayer, 'CBasePlayer.m_iHealth') sourcerpgPlayer = sourcerpg.players[teamPlayer] if health < sourcerpgPlayer['maxHealth']: if health + healing > sourcerpgPlayer['maxHealth']: armor = sourcerpgPlayer['maxHealth'] - health - healing es.setplayerprop(teamPlayer, 'CBasePlayer.m_iHealth', sourcerpgPlayer['maxHealth']) else: es.setplayerprop(teamPlayer, 'CBasePlayer.m_iHealth', healing + health) else: armor = healing if armor and self.gameName == "cstrike": """ if we're playing CSS and we have armor to increment, do the task """ maxArmor = sourcerpgPlayer['maxArmor'] currentArmor = es.getplayerprop(teamPlayer, 'CCSPlayer.m_ArmorValue') currentArmor += armor if currentArmor > maxArmor: currentArmor = maxArmor es.setplayerprop(teamPlayer, 'CCSPlayer.m_ArmorValue', currentArmor)
def player_spawn(event_var): """ Executed automatically when a player spawns, start the healing check @PARAM event_var - an automatically passed event instnace """ userid = event_var['userid'] if not es.getplayerprop(userid, 'CBasePlayer.pl.deadflag'): """ Player is alive, so it is the actual player spawn event """ if userid in heal: heal[userid].start(float(delay), 0)
def teleportPlayerToPlayer(userid, choice, popupid): target, recipient = choice if es.getplayerprop(target, 'CBasePlayer.pl.deadflag') or es.getplayerprop(recipient, 'CBasePlayer.pl.deadflag'): es.tell(userid, xalanguage('one player died', {}, playerlib.getPlayer(userid).get("lang") ) ) return if not es.exists('userid', target) or not es.exists('userid', recipient): """ One of the player's doesn't exists... Return early and break the function """ return x, y, z = es.getplayerlocation(recipient) z += 100 es.server.queuecmd('es_xsetpos %s %s %s %s' % (target, x, y, z) ) if not int(xa_anonymous): args = {} args["admin"] = es.getplayername(userid) args["target"] = es.getplayername(target) args["recipient"] = es.getplayername(recipient) for player in playerlib.getPlayerList("#all"): es.tell(int(player), xalanguage("player sent to player", args, player.get("lang") ) ) xateleport.logging.log("has teleported user %s [%s] to user %s [%s]" % (es.getplayername(target), es.getplayersteamid(target), es.getplayername(recipient), es.getplayersteamid(recipient) ), userid, True)
def addRestriction(self, weapon): """ Adds the weapon to the set of restricted weapons Calls the removeWeapon function on the RestrictedPlayer instance for each player on the restricted team """ weapon = weapon.replace('weapon_', '') if weapon in self.restrictions: return self.restrictions.add(weapon) for userid in filter(lambda x: es.getplayerteam(x) == self.teamnum if not es.getplayerprop(x, 'CBasePlayer.pl.deadflag') else False, es.getUseridList()): getPlayer(userid).removeWeapon(weapon)
def player_spawn(event_var): """ An event which occurs when a player spawns, ensure that their adrenalied key is set to False @PARAM event_var - an automatically passed event instance """ userid = event_var['userid'] if not es.getplayerprop(userid, 'CBasePlayer.pl.deadflag'): player = sourcerpg.players[userid] if player is not None: sourcerpg.players[userid]['adrenalined'] = False
def giveDeagle(userid): for x in xrange(7): # CSS players can have up to 7 weapons handle = es.getplayerprop(userid, 'CBaseCombatCharacter.m_hMyWeapons.%03d' % x) if handle > 0: index = es.getindexfromhandle(handle) weapon = weaponlib.getWeapon(es.entitygetvalue(index, 'classname')) if weapon is not None and 'secondary' in weapon.tags: if weapon != 'weapon_deagle': es.entitysetvalue(index, 'targetname', 'kill_me') es.server.insertcmd('es_xfire %(userid)s kill_me Kill;' 'es_xgive %(userid)s weapon_deagle' % {'userid': userid}) break
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 sourcerpg_skillupgrade(event_var): """ This event executes when a player's skill is upgraded. If the skill was regeneration, then stop any active regenerations, and create a new instance with the new values so that upgrades take place instantly @PARAM event_var - an auotomatically passed event instance """ if event_var['skill'] == skillName: userid = event_var['userid'] if not es.getplayerprop(userid, 'CBasePlayer.pl.deadflag'): regen[userid].stopRegen() regen[userid].startRegen( int(event_var['level']), float(regenDelay))