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: AutoReg  (Read 11947 times)

Offline LouK

  • Full Member
  • ***
  • Posts: 119
    • The Sni:{Per}:Jum Clan
Re: AutoReg
« Reply #15 on: March 15, 2013, 08:14:02 PM »
Still having the same problem :S

When i reconnect, I'm moved to regular

b3.log(sorry for all that "spam" xd):

http://pastebin.com/fDgQ1eDJ

Offline PtitBigorneau

  • Moderator
  • Sr. Member
  • *
  • Posts: 194
    • www.ptitbigorneau.fr
Re: AutoReg
« Reply #16 on: March 15, 2013, 10:56:19 PM »
you change groups?
What are your group levels, groups_bits?

for the plugin you are User level 100 ???

Code: [Select]
DEBUG	u'AutoregPlugin: clientmaxLevel : 100 cgroup : User gnamelevel1 : User'

for me you have a problem with your groups :(
PtitBigorneau

Offline LouK

  • Full Member
  • ***
  • Posts: 119
    • The Sni:{Per}:Jum Clan
Re: AutoReg
« Reply #17 on: March 15, 2013, 11:14:38 PM »
Lorol!!

-
Code: [Select]
- phpMyAdmin SQL Dump
-- version 2.11.7.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Sep 10, 2010 at 07:45 PM
-- Server version: 5.0.51
-- PHP Version: 5.2.12

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

--
-- Database: `kikker916_database`
--

-- --------------------------------------------------------

--
-- Table structure for table `groups`
--

DROP TABLE IF EXISTS `groups`;
CREATE TABLE IF NOT EXISTS `groups` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `name` varchar(32) NOT NULL default '',
  `keyword` varchar(32) NOT NULL default '',
  `level` int(10) unsigned NOT NULL default '0',
  `time_edit` int(10) unsigned NOT NULL default '0',
  `time_add` int(10) unsigned NOT NULL default '0',
  PRIMARY KEY  (`id`),
  UNIQUE KEY `keyword` (`keyword`),
  KEY `level` (`level`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;

--
-- Dumping data for table `groups`
--

INSERT INTO `groups` VALUES(256, 'Admin', 'Admin', 40, 1185973704, 1185973704);
INSERT INTO `groups` VALUES(16, 'Member', 'member', 10, 1185973704, 1185973704);
INSERT INTO `groups` VALUES(4096, 'Full Admin', 'fulladmin', 60, 1185973704, 1185973704);
INSERT INTO `groups` VALUES(65536, 'Senior Admin', 'senioradmin', 80, 1185973704, 1185973704);
INSERT INTO `groups` VALUES(524288, 'Super Admin *', '95', 95, 1185973704, 1185973704);
INSERT INTO `groups` VALUES(2097152, 'Super Admin', 'superadmin', 100, 1185973704, 1185973704);
INSERT INTO `groups` VALUES(1048576, 'Super Admin **', '99', 99, 1185973704, 1185973704);
INSERT INTO `groups` VALUES(2, 'Regular', 'reg', 2, 1185973704, 1185973704);
INSERT INTO `groups` VALUES(1, 'User', 'user', 1, 1185973704, 1185973704);
INSERT INTO `groups` VALUES(8, 'Premium', 'premium', 5, 1185973704, 1185973704);
INSERT INTO `groups` VALUES(32, 'Moderator', 'mod', 20, 1185973704, 1185973704);
INSERT INTO `groups` VALUES(512, 'Admin+', '45', 45, 1185973704, 1185973704);
INSERT INTO `groups` VALUES(64, 'Moderator+1', '30', 30, 1185973704, 1185973704);
INSERT INTO `groups` VALUES(128, 'Moderator+2', '35', 35, 1185973704, 1185973704);
INSERT INTO `groups` VALUES(2048, 'Admin+2', '55', 55, 1185973704, 1185973704);
INSERT INTO `groups` VALUES(1024, 'Admin+1', '50', 50, 1185973704, 1185973704);
INSERT INTO `groups` VALUES(8192, 'Full Admin+', '65', 65, 1185973704, 1185973704);
INSERT INTO `groups` VALUES(16384, 'Full Admin+1', '70', 70, 1185973704, 1185973704);
INSERT INTO `groups` VALUES(32768, 'Full Admin+2', '75', 75, 1185973704, 1185973704);
INSERT INTO `groups` VALUES(131072, 'Senior Admin+', '85', 85, 1185973704, 1185973704);
INSERT INTO `groups` VALUES(262144, 'Head Admin', 'headadmin', 90, 1185973704, 1185973704);

Offline PtitBigorneau

  • Moderator
  • Sr. Member
  • *
  • Posts: 194
    • www.ptitbigorneau.fr
Re: AutoReg
« Reply #18 on: March 16, 2013, 12:36:13 AM »
it has no guest group, level 0 ?
PtitBigorneau

Offline LouK

  • Full Member
  • ***
  • Posts: 119
    • The Sni:{Per}:Jum Clan
Re: AutoReg
« Reply #19 on: March 16, 2013, 12:45:27 AM »
Should be? I just downloaded this from this forum :o

Offline PtitBigorneau

  • Moderator
  • Sr. Member
  • *
  • Posts: 194
    • www.ptitbigorneau.fr
Re: AutoReg
« Reply #20 on: March 16, 2013, 01:20:11 AM »
I'm not sure that this poses problem but no group-bits 0 level 0 can pose problems to b3

I tested with your groups and for me it works well

PtitBigorneau

Offline LouK

  • Full Member
  • ***
  • Posts: 119
    • The Sni:{Per}:Jum Clan
Re: AutoReg
« Reply #21 on: March 16, 2013, 01:21:33 AM »
Did you try to reconnect? I have the problem when mask myself and then reconnect to the server, try it ;)

Offline PtitBigorneau

  • Moderator
  • Sr. Member
  • *
  • Posts: 194
    • www.ptitbigorneau.fr
Re: AutoReg
« Reply #22 on: March 16, 2013, 10:21:46 AM »
normally it should work with this version

autoreg 1.4.1

PtitBigorneau

Offline LouK

  • Full Member
  • ***
  • Posts: 119
    • The Sni:{Per}:Jum Clan
Re: AutoReg
« Reply #23 on: March 16, 2013, 06:37:10 PM »
yep, thank you so much! it is a nice plugin! :p

P.S: I added this in the !noc command to allow admins to use it in @ or &, its just a little modification, but idk ;)

