当前位置: 首页>>代码示例>>Python>>正文


Python Player.from_userid方法代码示例

本文整理汇总了Python中players.entity.Player.from_userid方法的典型用法代码示例。如果您正苦于以下问题:Python Player.from_userid方法的具体用法?Python Player.from_userid怎么用?Python Player.from_userid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在players.entity.Player的用法示例。


在下文中一共展示了Player.from_userid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: info_menu

# 需要导入模块: from players.entity import Player [as 别名]
# 或者: from players.entity.Player import from_userid [as 别名]
	def info_menu(self, userids = []):
		try:
			info_menu = SimpleMenu(build_callback=self.callback_info_menu)
			list = []
			if type(userids) is not list:
				player = Player.from_userid(userids)
				list = [player.index]
			else:
				for item in userids:
					player = Player.from_userid(item)
					list.append(player.index)
			info_menu.send(list)
		except:
			msg('ERROR', 'could not send info menu to one or more players')
开发者ID:Kandru,项目名称:conquest-go,代码行数:16,代码来源:flags.py

示例2: _player_death

# 需要导入模块: from players.entity import Player [as 别名]
# 或者: from players.entity.Player import from_userid [as 别名]
def _player_death(game_event):
    # Dead Strip
    remove_idle_weapons(status=GunGameMatchStatus.WARMUP)

    # Dissolver
    victim = game_event['userid']
    try:
        inthandle = Player.from_userid(victim).ragdoll
    except ValueError:
        return
    if inthandle == INVALID_ENTITY_INTHANDLE:
        return
    entity = Entity(index_from_inthandle(inthandle))
    entity.target_name = f'ragdoll_{victim}'
    dissolver_entity = Entity.find_or_create('env_entity_dissolver')
    dissolver_entity.magnitude = 2
    dissolver_entity.dissolve_type = 0
    dissolver_entity.dissolve(f'ragdoll_{victim}')

    # DeathMatch
    Delay(
        delay=2,
        callback=_respawn_player,
        args=(victim,),
        cancel_on_level_end=True,
    )
开发者ID:GunGame-Dev-Team,项目名称:GunGame-SP,代码行数:28,代码来源:listeners.py

示例3: update_player_data

# 需要导入模块: from players.entity import Player [as 别名]
# 或者: from players.entity.Player import from_userid [as 别名]
	def update_player_data(self, userid, data):
		try:
			player = Player.from_userid(userid)
			if not player.address or player.steamid == 'BOT':
				return
			tmp_keys = ''
			tmp_values = []
			lock = False
			self.player_data_lock.acquire()
			lock = True
			for item in data:
				tmp_keys = tmp_keys + ', ' + item + ' = %s'
				tmp_values.append(data[item])
				if item == 'rank':
					data[item] = json.loads(data[item])
				self.players[player.steamid][item] = data[item]
			self.player_data_lock.release()
			lock = False
			tmp_values.append(player.steamid)
			sql = "UPDATE `players` SET " + tmp_keys[1:] + " WHERE steamid = %s"
			self.db.query(sql, tmp_values, wait=False)
		except:
			if lock:
				self.player_data_lock.release()
			msg('ERROR', 'could not update player data')
开发者ID:Kandru,项目名称:conquest-go,代码行数:27,代码来源:rank.py

示例4: _remove_radar_from_player

# 需要导入模块: from players.entity import Player [as 别名]
# 或者: from players.entity.Player import from_userid [as 别名]
def _remove_radar_from_player(userid):
    """Remove the player's radar."""
    with suppress(KeyError):
        del _flashed_players[userid]
    player = Player.from_userid(userid)
    player.flash_alpha = 0
    player.flash_duration = time()
开发者ID:GunGame-Dev-Team,项目名称:GunGame-SP,代码行数:9,代码来源:cstrike.py

示例5: player_give_weapon

