thankyou
Donate to the B3 fund!

"even a small donation helps!"
Donate with PayPal!
Most of the plugins here are made by B3 users and the authors may not visit frequently. If you need support for plugins or if questions remain unanswered, you will have to contact the author directly. Read the full Support Disclaimer here

NOTE: Do not attach plugins to your forumtopics! Attachements are periodically removed by maintenance tasks. Upload your plugins to our Downloads section instead!

Author Topic: CoD4 Mute  (Read 11684 times)

Offline Spoon

  • Moderator
  • Sr. Member
  • *
  • Posts: 255
    • EHD Gaming
CoD4 Mute
« on: August 18, 2010, 12:30:40 AM »
I guess i never really made a release for this no maybe people dont know about it.

Description: When muted B3 will warn the player untill they are auto kicked.
Players are automatically unmuted on map change or player reconnection.

Command: !mute <name> <on/off>

Big thanks to Bakes for pointing me in the right direction and for helping with the code.

Download:
http://www.bigbrotherbot.net/forums/downloads/?sa=view;down=78
http://ehdfiles.co.uk/spoon/plugin_mute.rar

Offline medrado

  • Newbie
  • *
  • Posts: 1
Re: CoD4 Mute
« Reply #1 on: May 07, 2011, 04:41:25 PM »
« Last Edit: May 07, 2011, 04:43:31 PM by medrado »

Offline MordyT

  • Support Hero
  • Hero Member
  • *
  • Posts: 3644
  • Over $300 Donated to B3!
    • MordyT
Re: CoD4 Mute
« Reply #2 on: May 09, 2011, 02:55:55 AM »
Hmm.. do they get warned every time they chat? Or just warned in general?
Help will be given to those with a b3.log

If drop off the map it is due to RL becoming busy :)

System: Python 2.7.3 - Deb 7 - B3 Source Code - 128MB RAM box (rented at $5 a year) - remote MySQL - Remote Web Services

Offline Nocturnal1982

  • Full Member
  • ***
  • Posts: 111
    • Bandit Company
Re: CoD4 Mute
« Reply #3 on: August 16, 2011, 01:23:27 AM »
They will just get warned with whatever reason that you defined. Which in turn will make them get kicked or tempbanned once the limit in your admin.xml file has been reached.

Mute wears off on disconneting/rejoining the server + mapchange

Offline MordyT

  • Support Hero
  • Hero Member
  • *
  • Posts: 3644
  • Over $300 Donated to B3!
    • MordyT
Re: CoD4 Mute
« Reply #4 on: September 19, 2011, 11:59:11 PM »
Excellent plugin, is there a way to modify it so...

1) mute is persistent?
2) The don't get warned, what happens is a admin does !mute name on and name get a message "You are now muted, don't talk" and if he talks, instant kick? If he rejoins and talks, instant kick. until a admin does !mute name off
Help will be given to those with a b3.log

If drop off the map it is due to RL becoming busy :)

System: Python 2.7.3 - Deb 7 - B3 Source Code - 128MB RAM box (rented at $5 a year) - remote MySQL - Remote Web Services

Offline Spoon

  • Moderator
  • Sr. Member
  • *
  • Posts: 255
    • EHD Gaming
Re: CoD4 Mute
« Reply #5 on: September 20, 2011, 01:04:21 PM »
Code: [Select]
#Set the command level on line 21. Should be fairly obvious.

__version__ = '1.1'
__author__  = 'Spoon'

