PDA

View Full Version : IGA Script --> modmanager format


Lemming
6th September 2007, 20:15
Hi,

maybe someone could help with getting an ingame admin script into the modmanager format? :(

Already posted in another forum:
bfeditor.org/forums/index.php?showtopic=10409

For some reasons, I can't use the bf2cc daemon. This IGA script is working...the only problem is that I need it in modmanager form. So maybe...if someone has time?

Boffykins
6th September 2007, 20:20
Lemming, if you drop into #mpukhosting on Quakenet I'll be happy to walk you through it.

K
6th September 2007, 22:01
Is this a multiplay server? If so there is already an official IGA script installed.

Boffykins
7th September 2007, 07:29
I've sorted him already Steve ;)

Lemming
7th September 2007, 22:13
I've sorted him already Steve ;)


Just want to ask before I come again to IRC...
My module is now loaded and it is "answering" ingame if I type in a wrong command. (e.g. "!blabla" = Error, command not found). But if I'm using a command that is existing it is not reacting. Must be a problem with modmanager because the "normal" (not mm) version is working.

This is from the not mm version (debug):

2007-09-05 22:27:23 - dc_ass: the first character of !k was !
2007-09-05 22:27:23 - dc_ass: command = k
2007-09-05 22:27:23 - dc_ass: no parameter given
2007-09-05 22:27:23 - dc_ass: Command found in INI file!
2007-09-05 22:27:23 - dc_ass: type: kick
2007-09-05 22:27:23 - dc_ass: Attempting to authenticate keyhash: a15c52a82dd42424a7235c6069591556
2007-09-05 22:27:23 - dc_ass: a15c52a82dd42424a7235c6069591556 is level 10 in power.dat!
2007-09-05 22:27:23 - dc_ass: No parameter given... assigning victim_id to issuer.
2007-09-05 22:27:23 - dc_ass: now tracking player: 0
2007-09-05 22:27:23 - dc_ass: applied 10 points from a15c52a82dd42424a7235c6069591556 to player 0
2007-09-05 22:27:23 - dc_ass: Lemming now has 10 of 10 kick points
2007-09-05 22:27:23 - dc_ass: player -1: dc_ass: Lemming now has 10 of 10 kick points
2007-09-05 22:27:23 - dc_ass: Kicking player 'Lemming' (0) for firing from a vehicle in/into an uncapturable spawn
2007-09-05 22:27:23 - dc_ass: player -1: dc_ass: Kicking player 'Lemming' (0) for firing from a vehicle in/into an uncapturable spawn
2007-09-05 22:27:23 - dc_ass: player 0 disconnected and no longer tracked


And this from the mm version:

2007-09-07 01:09:59 - dc_ass: the first character of !k was !
2007-09-07 01:09:59 - dc_ass: command = k
2007-09-07 01:09:59 - dc_ass: no parameter given
2007-09-07 01:09:59 - dc_ass: Command found in INI file!
2007-09-07 01:09:59 - dc_ass: type: kick
2007-09-07 01:10:02 - dc_ass: the first character of !j was !
2007-09-07 01:10:02 - dc_ass: command = j
2007-09-07 01:10:02 - dc_ass: no parameter given
2007-09-07 01:10:02 - dc_ass: (ERROR) j command not found!
2007-09-07 01:10:02 - dc_ass: player -1: dc_ass: (ERROR) j command not found!
2007-09-07 01:10:09 - dc_ass: the first character of !keyhash was !
2007-09-07 01:10:09 - dc_ass: command = keyhash
2007-09-07 01:10:09 - dc_ass: no parameter given
2007-09-07 01:10:09 - dc_ass: Command found in INI file!
2007-09-07 01:10:09 - dc_ass: type: extension

Lemming
15th November 2007, 21:38
I just can not find the bug... :(: The script answers me...but don't do any actions (kicking, banning). It's stopping when it should read the admin keyhash.
Maybe someone could test it?

This is the non-mm version:

lemmingweb.de/bf2/1orig_dc_ass.txt

And this the MM version:
lemmingweb.de/bf2/dc_ass.txt

That's crazy...there is no difference in the code, but it don't works...
Is there a problem with modmanager...maybe with opening the power.dat ?

cal361
19th November 2007, 16:36
Hey lemming, I've been floating across the Internet posting in various forums trying to get your attention. I'd like to help you with this project as I am doing similar work. Do me a favor and post the dc_debug.py so I can help you.

Lemming
19th November 2007, 20:16
Hey lemming, I've been floating across the Internet posting in various forums trying to get your attention. I'd like to help you with this project as I am doing similar work. Do me a favor and post the dc_debug.py so I can help you.

:v No problem...here it is:
"""
DontCamp.com Common Debugging Function
written by: butter@dontcamp.com
Revision: $Revision: 1.11 $

Purpose:
To provide a central way for all DontCamp BF2 python code to output
debugging and informational text.

Setup: (defaults should work well)

1. Create a admin/standard_admin/dc_debug.level file and put the debug
level you want in the first character of the first line of said file.
Valid levels are 1-5.
2. Set log_to_file to either False or True if you want a seperate dc_debug
log file for all DontCamp BF2 python code debug output.
3. Set log_filename to whatever filename and path you like (relative to
your BF2 home directory). This is only necessary if log_to_file is set
to True.
4. Set log_to_stdout to either True or False if you want dc_debug to send
out its output to the python stdout interface. This is useful if you
are using BF2CC and want dc_debug's output in the pythonlog.txt file.
"""

import host
import time

try:
debug_level_fh = open('admin/standard_admin/dc_debug.level', 'r')
debug_level = int(debug_level_fh.read(1))
debug_level_fh.close()

except:
debug_level = 5

log_to_file = True
log_filename = 'IGA.log'
log_to_stdout = False

def decho(msg, level = 1):
# 1 = info w/ in-game feedback
# 2 = info
# 5 = debug

if debug_level > 0 and debug_level >= level:
string = time.strftime('%Y-%m-%d %H:%M:%S') + ' - ' + msg

if log_to_stdout:
print string

if log_to_file:
fh = open(log_filename, 'a')
fh.write(string + '\n')
fh.close()

if level == 1:
host.rcon_invoke('game.sayall "%s"' % msg)

def showLevel():
decho('dc_debug: The current debug level is %d' % debug_level, 2)

As you can see in the code, you need a dc_debug.level in bf2\admin\standard_admin ... In this file just write a "5" for full debug modus.

And this is the dc_ass_extensions.py:


import bf2
import host
from dc_debug import decho

def sayNextMap(unused=None):
#It works. We'll just leave it at that.
decho('The next map is %s' % (host.rcon_invoke('maplist.list').splitlines()[int(host.rcon_invoke('admin.nextLevel').strip())].split()[1].strip('"').replace('_', ' ').title()), 1)

def getMyKeyhash(admin):
decho( "dc_ass: %s, your keyhash is %s" % (bf2.PlayerManager.Player(admin.issuer).getName(), admin.keyhash), 1 )

def privGetMyKeyhash(admin):
host.rcon_feedback( admin.issuer, "%s, your keyhash is %s" % (bf2.PlayerManager.Player(admin.issuer).getName(), admin.keyhash) )
decho( "dc_ass: Check your console for the keyhash", 1 )

def getStatus(admin):
# this will be different when I put the issuer in the object
for v_id in admin.victim_id:

if admin.victim_tracker.has_key(v_id):
total_points = 0
for unused_key, points in admin.victim_tracker[v_id].iteritems():
total_points += points
decho( "dc_ass: %s has %d of 10 kick points" % (bf2.PlayerManager.Player(v_id).getName(), total_points), 1 )

else:
decho( "dc_ass: %s has 0 of 10 kick points" % bf2.PlayerManager.Player(v_id).getName(), 1 )

def getMyStatus(admin):
if admin.victim_tracker.has_key(admin.issuer):
total_points = 0
for unused_key, points in admin.victim_tracker[admin.issuer].iteritems():
total_points += points
decho( "dc_ass: %s has %d of 10 kick points" % (bf2.PlayerManager.Player(admin.issuer).getName(), total_points), 1 )

else:
decho( "dc_ass: %s has 0 of 10 kick points" % bf2.PlayerManager.Player(admin.issuer).getName(), 1 )

def clearPoints(admin):
for v_id in admin.victim_id:

if admin.victim_tracker.has_key(v_id):
admin.victim_tracker.pop(v_id)

# I figure I can say their all cleared even if we're not tracking them... yet
decho( "dc_ass: Points for %s have been cleared" % bf2.PlayerManager.Player(v_id).getName(), 1 )

cal361
19th November 2007, 22:06
Thanks. Get me some messenger info and we can probably hash through this.