# 需要导入模块: from players.entity import Player [as 别名]
# 或者: from players.entity.Player import from_userid [as 别名]
	def player_give_weapon(self, userid):
		try:
			player = Player.from_userid(userid)
			if not player.address or player.steamid == 'BOT':
				return
			if player.team not in (2,3):
				return
			# get player team
			pteam = self.get_player_team(userid)
			pdata = self.get_player_data(userid)
			for index in player.weapon_indexes():
				weapon = Entity(index)
				player.drop_weapon(weapon.pointer, player.origin, player.origin)
				weapon.remove()
			# get new weapons
			player.give_named_item('weapon_knife', 0, None, True)
			if pteam in pdata['loadout1']:
				if str(pdata['class']) in pdata['loadout1'][pteam]:
					if 'primary' in pdata['loadout1'][pteam][str(pdata['class'])]:
						player.give_named_item(pdata['loadout1'][pteam][str(pdata['class'])]['primary'], 0, None, True)
					if 'secondary' in pdata['loadout1'][pteam][str(pdata['class'])]:
						player.give_named_item(pdata['loadout1'][pteam][str(pdata['class'])]['secondary'], 0, None, True)
					for item in self.weapons:
						if int(self.weapons[item]['rank']) <= int(pdata['rank'][str(pdata['class'])]) and int(self.weapons[item]['type']) == 3 and pteam == self.weapons[item]['team'] and int(pdata['class']) == self.weapons[item]['class']:
							for x in range(0, self.weapons[item]['amount']):
								Delay(0, player.give_named_item, self.weapons[item]['slug'], 0, None, True)
			# give kevlar (and helmet on lvl 20 or above)
			if int(pdata['rank'][str(pdata['class'])]) < 20:
				player.give_named_item('item_kevlar', 0, None, True)
			else:
				player.give_named_item('item_assaultsuit', 0, None, True)
			# ready for spawn let other plugins know
			self.callbacks.execute('player_is_spawned', player.userid)
		except:
			msg('INFO', 'could not give weapon to player')
开发者ID:Kandru,项目名称:conquest-go,代码行数:37,代码来源:rank.py

示例6: _print_all_registered_cfg_scripts

# 需要导入模块: from players.entity import Player [as 别名]
# 或者: from players.entity.Player import from_userid [as 别名]
def _print_all_registered_cfg_scripts(userid=0):
    import es
    from .logic import cfg_scripts

    if userid > 0:
        try:
            player = Player.from_userid(userid)
        except ValueError:
            return
    else:
        player = None

    header = 'EventScripts Script packs:'
    sep = '------------------------------------------'
    if player is not None:
        player.client_command('echo {}'.format(header))
        player.client_command('echo {}'.format(sep))
    else:
        es.dbgmsg(0, header)
        es.dbgmsg(0, sep)

    for index, (scriptpack, enabled) in enumerate(cfg_scripts.items()):
        msg = '{:02d}   {}   "{}"'.format(index, '[on]' if enabled else '[off]', scriptpack)
        if player is not None:
            player.client_command('echo {}'.format(msg))
        else:
            es.dbgmsg(0, msg)


    if player is not None:
        player.client_command('echo {}'.format(sep))
    else:
        es.dbgmsg(0, sep)
开发者ID:Ayuto,项目名称:EventScripts-Emulator,代码行数:35,代码来源:helpers.py

示例7: player_check_rank

