Server Help

ASSS Custom Projects - <py> autoprize

Smong - Thu Sep 30, 2004 5:04 pm
Post subject: <py> autoprize
This module will prize the whole arena a certain amount of the same prize at regular intervals.

Since the python modules don't have an equivalent functions to load/unload you may see errors where stuff hasn't been initialised or cleaned up properly. Also I'm not sure if I should be using eval() to convert strings to ints but I couldn't get atoi() or num() to work.

Edit: removed old code.
Grelminar - Fri Oct 01, 2004 2:11 am
Post subject:
Cool. Here are my suggestions:

You don't need to "return 1" from your timer event; the default (no return) is to continue. You can if it makes you feel better, though.

I would get rid of the ap_status field and just use the presence of the timer handle to determine if you're on or off for an arena.

You can write "if m:" instead of "if m != None:"

Use "int(s)" instead of eval to turn strings into integers. Using eval is dangerous: if you're not extremely careful, someone might be able to get you to run code that they typed as part of the command. Better to avoid eval entirely.

Note that int will raise an exception if the string can't be converted into an integer. You can handle it if you want, or if you don't, asss will handle it and log an error. In the case of user input, it's probably better to handle it yourself.

It's probably overkill for this example, but you could look into using the getopt or optparse libraries to handle options. You can get a list of words to pass to one of those with "params.split()".
Smong - Tue May 22, 2007 6:52 am
Post subject:
Update
More robust loading (can be loaded after arena has been created)
Added support for named prizes (got fed up of finding the numbers)
Added ?ap command (got tired of typing out ?autoprize)

Plus all that stuff in Grelminar's post has been fixed long ago if anyone is wondering.
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group