from b3.querybuilder import QueryBuilder
import b3, thread, time, string, datetime
import b3, re, traceback, sys, threading ,MySQLdb
import b3.plugin
import b3.events
from b3 import clients
from b3 import functions
# Import the necessary libaries you need here, for example, I need random for the randomization of answers part of it.
import random
#--------------------------------------------------------------------------------------------------
#This lot doesn't need to be changed for simple commands, it gets the admin plugin and registers commands.
class MutePlugin(b3.plugin.Plugin):
    _adminPlugin = None
    action = 'warn'

    def onStartup(self):  
        self._adminPlugin = self.console.getPlugin('admin')  
        if not self._adminPlugin:  
            return False  
        #SET COMMAND LEVEL HERE
        self._adminPlugin.registerCommand(self, 'mute', 100, self.cmd_mute)
        self._adminPlugin.registerCommand(self, 'unmute', 100, self.cmd_unmute)
        self.registerEvent(b3.events.EVT_CLIENT_SAY)  
        self.registerEvent(b3.events.EVT_CLIENT_TEAM_SAY)  
        self.registerEvent(b3.events.EVT_CLIENT_AUTH)  
  
    def onEvent(self, event):  
        if event.type == b3.events.EVT_CLIENT_AUTH:
            self.getmute(event.client)  
            #event.client.setvar(self, 'muted', 0)
        elif event.type == b3.events.EVT_CLIENT_SAY or event.type == b3.events.EVT_CLIENT_TEAM_SAY:  
            if event.client.var(self, 'muted', 0).value == 1:
                action = self.config.get('settings', 'action')
                if action == 'kick':
                    event.client.kick('You are not allowed to talk')
                elif action == 'warn':
                    self._adminPlugin.warnClient(event.client, 'You are not allowed to talk', None, False, '', 1)
                else:
                    self._adminPlugin.warnClient(event.client, 'You are not allowed to talk', None, False, '', 1)    
            else:  
                return False

    def getmute(self, client):
        cursor = self.console.storage.query("""
        SELECT id, client_id, inactive, time_expire
        FROM penalties
        WHERE client_id = '%s' AND type = 'mute'
        ORDER BY id DESC LIMIT 1
        """ % (client.id))

        r = cursor.getRow()

        if cursor.rowcount > 0:
            self.debug('Mute Found')
            if r['inactive'] == 0:
                #if (int(time.time())) < r['time_expire']:
                if r['time_expire'] > self.console.time():
                    client.var(self, 'muted', 0).value = 1
                    client.message('^3You are now muted, shut up!')
                    self.console.say('%s has been muted' % client.exactName)
                else:
                    self.debug('Mute has expired')
                    client.var(self, 'muted', 0).value = 0
            else:
                self.debug('Mute has been deactived')
                client.var(self, 'muted', 0).value = 0
                return False
        else:
            self.debug('Player has never been muted')
            client.var(self, 'muted', 0).value = 0
            return False
        cursor.close()

    def cmd_mute(self, data, client=None, cmd=None):
        """\
        <player> <duration> [<reason>] - mute a player
        """
        m = data.split(' ',3)

        if not m[0]:
            client.message('^7Invalid parameters, you must supply a player name')
            return False

        if not m[1]:
            client.message('^7Invalid parameters, you must supply a duration')
            return False

        if not m[2]:
            client.message('^7Invalid parameters, you must supply a reason')
            return False

        sclient = self._adminPlugin.findClientPrompt(m[0], client)
        mins = int(m[1])
        reason = m[2]
        timeadd = (int(time.time()))
        timeend = (int(time.time()) + (mins*60))

        if sclient:
            if sclient.cid == client.cid:
                client.message('You cant mute yourself')
                return True
            elif sclient.maxLevel >= client.maxLevel:
                if sclient.maskGroup:
                    client.message('^7%s ^7is a masked higher level player, can\'t mute ' % client.exactName)
                else:
                    client.message('You cant mute %s' % (sclient.exactName))
                return True
            else:
                cursor = self.console.storage.query("""
                    INSERT INTO penalties ( type, client_id, admin_id, duration, inactive, reason, time_add, time_edit, time_expire )
                    VALUES ('mute', '%s', '%s', '%s', '0', '%s', '%s', '%s', '%s')
                    """ % (sclient.id, client.id, mins, reason, timeadd, timeadd, timeend)) #Have to escape quotes (')
                self.getmute(sclient)
                return True
        else:
            return False

    def cmd_unmute(self, data, client=None, cmd=None):
        """\
        <player> - unmutes a player
        """
        m = self._adminPlugin.parseUserCmd(data)
        if not m:
            client.message('^7Invalid parameters')
            return False

        sclient = self._adminPlugin.findClientPrompt(m[0], client)
        if sclient:
            cursor = self.console.storage.query("""
            SELECT id, client_id, inactive, time_expire
            FROM penalties
            WHERE client_id = '%s' AND type = 'mute'
            ORDER BY id DESC LIMIT 1
            """ % (sclient.id))

            r = cursor.getRow()

            if cursor.rowcount > 0:
                id = r['id']
        
                cursor = self.console.storage.query("""
                    UPDATE penalties
                    SET inactive = '%s'
                    WHERE id = '%s'
                    """ % (1, id))
                self.getmute(sclient)
            else:
                client.message('This user is not muted')
        else:
             return False
Code: [Select]
<configuration plugin="mute">
   <settings name="commands">
      <set name="mute">20</set>
      <set name="unmute">20</set>
   </settings>
   <settings name="settings">
      <set name="action">warn</set>
   </settings>
</configuration>

EDIT: You will have to edit your penalties table to allow mute as a type.
« Last Edit: September 20, 2011, 01:28:23 PM by Spoon »

Offline MordyT

  • Support Hero
  • Hero Member
  • *
  • Posts: 3644
  • Over $300 Donated to B3!
    • MordyT
Re: CoD4 Mute
« Reply #6 on: September 20, 2011, 04:17:08 PM »
Thanks Spoon. One question: is the .xml needed? Isn't the command level set in the .py?
Help will be given to those with a b3.log

