本文整理汇总了Python中players.entity.Player类的典型用法代码示例。如果您正苦于以下问题:Python Player类的具体用法?Python Player怎么用?Python Player使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Player类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Client
class Client(BaseClient):
def __init__(self, index):
super().__init__()
self.player = Player(index)
self.active_popup = None
def has_permission(self, permission):
return auth_manager.is_player_authorized(self.player.index, permission)
def send_popup(self, popup):
if self.active_popup is not None:
self.active_popup.close(self.player.index)
self.active_popup = popup
popup.send(self.player.index)
def tell(self, message):
chat_message(message, (self.player.index,))
def sync_execution(self, callback, args=(), kwargs=None):
self.player.delay(0, callback, args, kwargs)
@property
def name(self):
return self.player.name
@property
def steamid(self):
return self.player.steamid
示例2: disable_damage_protection
def disable_damage_protection(player_index):
"""Disable spawn protection for the player."""
with suppress(ValueError):
player = Player(player_index)
player.godmode = False
player.color = WHITE
示例3: respawn_bots
def respawn_bots(game_event):
userid = game_event.get_int("userid")
index = index_from_userid(userid)
player = Player(index)
playerinfo = playerinfo_from_index(index)
if playerinfo.is_fake_client():
SayText2("Respawning {0}".format(player.name)).send()
Delay(2, player=Player(index))
player.respawn()
示例4: remove
def remove(self):
"""Remove the weapon."""
# Avoid a cyclic import
from players.entity import Player
owner = self.owner
if owner is not None and owner.is_player():
player = Player(owner.index)
player.drop_weapon(self)
super().remove()
示例5: info_menu
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')
示例6: __init__
def __init__(self, index, disconnected):
self._disconnected = disconnected
player = Player(index)
self.userid = player.userid
self.steamid = player.steamid
self.name = player.name
self.address = player.address
# Add some stuff to be able to be filtered by filters.players...
self._fake_client = player.is_fake_client()
self._hltv = player.is_hltv()
self.dead = player.dead
self.team = player.team
示例7: get_player_data
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')
示例8: _player_say
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')
示例9: _player_death
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,
)
示例10: sp_ignite
def sp_ignite(source, command):
if command.get_arg_count() == 1:
source.message("c=(white)[c=(purple)SPc=(white)] Usage: "
"c=(purple)sp_ignite $c=(white)<name|#userid|@filter> [time: 0]")
return CommandReturn.BLOCK
targets = target_filter(command[1], source.index)
time = int(command[2]) if command.get_arg_count() > 2 else 0
if len(targets) == 0:
source.message("c=(white)[c=(purple)SPc=(white)] No Targets found.")
else:
for target in targets:
player = Player(target)
player.ignite_lifetime(time) if time > 0 else player.ignite()
message_client(player.index, "You have been set on fire for " + str(time) + " seconds.")
source.message("c=(white)[c=(purple)SPc=(white)] Set " + str(len(targets)) + " players on fire.")
return CommandReturn.BLOCK
示例11: _remove_radar_from_player
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()
示例12: player_check_rank
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()
示例13: spawnprotection_end
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')
示例14: _print_all_registered_cfg_scripts
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)
示例15: execute
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,
))