in def cmd_noc:

cmd.sayLoudOrPM(client, '%s^7 connected ^6%s ^7times. ^2%s^7 [^1%s^7] '%(sclient.exactName, sclient.connections, cgroup, sclient.maxLevel))

Regards

Offline Courgette

  • Senior Dev.
  • Hero Member
  • *
  • Posts: 4883
    • Github repository
Re: Re: AutoReg
« Reply #24 on: March 18, 2013, 08:40:05 AM »

Offline PtitBigorneau

  • Moderator
  • Sr. Member
  • *
  • Posts: 194
    • www.ptitbigorneau.fr
Re: AutoReg
« Reply #25 on: March 18, 2013, 09:07:16 AM »
thank you courgette for this information

 

PtitBigorneau

Offline LouK

  • Full Member
  • ***
  • Posts: 119
    • The Sni:{Per}:Jum Clan
Re: AutoReg
« Reply #26 on: June 10, 2013, 11:12:27 PM »
Hi there ptit,

I noticed that when a player(admin) is masked, the masked group is fine(with the !noc command) but not the level, it shows the command like:

LouK connected 100 rimes. User [100]

I would also suggest to put 1 or 10 connection(s) when masked, it's easy to be identified when you dont want to!

cheers

Offline PtitBigorneau

  • Moderator
  • Sr. Member
  • *
  • Posts: 194
    • www.ptitbigorneau.fr
Re: AutoReg
« Reply #27 on: June 12, 2013, 08:44:00 PM »
hi

I'd add a function to get a false numbers of connections for admins masked

parameterizable in the config file
PtitBigorneau

Offline LouK

  • Full Member
  • ***
  • Posts: 119
    • The Sni:{Per}:Jum Clan
Re: AutoReg
« Reply #28 on: June 12, 2013, 09:54:49 PM »
Hey there again, I tried to fix this by different ways, but I couldn't find the way to do it with the random atribute(see cmd_noc). masked group works fine now, here is my modification:

It just needs something related with the random atribute because when you use the !noc command, it allways show a random number even if the player is not masked

Code: [Select]
# AutoReg Plugin

__author__  = 'PtitBigorneau www.ptitbigorneau.fr'
__version__ = '1.4.1'

import b3, random
import b3.plugin
import b3.events
from b3 import clients