# 需要导入模块: from players.entity import Player [as 别名]
# 或者: from players.entity.Player import from_userid [as 别名]
	def player_check_rank(self, userid):
		try:
			player = Player.from_userid(userid)
			if not player.address or player.steamid == 'BOT':
				return
			# get player team
			pteam = self.get_player_team(userid)
			pdata = self.get_player_data(userid)
			if player.steamid in self.players:
				new_rank = int(pdata['rank'][str(pdata['class'])]) + 1
				if new_rank in self.ranks:
					if player.cash >= int(self.ranks[new_rank]['points_needed']):
						player.cash = player.cash - int(self.ranks[new_rank]['points_needed'])
						pdata['rank'][str(pdata['class'])] = int(new_rank)
						self.update_player_data(userid, {
							'cash': player.cash,
							'rank': json.dumps(pdata['rank'])
						})
						SayText2('New Rank: {} ({})'.format(str(new_rank), self.classes[pdata['class']]['name'])).send(player.index)
						for item in self.weapons:
							if int(self.weapons[item]['rank']) == int(new_rank) and pteam == self.weapons[item]['team'] and int(pdata['class']) == self.weapons[item]['class']:
								SayText2('New Weapon: {}'.format(self.weapons[item]['name'])).send(player.index)
								# ability to change weapon on next spawn because of a new weapon
								self.update_player_data(userid, {
									'change_loadout1': 1
								})
						self.player_check_rank(userid)
						#TODO: notification for new rank (e.G. Sound?)
		except:
			msg('ERROR', 'could not check player rank')
			self.player_data_lock.release()
开发者ID:Kandru,项目名称:conquest-go,代码行数:33,代码来源:rank.py

示例8: player_set_model

# 需要导入模块: from players.entity import Player [as 别名]
# 或者: from players.entity.Player import from_userid [as 别名]
	def player_set_model(self, userid, modelid):
		try:
			player = Player.from_userid(userid)
			if int(modelid) in self.skins:
				player.model = self.skins[int(modelid)]['model']
		except:
			msg('ERROR', 'could not set player model')
开发者ID:Kandru,项目名称:conquest-go,代码行数:9,代码来源:rank.py

示例9: _player_say

# 需要导入模块: from players.entity import Player [as 别名]
# 或者: from players.entity.Player import from_userid [as 别名]
	def _player_say(self, userid, text):
		try:
			player = Player.from_userid(userid)
			if not player.address or player.steamid == 'BOT':
				return
			self.player_data_lock.acquire()
			if player.steamid not in self.players:
				self.player_data_lock.release()
				return
			self.player_data_lock.release()
			# change weapons
			change_weapons = ['!weapon','!weapons','!changeweapon','!changeweapons','!loadout','!changeloadout','!w','!cw']
			if text in change_weapons:
				self.update_player_data(userid, {
					'change_loadout1': 1
				})
				SayText2('You can change your loadout on next respawn!').send(player.index)
			# change class
			change_class = ['!class','!selectclass','!changeclass','!c','!sc']
			if text in change_class:
				self.update_player_data(userid, {
					'change_class': 1
				})
				SayText2('You can change your class on next respawn!').send(player.index)
			# change skin
			change_skin = ['!skin','!selectskin','!changeskin','!s']
			if text in change_skin:
				self.update_player_data(userid, {
					'change_skin': 1
				})
				SayText2('You can change your skin on next respawn!').send(player.index)
		except:
			msg('ERROR', 'could not work with player say event')
开发者ID:Kandru,项目名称:conquest-go,代码行数:35,代码来源:rank.py

示例10: execute

# 需要导入模块: from players.entity import Player [as 别名]
# 或者: from players.entity.Player import from_userid [as 别名]
    def execute(self, client, left_player):
        if left_player.is_fake_client() or left_player.is_hltv():
            client.tell(plugin_strings['error bot_cannot_ban'])
            return

        ip_address = extract_ip_address(left_player.address)
        if banned_ip_address_manager.is_banned(ip_address):
            client.tell(plugin_strings['error already_ban_in_effect'])
            return

        try:
            player = Player.from_userid(left_player.userid)
        except (OverflowError, ValueError):
            pass
        else:
            language = get_client_language(player.index)

            # Disconnect the player
            player.kick(
                plugin_strings['default_ban_reason'].get_string(language))

        duration = int(plugin_config['settings']['default_ban_time_seconds'])

        GameThread(
            target=banned_ip_address_manager.save_ban_to_database,
            args=(client.steamid, ip_address, left_player.name, duration)
        ).start()

        for ws_ban_ip_address_page in _ws_ban_ip_address_pages:
            ws_ban_ip_address_page.send_remove_id(left_player)

        log_admin_action(plugin_strings['message banned'].tokenized(
            admin_name=client.name,
            player_name=left_player.name,
        ))
