Server Help

ASSS Questions - Silencing ip address

BDwinsAlt - Sun Nov 19, 2006 5:43 pm
Post subject: Silencing ip address
I am trying to silence by IP address using a python module. There are a few things I need to do in order to do this.

Get the player's ip when they enter the zone

Query the database for that ip and check the column 'banlength'

Compar that time to the current time to decide if they are still silenced.

Apply a new silence for the remaining time.

Any help would make me really happy. I'm working on it now. If I figure it out I will edit my post.
Smong - Sun Nov 19, 2006 6:00 pm
Post subject:
You'd want two columns, startedat and length. Then when the player enters the server you see if now - startedat < length, if so then you adjust the chatmask for length - (now - startedat) seconds.

You could probably push most of it to the db:
Code: Show/Hide
select length - (now() - startedat) from blah
where now() - startedat < length and ip = 'blah'
Then check to see if there is more than 0 rows of results.
BDwinsAlt - Sun Nov 19, 2006 6:25 pm
Post subject:
How do I query the db and see if the ip entering matches a row with an ip that has a banlength on it? I need to know how to Query the database before I begin any of it.
Smong - Mon Nov 20, 2006 4:46 am
Post subject:
Just look at the alias module.
BDwinsAlt - Mon Nov 20, 2006 5:04 pm
Post subject:
New problem: I looked at setcm in playercmd.c but chat.SetPlayerChatMask doesn't seem to silence people. Could you help me out with this?
Smong - Tue Nov 21, 2006 5:38 pm
Post subject:
Post your code.
BDwinsAlt - Tue Nov 21, 2006 6:25 pm
Post subject:
Code: Show/Hide

def c_silence(cmd, params, p, targ):
    if int(params) >= 1:
        chat.SetPlayerChatMask(targ, 1, int(params))


getcm shows all permissions, even if I change the int value.
Smong - Tue Nov 21, 2006 6:39 pm
Post subject:
Ok this works for me:
Code: Show/Hide
from asss import *

chat = get_interface(I_CHAT)

def c_silence(cmd, params, p, targ):
   # get integer parameter
   timeout = 0
   try: timeout = int(params)
   except: pass

   # check for priv command
   if isinstance(targ, PlayerType) and timeout >= 1:
      newmask = 1 << MSG_CHAT
      chat.SetPlayerChatMask(targ, newmask, timeout)

cmd1 = add_command("t1", c_silence)

Silencing chat channels for 60 seconds:
Code: Show/Hide
     Smong> ?getcm
getcm: +pub +pubmacro +freq +nmefreq +priv +chat +modchat
     Smong> ?t1 60
     Smong> ?getcm
getcm: +pub +pubmacro +freq +nmefreq +priv -chat +modchat

BDwinsAlt - Tue Nov 21, 2006 7:39 pm
Post subject:
thanks icon_smile.gif
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group