If drop off the map it is due to RL becoming busy :)

System: Python 2.7.3 - Deb 7 - B3 Source Code - 128MB RAM box (rented at $5 a year) - remote MySQL - Remote Web Services

Offline Spoon

  • Moderator
  • Sr. Member
  • *
  • Posts: 255
    • EHD Gaming
Re: CoD4 Mute
« Reply #7 on: September 20, 2011, 05:18:37 PM »
it will be needed for the action setting

Offline MordyT

  • Support Hero
  • Hero Member
  • *
  • Posts: 3644
  • Over $300 Donated to B3!
    • MordyT
Re: CoD4 Mute
« Reply #8 on: September 20, 2011, 05:47:00 PM »
EDIT: You will have to edit your penalties table to allow mute as a type.
I assume you mean like what I did in the screenshot below?

EDIT: Does it matter if it is Mute or mute (see uppercase letter)

it will be needed for the action setting
Ah, thanks.

[attachment deleted by maintenance]
« Last Edit: September 20, 2011, 05:48:35 PM by MordyT »
Help will be given to those with a b3.log

If drop off the map it is due to RL becoming busy :)

System: Python 2.7.3 - Deb 7 - B3 Source Code - 128MB RAM box (rented at $5 a year) - remote MySQL - Remote Web Services

Offline Spoon

  • Moderator
  • Sr. Member
  • *
  • Posts: 255
    • EHD Gaming
Re: CoD4 Mute
« Reply #9 on: September 20, 2011, 07:26:25 PM »
yea your ss is rite idk if it matters about being uppercase but i made it a cap M for mine

Offline MordyT

  • Support Hero
  • Hero Member
  • *
  • Posts: 3644
  • Over $300 Donated to B3!
    • MordyT
Re: CoD4 Mute
« Reply #10 on: September 20, 2011, 07:27:04 PM »
Thanks! I appreciate all your help!
Help will be given to those with a b3.log

If drop off the map it is due to RL becoming busy :)

System: Python 2.7.3 - Deb 7 - B3 Source Code - 128MB RAM box (rented at $5 a year) - remote MySQL - Remote Web Services

Offline MordyT

  • Support Hero
  • Hero Member
  • *
  • Posts: 3644
  • Over $300 Donated to B3!
    • MordyT
Re: CoD4 Mute
« Reply #11 on: September 23, 2011, 10:45:30 PM »
Hi spoon, I have a little issues...
I finally got to test the plugin, but it errors out... log snippet below.

Also attached is my mute.py and mute.xml for you to look over.

