[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
Painkiller
Senior Member
Posts: 376
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

[HL2:DM] 3 Teams

Postby Painkiller » Sat May 12, 2018 1:56 pm

A 3 team based plugin.
I also want to be able to play the Spectator and automatically select the team at game start.
Who could do that for me?

Thanks in Advance
User avatar
Painkiller
Senior Member
Posts: 376
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] 3 Teams

Postby Painkiller » Sun Jun 03, 2018 11:55 am

Did anyone have an idea?
User avatar
Painkiller
Senior Member
Posts: 376
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] 3 Teams

Postby Painkiller » Thu Jun 14, 2018 6:22 am

Can someone help me,please?
User avatar
Kami
Global Moderator
Posts: 142
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Re: [HL2:DM] 3 Teams

Postby Kami » Thu Jun 14, 2018 6:17 pm

Syntax: Select all

from players.entity import Player
from events import Event
from filters.players import PlayerIter
import operator
from cvars import ConVar

count = {}

@Event('player_activate')
def player_connect(ev):
teamplay = ConVar('mp_teamplay').get_int()
if teamplay == 1:
userid = int(ev['userid'])
team = get_team()
player = Player.from_userid(userid)
player.team_index = team


def get_team():
count[1] = 0
count[2] = 0
count[3] = 0
for player in PlayerIter():
if player.team_index == 1:
count[1] += 1
if player.team_index == 2:
count[2] += 1
if player.team_index == 3:
count[3] += 1
return min(count.items(), key=operator.itemgetter(1))[0]
User avatar
Painkiller
Senior Member
Posts: 376
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] 3 Teams

Postby Painkiller » Mon Jun 18, 2018 5:24 pm

19:20:37 HLSW Information: Verbinde zu 176.9.155.153:28060 ...
19:20:37 sp info
19:20:37
IMPORTANT: Please copy the full output.
--------------------------------------------------------
Checksum : 7b3b484c8f9936548dd32d99afcf3275
Date : 2018-06-18 17:20:54.589205
OS : Linux-4.4.0-79-generic-x86_64-with-debian-jessie-sid
Game : hl2dm
SP version : 653
Github commit : e5c043f1c5d7e15aaaca30d8f6341363002d1240
Server plugins:
00: DoS Attack Fixer, www.sourceop.com
01: Metamod:Source 1.10.7-dev
02: PlayerLimitRemover, www.sourceop.com
03: Spawn/Chat Protection; by Bernt Nilsson, version 3.3.5 beta 2
04: Source.Python, (C) 2012-2018, Source.Python Team.
SP plugins:
00: download
01: team
--------------------------------------------------------

19:23:22 sp plugin reload team
19:23:22 [SP] Unloading plugin 'team'...
[SP] Successfully unloaded plugin 'team'.
[SP] Loading plugin 'team'...
[SP] Successfully loaded plugin 'team'.

Unfortunately I do not see a 3 team,
it loads normally without errors.
User avatar
Kami
Global Moderator
Posts: 142
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Re: [HL2:DM] 3 Teams

Postby Kami » Mon Jun 18, 2018 6:03 pm

There is no team to see. The plugin will check how many players are on each team and the one with the lowest players will be chosen for new players.

So if Team Rebel has 2 players, Team Combine has 2 players and Team Spectators has 1, then you will be assigned to Team spectator.

I'm not sure what else you wanted. You want a menu to choose your team or what?
User avatar
Painkiller
Senior Member
Posts: 376
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] 3 Teams

Postby Painkiller » Mon Jun 18, 2018 6:08 pm

Yes, a choice and the spectator should indeed be playable and not fly through the area.
Ja eine auswahl und der spectator sollte ja spielbar sein (rumlaufen können)und nicht durch die gegend fliegen.
User avatar
Kami
Global Moderator
Posts: 142
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Re: [HL2:DM] 3 Teams

Postby Kami » Mon Jun 18, 2018 7:00 pm

The team is playable for me:

Image

And what about choosing teams. In an ESC menu or how?

I just saw how to cut some lines too:

Syntax: Select all

from players.entity import Player
from events import Event
from filters.players import PlayerIter
import operator
from cvars import ConVar

count = {}


@Event('player_activate')
def player_connect(ev):
teamplay = ConVar('mp_teamplay').get_int()
if teamplay == 1:
userid = int(ev['userid'])
team = get_team()
player = Player.from_userid(userid)
player.team_index = team


def get_team():
count[1] = 0
count[2] = 0
count[3] = 0
for player in PlayerIter():
count[player.team_index] += 1
return min(count.items(), key=operator.itemgetter(1))[0]


Also this only works when mp_teamplay is 1
User avatar
Painkiller
Senior Member
Posts: 376
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] 3 Teams

Postby Painkiller » Mon Jun 18, 2018 7:26 pm

mp_teamplay is on.
The selection would be very cool about the motd.

Is that possible?

Image

I'm sorry for me Does the plugin not work.
I also have a Linux root
User avatar
Kami
Global Moderator
Posts: 142
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Re: [HL2:DM] 3 Teams

Postby Kami » Tue Jun 19, 2018 4:30 am

You will not See the spectator Team until someone is in it.
User avatar
Painkiller
Senior Member
Posts: 376
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] 3 Teams

Postby Painkiller » Tue Jun 19, 2018 8:34 am

I'm aware,

I am jointeam 1
this is a spectator but i could only fly.
User avatar
Kami
Global Moderator
Posts: 142
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Re: [HL2:DM] 3 Teams

