Server Help

ASSS Custom Projects - Help please

Chambahs - Fri Jan 06, 2006 12:25 am
Post subject: Help please
Ive gone through this module over and over again, and i cant seem to find what is wrong with it. I get no error messages, no nothing. The module just doesnt work. ?start1 does nothing and I really dont know why.


Code: Show/Hide

from asss import *

chat = get_interface(I_CHAT)
game = get_interface(I_GAME)

def count_playing(arena):
    players = [ 0 ]
    def cb_count(p):
        if p.arena == arena and p.ship < SHIP_SPEC:
             players[0] += 1
    for_each_player(cb_count)
    return players[0]

def kill(arena, killer, killed, bounty, flags, pts, green):
    # promote
    if killer.ship != SHIP_WARBIRD:
        game.SetShip(killer, killer.ship - 1)

    # check for game over
    elif killer.ship == SHIP_WARBIRD:
        arena.leader_killcb = None
        chat.SendArenaMessage(arena, "Game over. %s is the winner!" % killer.p.name)

    # demote
    if killed.ship != SHIP_SHARK:
        game.SetShip(killed, killed.ship + 1)

    return pts, green

def c_start_game(cmd, params, p, targ):
    """\
Module: <py> leader
Min. players: 2
Everyone starts as Shark, kill to get ship changed.
First to make a kill in a Warbird wins.
"""
    players = count_playing(p.arena)

    if players >= 2:
        def cb_setship(i):
            if i.arena == arena and i.ship < SHIP_SPEC:
                game.SetShip(i, SHIP_SHARK)
        for_each_player(cb_setship)

        chat.SendArenaMessage(p.arena, "The Game Has Started, Begin Killing To Get Promoted. If You Are Killed You Will Get Demoted.")
        game.LockArena(p.arena, 0, 0, 0, 0)
    else:
        chat.SendArenaMessage(p.arena, "Not enough players, %d more needed." % (2 - players))

cmd1 = add_command("startl", c_start_game)

def mm_attach(arena):
    arena.leader_killcb = reg_callback(CB_KILL, kill, arena)

def mm_detach(arena):
    arena.leader_killcb = None
    arena.leader_cmd1 = None


Muskrat - Fri Jan 06, 2006 12:41 am
Post subject:
Sure you put the command in the groupdef files? It looks like it should at least be doing something.
Chambahs - Fri Jan 06, 2006 12:47 am
Post subject:
everything is done in the confs, i attached, i did everything, all that good stuff lol
Grelminar - Fri Jan 06, 2006 3:12 am
Post subject:
Something is a little confused. You probably meant to do add the command like this:
Code: Show/Hide
def mm_attach(arena):
    arena.leader_cmd1 = add_command("start1", c_start_game, arena)


So that the command is only defined for arenas where this is attached, and then register the callback in c_start_game.

Besides that, I don't see anything wrong.
Chambahs - Fri Jan 06, 2006 3:18 pm
Post subject:
Thanks grel, although there were some p's places there should be and other tiny things. But on the way of fixing the module i realized there are great bugs. Like when your in game you can spec and the game will keep going. Another is you can ?startgame over and over. I tried to fix a number of these but they failed once again. Here is the new working but still buggy leader module.

Code: Show/Hide

#Leader by Chambahs
#12-16-05
#dec 29 2005 smong
#Chambahs jan 06, bugs and ect.

from asss import *

chat = get_interface(I_CHAT)
game = get_interface(I_GAME)

def count_playing(arena):
    players = [ 0 ]
    def cb_count(p):
        if p.arena == arena and p.ship < SHIP_SPEC:
             players[0] += 1
    for_each_player(cb_count)
    return players[0]

def c_start_game(cmd, params, p, targ):
    """\
Module: <py> leader
Min. players: 2
Everyone starts as Shark, kill to get ship changed.
First to make a kill in a Warbird wins.
"""
    players = count_playing(p.arena)

    if players >= 2:
        def cb_setship(i):
            if i.arena == p.arena and i.ship < SHIP_SPEC:
                game.SetShip(i, SHIP_SHARK)
        for_each_player(cb_setship)

        chat.SendArenaMessage(p.arena, "The Leader Game Has Started By: " + p.name + ", Begin Killing To Get Promoted. If You Are Killed You Will Get Demoted.")
        game.LockArena(p.arena, 0, 0, 0, 0)
    else:
        chat.SendArenaMessage(p.arena, "Not Enough Players, %d More Needed." % (2 - players))

def kill(arena, killer, killed, bounty, flags, pts, green):
    # promote
    if killer.ship != SHIP_WARBIRD:
        game.SetShip(killer, killer.ship - 1)

    # check for game over
    players = count_playing(arena)

    if players < 2:
        arena.leader_killcb = None
        chat.SendArenaMessage(arena, "Game over. %s is the winner!" % killer.name)

    elif killer.ship == SHIP_WARBIRD:
        arena.leader_killcb = None
        chat.SendArenaMessage(arena, "Game over. %s is the winner!" % killer.name)
       
    # demote
    if killed.ship != SHIP_SHARK:
        game.SetShip(killed, killed.ship + 1)

    return pts, green

def mm_attach(arena):
    arena.leader_killcb = reg_callback(CB_KILL, kill, arena)
    arena.leader_cmd1 = add_command("startgame", c_start_game, arena)
    arena.leader_cmd2 = add_command("stopgame", do_game_over, arena)
   
def mm_detach(arena):
    arena.leader_killcb = None
    arena.leader_cmd1 = None
    arena.leader_cmd2 = None


Whoever wants to help work on it, be my guest.
Cyan~Fire - Fri Jan 06, 2006 3:51 pm
Post subject:
You want us to locate your bugs for you?
D1st0rt - Fri Jan 06, 2006 3:58 pm
Post subject:
You haven't been on the bot chat very much have you, Cyan?
Chambahs - Fri Jan 06, 2006 4:23 pm
Post subject:
LIES, i know what my bugs are, i said specifically:

"Whoever wants to help work on it, be my guest."

i didnt say: "I dont know whats wrong can you please find my bugs for me"

I stated the bugs and said this is whats wrong with the module, if you want it...take it, if you dont, then dont mind this thread. So -READ- before you -POST- thank you very much.
Cyan~Fire - Fri Jan 06, 2006 10:53 pm
Post subject:
Never, as far as I know, d1s.
Smong - Mon Jan 09, 2006 4:17 am
Post subject:
I don't see a do_game_over function, you should try and write one.
Chambahs - Mon Jan 09, 2006 10:08 am
Post subject:
i did smong, its just it didnt work and looked crappy so i deleted it
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group