[Script] organiser.py

Intended for use on live public servers.
44 posts Page 1 of 3 First unread post
VladVP
Post Demon
Post Demon
Posts: 1425
Joined: Fri Dec 14, 2012 10:48 pm


Contents
Prologue
Give me the script goddamnit
How the hell do I use this piece of brainfuck?


Prologue
It all started when I found a random server link in #buildandshoot, and I thought that it was just one of those faggots who advertise for their own servers. Turns out it was actually a league match. ohgodwhy.png
Yeah.
That was unfortunate.
So I got an idea! What if there were a script which prevented certain players from joining specific teams? That way I no one would ever get in such awkward situations again!



Give me the script goddamnit

Okay, okay! Easy on! Here's the code:
Code: Select all
#organiser.py
#by VladVP

from commands import add, admin, name

on_by_default = True

@name('to')
@admin
def toggleorganisation(connection):
	global on_by_default
	if on_by_default is True:
		on_by_default = False
		connection.protocol.send_chat("Team organisation disabled!")
	else:
		on_by_default = True
		connection.protocol.send_chat("Team organisation enabled!")

add(toggleorganisation)

def apply_script(protocol, connection, config):
	class orgConnection(connection):
		def spawn(self):
			if on_by_default:
				protocol = self.protocol
				name = self.name
				
				blue = config.get("team_preset", []).get("blue", [])
				green = config.get("team_preset", []).get("green", [])
				blueclan = config.get("team_preset", []).get("blueclan", [])
				greenclan = config.get("team_preset", []).get("greenclan", [])
				
				if   name in blue:
					self.team = protocol.blue_team
				elif name in green:
					self.team = protocol.green_team
				else:
					for clan in blueclan:
						if name.find(clan) + 1:
							self.team = protocol.blue_team
							return connection.spawn(self)
					for clan in greenclan:
						if name.find(clan) + 1:
							self.team = protocol.green_team
							return connection.spawn(self)
					self.team = protocol.spectator_team
			return connection.spawn(self)
	return protocol, orgConnection
organiser.py
(1.34 KiB) Downloaded 200 times


How the hell do I use this piece of brainfuck?

Pretty damn simple! Just add this to config.txt:
Code: Select all
	"team_preset" : {
		"blueclan" : ["{RoT}", "[AK]"],
		"blue" : [
			"Deuce",
			"xXxX1337snipz0r[PRO]XxXx",
			"Blueman"
		],
		"greenclan" : ["[CFKS]", "Ohh|"],
		"greenish" : [
			"Polak",
			"Vlad",
			"Greenman"
		]
	}
By looking at that, you should already have found out how this works. Basically, whenever someone spawns, they will be forced onto the team that their player name is associated with. And if they're not in either list, they will be forced into spectator mode. Plain and simple!
I was about to add a /login functonality, but thought that it was probably unneeded, as I've designed this primarily for events and league matches.
UPDATE: Now you can also associate clan tags with teams! Check the above to see how to do that. Also, all JSON objects related to this script are now optional to specify.
Last edited by VladVP on Fri Oct 11, 2013 1:08 pm, edited 2 times in total.
Lostmotel
League Participant
League Participant
Posts: 298
Joined: Sun Nov 18, 2012 1:09 pm


great work!
Would it be possible to add a command to toggle the script on and off? It would be hard to maintain a good teambalance in bigger matches when no one is able to switch teams.
VladVP
Post Demon
Post Demon
Posts: 1425
Joined: Fri Dec 14, 2012 10:48 pm


Lostmotel wrote:
great work!
Would it be possible to add a command to toggle the script on and off? It would be hard to maintain a good teambalance in bigger matches when no one is able to switch teams.
Sure. here you go:
Code: Select all
#organiser.py
#by VladVP

from commands import add, admin, name

on_by_default = True

@name('to')
@admin
def toggleorganisation(connection):
	global on_by_default
	if on_by_default is True:
		on_by_default = False
		connection.protocol.send_chat("Team organisation disabled!")
	else:
		on_by_default = True
		connection.protocol.send_chat("Team organisation enabled!")

add(toggleorganisation)

def apply_script(protocol, connection, config):
	class orgConnection(connection):
		def spawn(self):
			if on_by_default:
				protocol = self.protocol
				blue = config.get("team_preset", None).get("blue", None)
				if blue == None: return False
				green = config.get("team_preset", None).get("green", None)
				if green == None: return False
				if   self.name in blue:
					self.team = protocol.blue_team
				elif self.name in green:
					self.team = protocol.green_team
				else:
					self.team = protocol.spectator_team
			return connection.spawn(self)
	return protocol, orgConnection
