 |
Server Help Community forums for Subgame, ASSS, and bots
|
Author |
Message |
Guest
Offline
|
Posted: Sat May 05, 2012 12:22 pm Post subject: per-arena commands? |
 |
|
|
|
per-arena commands?
When reusing modules/commands in more then one arena, the command itself is loaded into the arena, but its calling all modules in all arenas causing multiple returns to the player.
arena.stats_gamestats_cmd = \
asss.add_command("gamestats", \
gamestats, \
arena)
ex: stats module running in (public) and in mysubarena
?gamestats
team 0: 1000 - team 1: 2000
team 0: 1000 - team 1: 2000
Am I missing something? If not this kind of sucks cause I'd have to rewrite ever module/command, and do something like ?mypubstats, ?mysubarenastats etc. thats not very macro user freindly. |
|
Back to top |
|
 |
Cheese Wow Cheese is so helpful!

Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Sat May 05, 2012 2:32 pm Post subject: |
 |
|
|
|
try writing it so that it uses the arena passed while attaching
that way it will only work in an arena that you attached the module to _________________ SSC Distension Owner
SSCU Trench Wars Developer |
|
Back to top |
|
 |
Guest
Offline
|
Posted: Sat May 05, 2012 4:40 pm Post subject: |
 |
|
|
|
The callbacks work as expected per-arena:
Example CB_PLAYERACTION: Works only when a player enter or exit THAT arena.
arena.stats_PLAYERACTION_CB = \
asss.reg_callback(asss.CB_PLAYERACTION, \
store_stats, \
arena)
def store_stats(p, action, arena):
if action == asss.PA_ENTERARENA:
for item in arena.stats_saves:
if item['name'] == p.name:
p.stats = item
arena.stats_saves.remove(item)
chat.SendMessage(p, 'PA_ENTERARENA stats restored')
return
p.stats = {
'name' : p.name, \
'freq' : -1, \
'kills' : 0, \
'deaths' : 0, \
'tks' : 0, \
'touch' : 0, \
'kscore' : 0, \
'fscore' : 0, \
'bscore' : 0};
chat.SendMessage(p, 'PA_ENTERARENA stats renewed')
elif action == asss.PA_LEAVEARENA:
arena.stats_saves.append(p.stats)
chat.SendMessage(p, 'PA_LEAVEARENA stats saved')
|
But commands, and the arena is passed correctly, calls all gamestats() functions in all modules in all arenas.
Example:
arena.stats_gamestats_cmd = \
asss.add_command("gamestats", \
gamestats, \
arena)
def gamestats(cmd, params, p, arena):
chat.SendMessage(p, 'gamestats from this arena')
|
cmdman.h
* command handlers come in two flavors, which differ only in whether
* the handler gets to see the command name that was used. this can only
* make a difference if the same handler is used for multiple commands,
* of course. also, if you want to register per-arena commands, you need
* to use the second flavor. all handlers may assume p and p->arena are
* non-NULL.
I think im not understanding what the other flavor is or how to use it, or maybe im missing something right in front of my face.
Eye strain head hurts please help! |
|
Back to top |
|
 |
Cheese Wow Cheese is so helpful!

Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Sat May 05, 2012 10:10 pm Post subject: |
 |
|
|
|
not very good with py, but if it calls that function name, just name the function differently |
|
Back to top |
|
 |
Guest
Offline
|
Posted: Sat May 05, 2012 11:05 pm Post subject: |
 |
|
|
|
Thats doable, but defeats the purpose. To rename the function you need 2 modules stats_pub.py and stats_somesubarena.py. Then you have to edit the function names, and use prefix's for the commands aswell ?mypubstats, ?mysubarenastats etc.. And what if you want to setup something in the "default arena", how could you swing that?
I'm just curious if Im doing something wrong or if this is just how it is. |
|
Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
Software by php BB © php BB Group Server Load: 264 page(s) served in previous 5 minutes.
|