Пример #1
0
def allow_message(cn,msg):
	if checkforCS(("ingame",cn),msg):
		return False
	if cn in muted_cns:
		triggerServerEvent("talk_blocked",[cn])
		return False
	return True
Пример #2
0
def kick(caller,cn):
        """This allows the caller to kick another player; however, this will not override players with higher permission. Meaning, a master level permission can not kick someone with admin or trusted permission. To prevent the player from rejoining the server, they will also be banned for the default 60 minutes."""
	cn=int(cn)
	UserSessionManager.checkPermissions(caller,UserSessionManager[("ingame",cn)][1]) #check if the other person is more privileged
	
	ban(caller,sbserver.playerName(cn),"kicked by %s" % formatCaller(caller))
	triggerServerEvent("player_kicked",[caller,cn])
	return sbserver.playerKick(cn)
Пример #3
0
	def failauth(self, args):
		self.responses_needed -= 1
		auth_id = args.split(' ')[0]
		try:
			self.pop_auth(int(auth_id))
		except KeyError:
			raise AuthError('Could not find matching auth request for given auth request id')
		triggerServerEvent('player_auth_fail', (auth.cn, auth.name))
Пример #4
0
	def privmsg(self, user, channel, msg):
		user = user.split('!', 1)[0]
		if channel == self.nickname:
			if checkforCS(("irc",user),msg)==0:
				msg="@"+msg
				checkforCS(("irc",user),msg)
		else:
			if(checkforCS(("irc",user),msg)==0):
				triggerServerEvent("user_communication",[("irc",user),msg])
Пример #5
0
def kick(caller,cn):
	"""Kicks another player; however, this command does not work on players with higher permission. Kicking a player also gives them a 60 minute ban."""
	cn=int(cn)
	try:
		UserSessionManager.checkPermissions(caller,UserSessionManager[("ingame",cn)][1]) #check if the other person is more privileged
	except PermissionError:
		triggerServerEvent("player_kick_failed",[caller,cn])
		raise
	
	ban(caller,sbserver.playerName(cn),"kicked by %s" % formatCaller(caller))
	triggerServerEvent("player_kicked",[caller,cn])
	return sbserver.playerKick(cn)
Пример #6
0
def savemap(caller,name=None):
	"""Saves the map to the server. Note that the map must be sent prior to saving."""
	if name is None:
		name=sbserver.mapName()
	ogzfilename,ogz=openfile(os.path.join("maps",name+".ogz"),"wb")
	
	mapdata=sbserver.getMapDataFile()
	mapdata.seek(0)
	ogz.write(mapdata.read())
	ogz.close()
	
	triggerServerEvent("savemap",[caller,name,ogzfilename])
Пример #7
0
def savemap(caller,name=None):
        """This allows players to savemaps to the server. This not only allows for easier transfer of files later on, but also allows for partial asynchronous work on a map by saving the map back to the server."""
	if name is None:
		name=sbserver.mapName()
	ogzfilename,ogz=openfile(os.path.join("maps",name+".ogz"),"wb")
	
	mapdata=sbserver.getMapDataFile()
	mapdata.seek(0)
	ogz.write(mapdata.read())
	ogz.close()
	
	triggerServerEvent("savemap",[caller,name,ogzfilename])
Пример #8
0
def mute(caller,*args):
        """If there are no arguments other than #mute then the caller will be muted. The first argument is a boolen that says what state of muted the player will be (0 for not muted and 1 for muted), anything other than 0 will result in an mute. The cn is the client number of the player that caller want muted. If left off it will apply to the caller."""
	if(len(args)==1):
		boolean=1
		cn=args[0]
	elif(len(args)==2):
		boolean=args[0]
		cn=args[1]
	else:
		raise TypeError("mute takes either 1 or 2 arguments.")
	boolean=int(boolean)
	cn=int(cn)
	
	triggerServerEvent("player_muted",[caller,boolean,cn])
Пример #9
0
def mute(caller,*args):
	"""Sets a mute on the given cn. If the cn is left off it applies to the caller."""
	if(len(args)==1):
		boolean=1
		cn=args[0]
	elif(len(args)==2):
		boolean=args[0]
		cn=args[1]
	else:
		raise TypeError("mute takes either 1 or 2 arguments.")
	boolean=int(boolean)
	cn=int(cn)
	
	triggerServerEvent("player_muted",[caller,boolean,cn])
Пример #10
0
def loadmap(caller,name=None):
        """This is the opposite of #savemap. This is automatically executed when you change to a map that the server has in storage."""
	if name is None:
		name=sbserver.mapName()
	
	ogzfilename,ogz=openfile(os.path.join("maps",name+".ogz"),"rb")
	
	mapdata=sbserver.getMapDataFile()
	mapdata.seek(0)
	mapdata.truncate(0)
	mapdata.write(ogz.read())
	mapdata.flush()
	ogz.close()
	
	triggerServerEvent("loadmap",[caller,name,ogzfilename])