organiser.py
(1021 Bytes) Downloaded 192 times
Use /to to toggle it.

I will also add the new version to the OP.
Kuma
Scripter
Scripter
Posts: 758
Joined: Fri Mar 22, 2013 10:05 am


Would you be interested in merging our scripts? (Mine is for mass switching of players)
http://buildandshoot.com/viewtopic.php?f=19&t=6292
VladVP
Post Demon
Post Demon
Posts: 1425
Joined: Fri Dec 14, 2012 10:48 pm


Kuma wrote:
Would you be interested in merging our scripts? (Mine is for mass switching of players)
http://buildandshoot.com/viewtopic.php?f=19&t=6292
Why not just make an entire toolkit for event organisation?
Kuma
Scripter
Scripter
Posts: 758
Joined: Fri Mar 22, 2013 10:05 am


VladVP wrote:
Kuma wrote:
Would you be interested in merging our scripts? (Mine is for mass switching of players)
http://buildandshoot.com/viewtopic.php?f=19&t=6292
Why not just make an entire toolkit for event organisation?
Sure
EldredChandler
Build and Shoot's 1st Birthday
Build and Shoot's 1st Birthday
Posts: 730
Joined: Mon Nov 05, 2012 5:09 pm


Seems like a ton of work gathering the in game names of up to 32 player, then manually adding them in, then having to redo it again, for a different match.
Kuma
Scripter
Scripter
Posts: 758
Joined: Fri Mar 22, 2013 10:05 am


EldredChandler wrote:
Seems like a ton of work gathering the in game names of up to 32 player, then manually adding them in, then having to redo it again, for a different match.
Its better than having to lock and unlock teams, after all we can't make a script which reads your brain can we?
EldredChandler
Build and Shoot's 1st Birthday
Build and Shoot's 1st Birthday
Posts: 730
Joined: Mon Nov 05, 2012 5:09 pm


What if someone joins with a mispelled name? eg. on script its Eldred but in game is Eldrde?
Kuma
Scripter
Scripter
Posts: 758
Joined: Fri Mar 22, 2013 10:05 am


EldredChandler wrote:
What if someone joins with a mispelled name? eg. on script its Eldred but in game is Eldrde?
well, that is the problem. ADVERTISING WHORE ALERT, my script allows to switch multiple people to a certain team and thats why I asked him to merge our script.
EldredChandler
Build and Shoot's 1st Birthday
Build and Shoot's 1st Birthday
Posts: 730
Joined: Mon Nov 05, 2012 5:09 pm


This is more effort than locking the teams after the clans have joined.
Kuma
Scripter
Scripter
Posts: 758
Joined: Fri Mar 22, 2013 10:05 am


EldredChandler wrote:
This is more effort than locking the teams after the clans have joined.
what do you mean
EldredChandler
Build and Shoot's 1st Birthday
Build and Shoot's 1st Birthday
Posts: 730
Joined: Mon Nov 05, 2012 5:09 pm


Gee wiz, I better go config 2 different scripts, rather than doing it the way that works fine.
Kuma
Scripter
Scripter
Posts: 758
Joined: Fri Mar 22, 2013 10:05 am


EldredChandler wrote:
Gee wiz, I better go config 2 different scripts, rather than doing it the way that works fine.
*facepalm*
VladVP script allows you to add names and associate them to a team, so on spawn only that player can join the team (So even if they are in spectator they still can join the team they are assigned to)
While me script is command based(you just need to add it to scripts and config file) and if a admin type /sl the green and blue teams get locked and everyone goes to the spectator team, and there is the multiswitch command /ms which can be used like /ms green kuma vlad polm eldred gen lostmotel lelue and all these will go to the green team.
EldredChandler
Build and Shoot's 1st Birthday
Build and Shoot's 1st Birthday
Posts: 730
Joined: Mon Nov 05, 2012 5:09 pm


VladVP script allows you to add names and associate them to a team, so on spawn only that player can join the team (So even if they are in spectator they still can join the team they are assigned to)
Right, but thats only assuming they always keep the exact same name.
While me script is command based(you just need to add it to scripts and config file) and if a admin type /sl the green and blue teams get locked and everyone goes to the spectator team, and there is the multiswitch command /ms which can be used like /ms green kuma vlad polm eldred gen lostmotel lelue and all these will go to the green team.
So, your solution is to lock both teams, then type the names of 32 people to get them on the correct team?
44 posts Page 1 of 3 First unread post
Return to “Completed Releases”

Who is online

Users browsing this forum: No registered users and 19 guests