Postby Kami » Tue Jun 19, 2018 12:12 pm

My Plugin does Not interfere with jointeam so that might be why it does Not Work.
User avatar
Painkiller
Senior Member
Posts: 376
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] 3 Teams

Postby Painkiller » Tue Jun 19, 2018 12:52 pm

What do I have to do then?

Would it also be possible for the team to choose the motd.txt if that works?
User avatar
Kami
Global Moderator
Posts: 142
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Re: [HL2:DM] 3 Teams

Postby Kami » Tue Jun 19, 2018 1:06 pm

This will take care of the jointeam problem:

Now can use 4 teams.

jointeam 0 = Team Unassigned
jointeam 1 = Team Spectator
jointeam 2 = Team Combine
jointeam 3 = Team Rebel

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
import random

count = {}

@Event('player_activate')
def player_connect(ev):
teamplay = ConVar('mp_teamplay').get_int()
if teamplay == 1:
userid = int(ev['userid'])
team = get_team()
player = Player.from_userid(userid)
player.team_index = team


def get_team():
count[1] = 0
count[2] = 0
count[3] = 0
for player in PlayerIter():
count[player.team_index] += 1
return min(count.items(), key=operator.itemgetter(1))[0]


@ClientCommand('jointeam')
def join_test(command,index):
team_to_join = int(command[1])
if team_to_join > 3:
team_to_join = 0
player = Player(index)
player.team_index = team_to_join
if team_to_join == 0:
team_message = "Unassigned"
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
Painkiller
Senior Member
Posts: 376
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] 3 Teams

Postby Painkiller » Tue Jun 19, 2018 1:25 pm

Now it seems to be funtioning.

Also team 0 works

Now you only need a choice when joins.

Good work

Edit: I noticed that I often get kicked out of the game.

Is there autokick_disabler for SP?
Last edited by Painkiller on Tue Jun 19, 2018 1:33 pm, edited 1 time in total.
User avatar
Kami
Global Moderator
Posts: 142
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Re: [HL2:DM] 3 Teams

Postby Kami » Tue Jun 19, 2018 1:27 pm

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
import random

count = {}

@Event('player_activate')
def player_connect(ev):
teamplay = ConVar('mp_teamplay').get_int()
if teamplay == 1:
userid = int(ev['userid'])
team = get_team()
player = Player.from_userid(userid)
player.team_index = team


def get_team():
count[1] = 0
count[2] = 0
count[3] = 0
for player in PlayerIter():
count[player.team_index] += 1
return min(count.items(), key=operator.itemgetter(1))[0]



@ClientCommand('jointeam')
def join_test(command,index):
team_to_join = int(command[1])
if team_to_join > 3:
team_to_join = 0
player = Player(index)
player.team_index = team_to_join
player.client_command("kill", True)
if team_to_join == 0:
team_message = "Unassigned"
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


This version will kill you when using jointeam, so people cannot abuse it.

Also I am not familiar with MODT editing so I cannot help you with that.
User avatar
Painkiller
Senior Member
Posts: 376
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] 3 Teams

Postby Painkiller » Tue Jun 19, 2018 1:46 pm

motd can html
it just lacks something where it refers I think.

Edit: Team 0 immediately refers to team 2 or 3

After mapchange you are assigned another team that is bad.


Edit 2: If possible, please make an ESC menu?
User avatar
Kami
Global Moderator
Posts: 142
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Re: [HL2:DM] 3 Teams

Postby Kami » Tue Jun 19, 2018 2:02 pm

This is a version with ESC Menu.

The plugin now works like this:

When you join you will be assigned to the team with the lowest players and you are sent an ESC Menu too.

Then you have the option to write !team in the chat to open up the ESC Menu again. You can also still use jointeam if you want

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
import random

count = {}

@SayCommand("!team")
def team_command(command, index, team=None):
choose_team_menu.send(index)

@Event('player_activate')
def player_connect(ev):
teamplay = ConVar('mp_teamplay').get_int()
if teamplay == 1:
userid = int(ev['userid'])
team = get_team()
player = Player.from_userid(userid)
player.team_index = team
choose_team_menu.send(player.index)


def get_team():
count[1] = 0
count[2] = 0
count[3] = 0
for player in PlayerIter():
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)
Player(index).client_command("kill", True)

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.client_command("kill", True)
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



Edit: I just saw your complaints about the unassigned team and you are right, on spawn it will choose a team from the two "real" ones. So in the version above I removed the Unassigned Team as it seems to have unexpected behavior.
User avatar
Painkiller
Senior Member
Posts: 376
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] 3 Teams

Postby Painkiller » Tue Jun 19, 2018 2:08 pm

The chat command !team does not work.
After mapchange you are still thrown into another team.

Could you stay in the same team?

Edit: I tested it again on a new server.
As far as everything seems to work.
Only the mapchange does not work.
He always throws into team 1 (spec)
Last edited by Painkiller on Tue Jun 19, 2018 3:08 pm, edited 1 time in total.
User avatar
satoon101
Project Leader
Posts: 2573
Joined: Sat Jul 07, 2012 1:59 am

Re: [HL2:DM] 3 Teams

Postby satoon101 » Tue Jun 19, 2018 3:08 pm

Just an fyi, but you don't need to explicitly import ESCMenu/Option for hl2mp, as that is the default for that game (since it doesn't support Radio Menus):
https://github.com/Source-Python-Dev-Te ... t__.py#L13
Image

Return to “Plugin Requests”

Who is online

Users browsing this forum: No registered users and 2 guests