Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
per-arena commands?

 
Post new topic   Reply to topic Printable version
 View previous topic  How to get ball XY in python? Post :: Post Misc ASSS Questions  View next topic  
Author Message
Guest



Offline

PostPosted: Sat May 05, 2012 12:22 pm    Post subject: per-arena commands? Reply to topic Reply with quote

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

PostPosted: Sat May 05, 2012 2:32 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
Guest



Offline

PostPosted: Sat May 05, 2012 4:40 pm    Post subject: Reply to topic Reply with quote

The callbacks work as expected per-arena:

Example CB_PLAYERACTION: Works only when a player enter or exit THAT arena.
Code: Show/Hide

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:
Code: Show/Hide

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

PostPosted: Sat May 05, 2012 10:10 pm    Post subject: Reply to topic Reply with quote

not very good with py, but if it calls that function name, just name the function differently
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
Guest



Offline

PostPosted: Sat May 05, 2012 11:05 pm    Post subject: Reply to topic Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> ASSS Questions All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 696 page(s) served in previous 5 minutes.

phpBB Created this page in 0.442073 seconds : 30 queries executed (93.8%): GZIP compression disabled