def acquire_player_id(self): """temporarily borrow a player ID to score""" max_players = min(32, self.protocol.max_players) if len(self.protocol.connections) >= max_players: try: self.player_id = next(self.team.get_players()).player_id except StopIteration: self.player_id = None return self.player_id is not None self.player_id = self.protocol.player_ids.pop() self.protocol.player_ids.put_back(self.player_id) # just borrowing it! create_player = loaders.CreatePlayer() create_player.x = 0 create_player.y = 0 create_player.z = 63 create_player.weapon = RIFLE_WEAPON create_player.player_id = self.player_id create_player.name = self.team.name create_player.team = self.team.id self.protocol.broadcast_contained(create_player, save=True) return True
from pyspades.protocol import BaseConnection from pyspades.constants import * from pyspades.packet import call_packet_handler, register_packet_handler from pyspades import contained as loaders from pyspades.collision import vector_collision, collision_3d from pyspades import world from pyspades.common import Vertex3, get_color, make_color from pyspades.weapon import WEAPONS from pyspades.mapgenerator import ProgressiveMapGenerator set_tool = loaders.SetTool() block_action = loaders.BlockAction() position_data = loaders.PositionData() restock = loaders.Restock() create_player = loaders.CreatePlayer() intel_pickup = loaders.IntelPickup() intel_capture = loaders.IntelCapture() intel_drop = loaders.IntelDrop() player_left = loaders.PlayerLeft() set_hp = loaders.SetHP() existing_player = loaders.ExistingPlayer() kill_action = loaders.KillAction() chat_message = loaders.ChatMessage() map_data = loaders.MapChunk() map_start = loaders.MapStart() state_data = loaders.StateData() ctf_data = loaders.CTFState() tc_data = loaders.TCState() change_weapon = loaders.ChangeWeapon() weapon_reload = loaders.WeaponReload()