class AutoregPlugin(b3.plugin.Plugin):
   
    _adminPlugin = None
    _pluginactived = "on"
    _noclevel1 = 25
    _noclevel2 = 100
    _nocminlevel = 20
    _adminlevel = 100

    gnamelevel0 = "Guest"
    gkeywordlevel0 = "guest"
    gnamelevel1 = "User"
    gkeywordlevel1 = "user"
    gnamelevel2 = "Regular"
    gkeywordlevel2 = "reg"

    def onStartup(self):
       
        self._adminPlugin = self.console.getPlugin('admin')
       
        if not self._adminPlugin:

            self.error('Could not find admin plugin')
            return False

        self.registerEvent(b3.events.EVT_CLIENT_AUTH)

        self._adminPlugin.registerCommand(self, 'noc', self._nocminlevel, self.cmd_noc)
        self._adminPlugin.registerCommand(self, 'autoreg', self._adminlevel, self.cmd_autoreg)

    def onLoadConfig(self):

        try:
            self._pluginactived = self.config.get('settings', 'pluginactived')
        except Exception, err:
            self.warning("Using default value %s for Autoreg. %s" % (self._pluginactived, err))
        self.debug('Autoreg : %s' % self._pluginactived)

        try:
            self._noclevel1 = self.config.getint('settings', 'noclevel1')
        except Exception, err:
            self.warning("Using default value %s for level 1. %s" % (self._noclevel1, err))
        self.debug('number of connections for level 1 : %s' % self._noclevel1)

        try:
            self._noclevel2 = self.config.getint('settings', 'noclevel2')
        except Exception, err:
            self.warning("Using default value %s for level 2. %s" % (self._noclevel2, err))
        self.debug('number of connections for level 2 : %s' % self._noclevel2)

        try:
            self._nocminlevel = self.config.getint('settings', 'nocminlevel')
        except Exception, err:
            self.warning("Using default value %s for cmd noc. %s" % (self._nocminlevel, err))
        self.debug('min level for cmd !noc : %s' % self._nocminlevel)

        try:
            self._adminlevel = self.config.getint('settings', 'adminlevel')
        except Exception, err:
            self.warning("Using default value %s for adminlevel. %s" % (self._adminlevel, err))
        self.debug('min level for cmds : %s' % self._adminlevel)

    def onEvent(self, event):

        if self._pluginactived == 'on':

            if event.type == b3.events.EVT_CLIENT_AUTH:
           
                client = event.client
                self.group()
           
                cgroup = client.maxGroup.name
                cconnect = client.connections
                clevel = client.maxLevel

                if (cgroup == self.gnamelevel0) and (client.connections >= self._noclevel1):
           
                    self.debug("clientmaxLevel : %s cgroup : %s gnamelevel0 : %s"%(client.maxLevel, cgroup, self.gnamelevel0))

                    try:

                        group = clients.Group(keyword= self.gkeywordlevel1)
                        group = self.console.storage.getGroup(group)
               
                    except:
               
                        return False
               
                    client.setGroup(group)
                    client.save()

                if (cgroup == self.gnamelevel1) and (client.connections >= self._noclevel2):
 
                    self.debug("clientmaxLevel : %s cgroup : %s gnamelevel1 : %s"%(client.maxLevel, cgroup, self.gnamelevel1))
 
                    client.message('You are connected ^6%s^7 times. Thank you for your loyalty ^2:^5)^6!'%(client.connections))
                    client.message('you are now in the group ^2%s ^7[^22^7], type ^2!help 2 ^7to see your new comands'%(self.gnamelevel2))
               
                    try:

                        group = clients.Group(keyword= self.gkeywordlevel2)
                        group = self.console.storage.getGroup(group)
               
                    except:
               
                        return False
               
                    client.setGroup(group)
                    client.save()
       
        else:

           return False
   
    def cmd_noc(self, data, client, cmd=None):
       
        """\
        info client connections
        """
       
        if data:
           
            input = self._adminPlugin.parseUserCmd(data)
       
        else:
           
            client.message('!noc <name>')
            return
       
        sclient = self._adminPlugin.findClientPrompt(input[0], client)
       
        if sclient:
           
            if sclient.maskedGroup:
                 
                cgroup = sclient.maskedGroup.name
                cconnect = random.choice(('18', '9', '1', '16', '2', '13', '7', '4', '6'))
                clevel = sclient.maskedGroup.level
               
            else:
       
                cgroup = self.gnamelevel0
                cconnect = sclient.connections
                clevel = sclient.maxLevel
           
            cmd.sayLoudOrPM(client, '%s^7 connected ^6%s ^7times. ^2%s^7 [^1%s^7] '%(sclient.exactName, cconnect, cgroup, clevel)) 
       
        else:
            return False

    def cmd_autoreg(self, data, client, cmd=None):
       
        """\
        activate / deactivate autoreg or change number of connections
        """
       
        if data:
           
            input = self._adminPlugin.parseUserCmd(data)
       
        else:
       
            if self._pluginactived == 'on':

                client.message('Autoreg is ^2activated^7 ')

            if self._pluginactived == 'off':

                client.message('Autoreg is ^1deactivated^7 ')
           
            client.message('The number of connections for ^3Level1 ^7is ^2%s^7 '%(self._noclevel1))
            client.message('The number of connections for ^3Level2 ^7is ^2%s^7 '%(self._noclevel2))
            client.message('!autoreg <on / off> or <level1 or level2> <number of connections>')
           
            return False

        if input[0] == 'on':

            if self._pluginactived != 'on':

                self._pluginactived = 'on'
                message = 'Autoreg is now ^2activated^7 '
                settingname = 'pluginactived'
                settingsvalue = 'on'               

            else:

                client.message('Autoreg is already ^2activated')

                return False

        elif input[0] == 'off':

            if self._pluginactived != 'off':

                self._pluginactived = 'off'
                message = 'Autoreg ^1deactivated^7 '
                settingname = 'pluginactived'
                settingsvalue = 'off'
            else:
               
                client.message('autoreg is already ^1disabled')               

                return False

        elif input[0] == 'level1' or input[0] == 'level2':

                if input[1]:

                    if input[1].isdigit():
                       
                        if input[0] == 'level1':
                            self._noclevel1 = input[1]
                            settingname = 'noclevel1'

                        if input[0] == 'level2':
                            self._noclevel2 = input[1]
                            settingname = 'noclevel2'

                        settingsvalue = input[1]
                        message = 'The number of connections for ^3%s ^7is now ^2%s^7 '%(input[0], settingsvalue)

                    else:

                        client.message('!autoreg <level1 or level2> <number of connections>')
                        return False

                else:

                    if input[0] == 'level1':
                        client.message('The number of connections for ^3%s ^7is ^2%s^7 '%(input[0], self._noclevel1))
                                           
                    if input[0] == 'level2':
                        client.message('The number of connections for ^3%s ^7is ^2%s^7 '%(input[0], self._noclevel2))
                   
                    client.message('!autoreg <level1 or level2> <number of connections>')
                    return False

        else:

            client.message('!autoreg <on / off> or <level1 or level2> <number of connections>')
            return False

        client.message('%s '%(message))

        modif = "%s: %s\n"%(settingname, settingsvalue)

        fichier = self.config.fileName

        autoregini = open(fichier, "r")
       
        contenu = autoregini.readlines()

        autoregini.close()

        newcontenu = ""

        for ligne in contenu:

            if settingname in ligne:

                ligne = modif

            newcontenu = "%s%s"%(newcontenu, ligne)       

        autoreginiw = open(fichier, "w")
        autoreginiw.write(newcontenu)
        autoreginiw.close()

    def group(self):

        self.rgname = None
        self.rgkeyword = None
   
        cursor = self.console.storage.query("""
        SELECT *
        FROM groups n
        """)

        if cursor.EOF:
 
            cursor.close()           
           
            return False

        while not cursor.EOF:
       
            sr = cursor.getRow()
            gname= sr['name']
            gkeyword = sr['keyword']
            glevel= sr['level']
       
            if glevel == 0:

                self.gnamelevel0 = gname
                self.gkeywordlevel0 = gkeyword

            if glevel == 1:

                self.gnamelevel1 = gname
                self.gkeywordlevel1 = gkeyword

            if glevel == 2:

                self.gnamelevel2 = gname
                self.gkeywordlevel2 = gkeyword

            cursor.moveNext()
   
        cursor.close()

        return

Offline PtitBigorneau

  • Moderator
  • Sr. Member
  • *
  • Posts: 194
    • www.ptitbigorneau.fr
Re: AutoReg
« Reply #29 on: June 13, 2013, 06:12:22 PM »
Code: [Select]
            if sclient.maskedGroup.level != 0:
                
                cgroup = sclient.maskedGroup.name
                cconnect = random.choice(('18', '9', '1', '16', '2', '13', '7', '4', '6'))
                clevel = sclient.maskedGroup.level
                
            else:
        
                cgroup = self.gnamelevel0
                cconnect = sclient.connections
                clevel = sclient.maxLevel

maskedgroup is never null
maskedgroup.level equal 0 by default
« Last Edit: June 13, 2013, 06:26:07 PM by PtitBigorneau »
PtitBigorneau

 


Rate this page +1 at Google Search