Пример #11
0
def CSserverPM(caller, cn, *what):
	"""Allows players to pm other players."""
	string=' '.join(map(str,what))
	try:
		cn = int(cn)
		reciver = ("ingame", cn)
		if caller[0] == "ingame":
			namecn = " ("+str(caller[1])+"): "
		else:
			namecn = ""
		string1 = formatCaller(caller) + namecn
		newstring = color(3, string1+string)
		playerCS.executeby(reciver,"echo \"%s\"" %newstring)
	except ValueError:
		triggerServerEvent("pm",[caller,cn,string])
	return string
Пример #12
0
def editmute(caller,boolean=None,cn=None):
	"""Sets an editmute on the given cn. If the cn is left off it applies to the caller."""
	#empty args
	if boolean is None:
		boolean=1
	
	if cn is None:
		if(caller[0]=="ingame"):
			cn=caller[1]
		else:
			raise ServerError("You are not ingame. Please specify cn.")
	cn=int(cn)
	boolean=int(boolean)
	
	if boolean:
		spectator(caller,0,cn)
		sbserver.editMute(cn)
		triggerServerEvent("player_editmuted",[cn])
	else:
		sbserver.editUnmute(cn)
		triggerServerEvent("player_editunmuted",[cn])
Пример #13
0
def editmute(caller,boolean=None,cn=None):
        """If there are no arguments other than #editmute then the caller will be editmuted. The first argument is a boolen that says what state of editmuted the player will be (0 for not editmuted and 1 for editmuted), anything other than 0 will result in an editmute. The cn is the client number of the player that the caller want editmuted. If left off it will apply to the caller."""
	#empty args
	if boolean is None:
		boolean=1
	
	if cn is None:
		if(caller[0]=="ingame"):
			cn=caller[1]
		else:
			raise ServerError("You are not ingame. Please specify cn.")
	cn=int(cn)
	boolean=int(boolean)
	
	if boolean:
		spectator(caller,0,cn)
		sbserver.editMute(cn)
		triggerServerEvent("player_editmuted",[cn])
	else:
		sbserver.editUnmute(cn)
		triggerServerEvent("player_editunmuted",[cn])
Пример #14
0
def voteMap(caller,name,mode=None):
	"""Places a vote for the map of choice. This can be used to call maps from /storage/maps."""
	if mode is None:
		mode=sbserver.gameMode()
	triggerServerEvent("vote_map",[caller,modeNumber(mode),name])
Пример #15
0
def changeMap(caller,name,mode=None):
        """This command works just like the #map command except rather than directly going to a map it places a vote for the map of choice. Just like with #map, the caller can also call maps from /storage/maps. This calls the map from the server removing the need to /sendmap (as long as the maps are the same version)."""
	if mode is None:
		mode=sbserver.gameMode()
	triggerServerEvent("vote_map",[caller,modeNumber(mode),name])
Пример #16
0
def echo(caller,*what):
        """This is how the caller can read the output from some commands. Examples: listusersessions, list, user, who, whoami. Note that the command must be in parentheses. #echo (command)"""
	string=' '.join(map(str,what))
	triggerServerEvent("echo",[caller,string])
	return string
Пример #17
0
def say(caller,*what):
        """This commad says string to the server, simialar to #notice, just without the Notice from PlayerName: MESSAGE HERE"""
	string=' '.join(map(str,what))
	triggerServerEvent("say",[string])
	return string
Пример #18
0
	def succreg(self, args):
		self.responses_needed -= 1
		serverNotice('Master server registration successful')
		triggerServerEvent('master_registration_succeeded', ())
Пример #19
0
def clientMapVote(caller,mapname,mode):
	caller=("ingame",caller)
	try:
		playerCS.executeby(caller,"map %s %s" % (mapname,mode))
	except PermissionError:
		triggerServerEvent("vote_map",[caller,mode,mapname])
Пример #20
0
def say(caller,*what):
	"""Causes the server to say the input, simialar to #notice, without "Notice from PlayerName: MESSAGE HERE"""
	string=' '.join(map(str,what))
	triggerServerEvent("say",[string])
	return string
Пример #21
0
	def failreg(self, args):
		self.responses_needed -= 1
		serverNotice('Master server registration failed: %s' % args)
		triggerServerEvent('master_registration_failed', ())
Пример #22
0
def serverNotice(string):
	print "Notice: ",string
	triggerServerEvent("notice",[string])
Пример #23
0
def PlayerMessage(cn,msg):
	triggerServerEvent("user_communication",[("ingame",cn),msg])