[HL2:DM] 3 Teams

A place for requesting new Source.Python plugins to be made for your server.

Please request only one plugin per thread.
User avatar
Global Moderator
Posts: 128
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Re: [HL2:DM] 3 Teams

Postby Kami » Tue Jun 19, 2018 4:48 pm

Thank you satoon for pointing that out to me!

This version will remember which team you are on after mapchange (also it does not kill you on team change anymore, just respawns you)

Syntax: Select all

from players.entity import Player
from events import Event
from filters.players import PlayerIter
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
import random

count = {}
player_team = {}

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])
team = get_team()
player.team_index = team

def team_command(command, index, team=None):

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')
option = SimpleESCOption(2,'Combine Team')
option = SimpleESCOption(3,'Rebel Team')

choose_team_menu = SimpleESCMenu(select_callback=choose_team_select, build_callback=choose_team_build, title="Choose your team")

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
if team_to_join == 1:
team_message = "Specator"
if team_to_join == 2:
team_message = "Combine"
if team_to_join == 3:
team_message = "Rebel"
SayText2("\x04%s \x03changed to Team \x04%s" % (player.name,team_message)).send()
return CommandReturn.BLOCK
User avatar
Senior Member
Posts: 362
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany

Re: [HL2:DM] 3 Teams

Postby Painkiller » Tue Jun 19, 2018 5:37 pm

Work Good

Big Thanks Kami and thanks Satoon.

Return to “Plugin Requests”

Who is online

Users browsing this forum: No registered users and 2 guests