Server Help

ASSS Questions - Reloading temp setts with python.

BDwinsAlt - Mon Sep 04, 2006 6:22 pm
Post subject: Reloading temp setts with python.
I did read the post about doors for C. How would I go about updating the door mode instantly if someone types a command. Right now you have to wait a few seconds for the doors to open and close. I need to be able to set the door mode and reload the door state.

How can I do this in python?

ALSO, how can I take away a death from someone's score in python if they get tked.
Chambahs - Mon Sep 04, 2006 10:19 pm
Post subject:
Dont know about the doors but i know that for the win/death count in python, its:

GetStat(p, STAT_WINS, INTERVAL_RESET)
SetStat(p, STAT_WINS, INTERVAL_RESET)

Or:

GetStat(p, STAT_LOSSES, INTERVAL_RESET)
SetStat(p, STAT_LOSSES, INTERVAL_RESET)

And then:

stats.SendUpdates()


All found in asss/src/include/stats.h and also asss/src/packets/pdata.h

Preview for code for you or anyone else:

Code: Show/Hide

def get_money(p):
    kp = stats.GetStat(p, STAT_KILL_POINTS, INTERVAL_RESET)
    fp = stats.GetStat(p, STAT_FLAG_POINTS, INTERVAL_RESET)
    return kp + fp

def subtract_money(p, amount):
    if amount > 0:
        fp = stats.GetStat(p, STAT_FLAG_POINTS, INTERVAL_RESET)
        fp -= amount
        stats.SetStat(p, STAT_FLAG_POINTS, INTERVAL_RESET, fp)
        stats.SendUpdates()

def c_buy(cmd, params, p, targ):
    # spec can't buy
    if len(params) > 0 and p.ship == SHIP_SPEC:
        chat.SendMessage(p, "Sorry, you cannot buy from spec.")
        return

    money = get_money(p)

    if params == "nades":
        if money >= 100000:
            subtract_money(p, 100000)
       do_nades(p)


BDwinsAlt - Mon Sep 04, 2006 11:29 pm
Post subject:
Thanks man. I will try it out tomarrow I have to go to bed now. Thanks again :-D

EDIT: I got it working but with code a little different.
Your example helped me a lot. One thing though, STAT_WIN is STAT_KILLS and STAT_LOSSES is STAT_DEATHS. Just a note to anyone who wants to do this.

Thanks guys :)


Now if we could figure out the other issue :P
Smong - Tue Sep 05, 2006 4:50 pm
Post subject:
Looking at clientset.h it doesn't have any python hooks in it. But a workaround is to use asss.call_callback(CB_ARENAACTION, (arena, AA_CONFCHANGED)) and that should make the clientset module resend the settings. I haven't tested this so it's only hypothetical.
Anonymous - Wed Sep 06, 2006 4:42 pm
Post subject:
Can you ellaberate? I am having this same problem as well. An example would be nice. I'm pretty new to asss myself.
Smong - Wed Sep 06, 2006 4:55 pm
Post subject:
Still not tested but this is what it might look like.
Code: Show/Hide
import * from asss

cfg = get_interface(I_CONFIG)

def set_doormode(arena, newdoormode):
    cfg.SetInt(arena.cfg, "Door", "DoorMode", newdoormode, "", false)
    call_callback(CB_ARENAACTION, (arena, AA_CONFCHANGED))

def mm_attach(a):
    set_doormode(a, 127)

def mm_detach(a):
    set_doormode(a, -2)

BDwinsAlt - Wed Sep 06, 2006 6:35 pm
Post subject:
HEY! This worked for me! Thanks very much. Tunkel is my buddy in real life and he was trying to help me too. Thanks.
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group