Code: [Select]
110924 00:13:45	VERBOSE	'XlrstatsPlugin: ----> XLRstats: Victim: oldsk: 764.879 - newsk: 764.302'
110924 00:13:45 VERBOS2 'Client Kill event handled by XlrstatsPlugin in 10.000 ms'
110924 00:13:45 VERBOSE 'Parsing Event: Client Kill: SpreePlugin'
110924 00:13:45 VERBOS2 'Client Kill event handled by SpreePlugin in 0.000 ms'
110924 00:13:46 CONSOLE '17076:08 say;3cd4813b4f3f48e0e5f818c7fc5933f4;0;Mordy;\x15!mute pat on'
110924 00:13:46 VERBOSE 'Queueing event Say !mute pat on'
110924 00:13:46 VERBOSE 'Parsing Event: Say: AdminPlugin'
110924 00:13:46 DEBUG 'AdminPlugin: OnSay handle 5:"!mute pat on"'
110924 00:13:46 DEBUG 'AdminPlugin: Handle command !mute pat on'
110924 00:13:46 VERBOSE "RCON sending (85.234.137.75:2304) 'tell 0 [^4R^1vO^4B^1ot^7]: ^3[pm]^7 ^7There was an error processing your command'"
110924 00:13:46 CONSOLE '17076:08 D;059dae8a30fbd51146e7a004f7b8454c;6;axis;senturion;24ffa7dc09515a16f1fab022081e10d2;5;allies;Ole;winchester1200_grip_mp;40;MOD_PISTOL_BULLET;torso_lower'
110924 00:13:46 VERBOS2 'Aborted Making Alias for cid: 5, name is the same'
110924 00:13:46 VERBOS2 'Aborted Making Alias for cid: 6, name is the same'
110924 00:13:46 VERBOSE "Queueing event Client Damage (40.0, 'winchester1200_grip_mp', 'torso_lower', 'MOD_PISTOL_BULLET')"
110924 00:13:46 ERROR "handler AdminPlugin could not handle event Say: IndexError: list index out of range [('/bot/b3/parser.py', 973, 'handleEvents', 'hfunc.parseEvent(event)'), ('/bot/b3/plugin.py', 158, 'parseEvent', 'self.onEvent(event)'), ('/bot/b3/plugin.py', 176, 'onEvent', 'self.handle(event)'), ('/bot/b3/plugins/admin.py', 223, 'handle', 'self.OnSay(event)'), ('/bot/b3/plugins/admin.py', 368, 'OnSay', 'results = command.execute(data, event.client)'), ('/bot/b3/plugins/admin.py', 2002, 'execute', 'self.func(data, client, copy.copy(self))'), ('/bot/b3/extpluginsKH/mute.py', 90, 'cmd_mute', 'if not m[2]:')]"
110924 00:13:46 VERBOS2 'Say event handled by AdminPlugin in 0.000 ms'
110924 00:13:46 VERBOSE 'Parsing Event: Say: ChatloggerPlugin'
110924 00:13:46 DEBUG 'ChatloggerPlugin: ALL, 2, Mordy, !mute pat on'
110924 00:13:46 DEBUG 'ChatloggerPlugin: writing to file'
110924 00:13:46 DEBUG 'ChatloggerPlugin: writing to database'
110924 00:13:46 DEBUG 'ChatloggerPlugin: rowcount: 1, id:37830'
110924 00:13:46 VERBOS2 'Say event handled by ChatloggerPlugin in 0.000 ms'
110924 00:13:46 VERBOSE 'Parsing Event: Say: TranslatorsPlugin'
110924 00:13:46 VERBOS2 'Say event handled by TranslatorsPlugin in 0.000 ms'
110924 00:13:46 VERBOSE 'Parsing Event: Say: MutePlugin'
110924 00:13:46 VERBOS2 'Say event handled by MutePlugin in 0.000 ms'
110924 00:13:46 VERBOSE 'Parsing Event: Say: ChatPlugin'
110924 00:13:46 VERBOS2 'Say event handled by ChatPlugin in 0.000 ms'
110924 00:13:46 VERBOSE 'Parsing Event: Client Damage: AntinoobPlugin'
110924 00:13:46 VERBOS2 'Client Damage event handled by AntinoobPlugin in 0.000 ms'
110924 00:13:46 VERBOSE 'Parsing Event: Client Damage: XlrstatsPlugin'
110924 00:13:46 VERBOSE 'XlrstatsPlugin: ---> XLRstats: Not enough damage done to award an assist'
110924 00:13:46 VERBOS2 'Client Damage event handled by XlrstatsPlugin in 0.000 ms'
110924 00:13:46 DEBUG 'formatting time with timezone [CST], tzOffset : -21600'
110924 00:13:46 DEBUG 'WelcomePlugin: LastVisit: 06:06AM CST 09/18/11'
110924 00:13:46 DEBUG 'formatting time with timezone [CST], tzOffset : -21600'
110924 00:13:47 VERBOS2 "RCON: Received ''"
110924 00:13:47 CONSOLE '17076:09 D;059dae8a30fbd51146e7a004f7b8454c;6;axis;senturion;24ffa7dc09515a16f1fab022081e10d2;5;allies;Ole;winchester1200_grip_mp;40;MOD_PISTOL_BULLET;torso_upper'

[attachment deleted by maintenance]
Help will be given to those with a b3.log

If drop off the map it is due to RL becoming busy :)

System: Python 2.7.3 - Deb 7 - B3 Source Code - 128MB RAM box (rented at $5 a year) - remote MySQL - Remote Web Services

Offline Spoon

  • Moderator
  • Sr. Member
  • *
  • Posts: 255
    • EHD Gaming
Re: CoD4 Mute
« Reply #12 on: September 24, 2011, 05:43:56 PM »
u must supply time and reason or it will error.

Offline MordyT

  • Support Hero
  • Hero Member
  • *
  • Posts: 3644
  • Over $300 Donated to B3!
    • MordyT
Re: CoD4 Mute
« Reply #13 on: September 26, 2011, 03:43:22 PM »
So I tried !mute name 1m test and !mute name 1m test on and both returned a error. Do you need some logs?
Help will be given to those with a b3.log

If drop off the map it is due to RL becoming busy :)

System: Python 2.7.3 - Deb 7 - B3 Source Code - 128MB RAM box (rented at $5 a year) - remote MySQL - Remote Web Services

Offline Garreth

  • Sr. Member
  • ****
  • Posts: 279
Re: CoD4 Mute
« Reply #14 on: September 26, 2011, 05:36:17 PM »
Quick glance at the code (I don't run COD server myself), and I believe MordyT, that you should try "!mute name 1 test" - that should ban for one minute. Unless the error is connected to something else (you could have paste this one line of error message:P )

 


Rate this page +1 at Google Search

anything