Here's a new python script that allows your SMP server to have OPs, use the !kick command, and the !# command (to allow a player to give themselves items!)
You can add OPs to your server by adding their names to the oplist.txt file. As well, you can add a list of blocks that non-ops can give themselves into the blocklist.txt file.
nyko add this to urs and test it i would think it has been tested before release and its not like what it dose is any thing new it just makes it more simple.
#Observer V1.0 by koufu
#This script is BSD licensed.
import subprocess, string, time
args = 'java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui'.split()
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
#Edit me to change the placement limit for non-ops!
limit = 16
oplist = []
blocklist = []
f = open('oplist.txt', 'r')
l = f.readlines()
for line in l:
if not ((line[0] == '#') or line[0] == '\n' or line[0] == '\r'):
oplist.append(line.strip())
f.close()
f = open('blocklist.txt', 'r')
l = f.readlines()
for line in l:
if not ((line[0] == '#') or line[0] == '\n' or line[0] == '\r'):
blocklist.append(line.strip())
f.close()
#Give num blocks to a player
def givenum(proc, player, item, num):
try:
if (player not in oplist) and (int(num) > limit):
proc.stdin.write('say Non OPs can only make ' + str(limit) + ' at a time!\n')
num = str(limit)
if (player in oplist) or (item in blocklist):
for i in range(int(num)):
proc.stdin.write('give %s %s\n' % (player, item))
time.sleep(0.1)
else:
proc.stdin.write('say You do not have permission to place this block!\n')
except Exception:
proc.stdin.write('say That is not a valid number!\n')
def kick(proc, player, target):
if(player not in oplist):
proc.stdin.write('say You do not have permission to use the kick command!\n')
else:
proc.stdin.write('kick ' + target + '\n')
#Watch and interface with the server
while(p.poll() == None):
log = p.stderr.readline()
words = log.split()
# Our givenum command
if('!#' in words):
i = words.index('!#')
if(len(words) < (i+3)):
p.stdin.write('say ERROR: Usage is !# num item\n')
time.sleep(0.1)
p.stderr.readline()
else:
player = words[i-1].strip('<>')
num = words[i+1]
item = words[i+2]
givenum(p, player, item, num)
if('!kick' in words):
i = words.index('!kick')
if(len(words) < (i + 2)):
p.stdin.write('say ERROR: Usage is !kick player\n')
time.sleep(0.1)
p.stderr.readline()
else:
player = words[i-1].strip('<>')
target = words[i+1]
kick(p, player, target)
print log.strip()
time.sleep(0.1)
print 'Server shutdown complete!'
Thanks for this, after many problems in the other thread I think I fixed it, I now have 3.1,2.7and 2.6.5 installed. This wont cause any problems at all :biggrin.gif:
Ok, thank you. Was wondering because only time ive used python was with a counter-strike source server. Will test this in about 30 minutes, then I'll post if it works for me!
Nyko what we could do in-game now is have some 1 with access to all the items and deny just about every thing bar the basics to normal players and the normal players can collect the iron squares and go to the admin to exchange them for bars etc other wise every 1 will be running around with all the tools and that kinda ruins the fun and point of mining.
Here's a new python script that allows your SMP server to have OPs, use the !kick command, and the !# command (to allow a player to give themselves items!)
You can add OPs to your server by adding their names to the oplist.txt file. As well, you can add a list of blocks that non-ops can give themselves into the blocklist.txt file.
Further instructions are located in README.txt
This is the latest release and fixes a major security hole, in addition to a few small bugfixes and MAXPLAYERS YAY:
http://www.mediafire.com/?gh119ougdri735m
Have fun,
Koufu
Nyko's server thread | Nyko's gaming blog
Here's the code if you are interested:
viewtopic.php?f=1012&t=22916
[simg]http://img850.imageshack.us/img850/4148/mysigv2.png[/simg]
Nyko's server thread | Nyko's gaming blog
EDIT: Good luck with the script, Nyko! If you have any issues, just PM me or post.
Nyko's server thread | Nyko's gaming blog
Just an idea for now.
That is a good idea.
Nyko's server thread | Nyko's gaming blog
It is incompatible with python 3 BTW. :tongue.gif:
It /should/ work anywhere afaik, as I didn't use platform dependent stuff.
Nice setup with the multiple pythons XD, just make sure the right one runs :wink.gif:
Nyko's server thread | Nyko's gaming blog
Nyko's server thread | Nyko's gaming blog
I should so make a fire fighter skin lolz
Do I need to install python for this? If so is 2.7 compatible?
Nyko's server thread | Nyko's gaming blog