Well you could always try and learn something new. That would propably make it easier for you to get things done.
Here is what you wanted, I hope it's okay that way as I do not plan to add anything more to it if you are not at least willing to try to understand whats done here.
This combines the 3 teams plugin with the custom team names plugin.
Syntax: Select all
from players.entity import Player
from events import Event
from filters.players import PlayerIter
from filters.entities import EntityIter
from entities.entity import Entity
import operator
from cvars import ConVar
from commands.client import ClientCommand
from commands import CommandReturn
from messages import SayText2
from commands.say import SayCommand
from menus.esc import SimpleESCMenu,SimpleESCOption
from listeners import OnClientActive,OnEntityCreated
import random
count = {}
player_team = {}
combine_name = "Combine"
rebels_name = "Rebels"
spectator_name = "Spectator"
@OnClientActive
def on_client_active(index):
teamplay = ConVar('mp_teamplay').get_int()
if teamplay == 1:
player = Player(index)
if player.userid in player_team:
player.client_command("jointeam %s" % player_team[player.userid])
else:
team = get_team()
player.team_index = team
choose_team_menu.send(player.index)
@OnEntityCreated
def OnEntityCreated(entity):
teamplay = ConVar('mp_teamplay').get_int()
if teamplay == 1:
if entity.classname == 'team_manager':
ent = Entity(entity.index)
ent.delay(0.1,change_team_name,(ent,))
def change_team_name(ent):
team_name = ent.get_property_string('m_szTeamname')
if team_name == "Combine":
ent.set_property_string("m_szTeamname",combine_name)
if team_name == "Rebels":
ent.set_property_string("m_szTeamname",rebels_name)
if team_name == "Spectator":
ent.set_property_string("m_szTeamname",spectator_name)
@SayCommand("!team")
def team_command(command, index, team=None):
choose_team_menu.send(index)
def get_team():
count[1] = 0
count[2] = 0
count[3] = 0
for player in PlayerIter():
if player.team_index != 0:
count[player.team_index] += 1
return min(count.items(), key=operator.itemgetter(1))[0]
def choose_team_select(menu,index,choice):
Player(index).client_command("jointeam %s" % choice.choice_index)
def choose_team_build(menu,index):
option = SimpleESCOption(1,'Spectator Team')
menu.append(option)
option = SimpleESCOption(2,'Combine Team')
menu.append(option)
option = SimpleESCOption(3,'Rebel Team')
menu.append(option)
choose_team_menu = SimpleESCMenu(select_callback=choose_team_select, build_callback=choose_team_build, title="Choose your team")
@ClientCommand('jointeam')
def join_test(command,index):
team_to_join = int(command[1])
if team_to_join > 3 or team_to_join < 1:
team_to_join = random.randint(1, 3)
player = Player(index)
player.team_index = team_to_join
player_team[player.userid] = team_to_join
player.team_index = team_to_join
player.spawn(True)
if team_to_join == 1:
team_message = spectator_name
if team_to_join == 2:
team_message = combine_name
if team_to_join == 3:
team_message = rebels_name
SayText2("\x04%s \x03changed to Team \x04%s" % (player.name,team_message)).send()
return CommandReturn.BLOCK
I hope you can figure out where your new team names go :)