开发者ID:Source-Python-Dev-Team,项目名称:Source.Python.Admin,代码行数:37,代码来源:ip_address.py

示例11: spawnprotection_end

# 需要导入模块: from players.entity import Player [as 别名]
# 或者: from players.entity.Player import from_userid [as 别名]
	def spawnprotection_end(self, userid):
		try:
			player = Player.from_userid(userid)
			player.set_godmode(False)
			self.msg_spawnprotection.send(player.index)
		except:
			msg('ERROR', 'could not disable godmode for player')
开发者ID:Kandru,项目名称:conquest-go,代码行数:9,代码来源:respawn.py

示例12: get_player_data

# 需要导入模块: from players.entity import Player [as 别名]
# 或者: from players.entity.Player import from_userid [as 别名]
	def get_player_data(self, userid):
		try:
			player = Player.from_userid(userid)
			if not player.address or player.steamid == 'BOT':
				return
			sql = "SELECT * FROM players WHERE steamid = %s LIMIT 0,1"
			row = self.db.query(sql, (player.steamid,), fetch_all = False)
			if row:
				player.cash = row['cash']
				if row['rank']:
					row['rank'] = json.loads(row['rank'])
				if row['skin']:
					row['skin'] = json.loads(row['skin'])
				if row['loadout1']:
					row['loadout1'] = json.loads(row['loadout1'])
			else:
				# if user does not exist in our database
				self.insert_player_data(userid)
				row = self.get_player_data(userid)
			self.player_data_lock.acquire()
			self.players[player.steamid] = row
			self.player_data_lock.release()
			return row
		except:
			msg('ERROR','could not get player data')
开发者ID:Kandru,项目名称:conquest-go,代码行数:27,代码来源:rank.py

示例13: menu_select_class

# 需要导入模块: from players.entity import Player [as 别名]
# 或者: from players.entity.Player import from_userid [as 别名]
	def menu_select_class(self, userid):
		player = Player.from_userid(userid)
		if not player.address or player.steamid == 'BOT':
			return
		pdata = self.get_player_data(userid)
		menu = ExtendedPagedMenu(title='Select Class', select_callback=self.menu_select_class_callback, on_close_menu=self.menu_select_class_close_callback)
		for item in self.classes:
			menu.append(PagedOption('{}, Rank: {}'.format(self.classes[item]['name'], pdata['rank'][str(item)]), str(item), selectable=True))
		menu.send(player.index)
开发者ID:Kandru,项目名称:conquest-go,代码行数:11,代码来源:rank.py

示例14: on_player_spawn

# 需要导入模块: from players.entity import Player [as 别名]
# 或者: from players.entity.Player import from_userid [as 别名]
def on_player_spawn(game_event):

    # We refresh HLTV index every time in case somebody kicks that poor guy
    player = Player.from_userid(game_event['userid'])
    if not player.is_hltv():
        return

    global hltv_index
    hltv_index = player.index
开发者ID:KirillMysnik,项目名称:sp-deadchat,代码行数:11,代码来源:deadchat.py

示例15: on_player_spawn

# 需要导入模块: from players.entity import Player [as 别名]
# 或者: from players.entity.Player import from_userid [as 别名]
def on_player_spawn(ev):
    player = Player.from_userid(ev['userid'])
    for ws_slay_page in _ws_slay_pages:
        if not ws_slay_page.filter(player):
            continue

        ws_slay_page.send_add_player(player)

    for ws_resurrect_page in _ws_resurrect_pages:
        ws_resurrect_page.send_remove_id(player)
开发者ID:Source-Python-Dev-Team,项目名称:Source.Python.Admin,代码行数:12,代码来源:admin_life_management.py


注:本文中的players.entity.Player.from_userid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。