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: Voting Plugin (by danger89)  (Read 38878 times)

Offline danger89

  • Full Member
  • ***
  • Posts: 129
    • JoinMyServer - Game Servers
Re: Voting Plugin (by danger89)
« Reply #30 on: February 26, 2011, 11:46:49 PM »
New version release: 2.2
JoinMyServer.com
Call of Duty 4 Game Servers

Offline Platanos

  • Sr. Member
  • ****
  • Posts: 296
    • The Last Unit
Re: Voting Plugin (by danger89)
« Reply #31 on: February 28, 2011, 09:25:30 AM »
hi

works Mapvoting  for Black Ops Ranked Server?


LG

Offline danger89

  • Full Member
  • ***
  • Posts: 129
    • JoinMyServer - Game Servers
Re: Voting Plugin (by danger89)
« Reply #32 on: February 28, 2011, 10:08:31 AM »
hi

works Mapvoting  for Black Ops Ranked Server?
With version 2.2 should it work, yes. However until now I tested it on cod4, but I'm almost sure black ops uses also the 'map' command to change the map.

You should only change the maplist.txt file, to the maps you have/you want in Black Ops.

I hope to hear from you soon and be free to upload your new maplist.txt.

Kind regards,
Melroy
JoinMyServer.com
Call of Duty 4 Game Servers

Offline Spruehwurstheinz

  • Sr. Member
  • ****
  • Posts: 234
Re: Voting Plugin (by danger89)
« Reply #33 on: February 28, 2011, 04:52:05 PM »
I think it wouldn't work for black ops ranked. There is no possibility so set the next map, you need to exclude the other maps. Just a baka modified the rotationmanager plugin for that, I guess a similar modification is necessary for the voting plugin.

Offline Platanos

  • Sr. Member
  • ****
  • Posts: 296
    • The Last Unit
Re: Voting Plugin (by danger89)
« Reply #34 on: February 28, 2011, 05:29:58 PM »
hi

its true, vote passed but no map changing, a modification for BO would be nice

LG

Offline Blueeyes

  • Jr. Member
  • **
  • Posts: 22
    • eXec
Re: Voting Plugin (by danger89)
« Reply #35 on: March 15, 2011, 06:39:25 PM »
Player votes doesnt register on MW2 server, so basically !vn and !vy doesn't work.. Neither the timers work, you can vote again even tho I've set it to be 1 vote in 2 mins.

Offline gabarram

  • Sr. Member
  • ****
  • Posts: 186
Re: Voting Plugin (by danger89)
« Reply #36 on: March 15, 2011, 06:58:34 PM »

Offline danger89

  • Full Member
  • ***
  • Posts: 129
    • JoinMyServer - Game Servers
Re: Voting Plugin (by danger89)
« Reply #37 on: March 15, 2011, 08:55:45 PM »
JoinMyServer.com
Call of Duty 4 Game Servers

Offline Kid Cudi

  • Jr. Member
  • **
  • Posts: 27
Re: Voting Plugin (by danger89)
« Reply #38 on: April 20, 2011, 12:13:47 PM »
Hello, i am using your voting plugin, but doesnt work in MW2 right. I am using voting plugin 2.1.

I want that 6 votes are needed to kick, but only 2 votes are needed to kick someone with it.

voting.xml:
Code: [Select]
<configuration plugin="votekick">
<settings name="settings">
<set name="min_level_vote">0</set>

<set name="vote_times">2</set> <!-- number of times it shows an announcement -->
<set name="vote_interval_announcements">1</set> <!-- time in minutes between each announcement -->
<set name="vote_interval_failed">2</set> <!-- time in minutes after a failed vote and re-vote -->
        <set name="vote_minvotes">6</set> <!-- minimum necessary votes in order to pass a vote -->
</settings>

<settings name="votekick">
<set name="min_level_kick">0</set>
<set name="tempban_percent">55</set> <!-- minimum necessary percentage that voted in order to pass the vote -->
<set name="tempban_duration">9000</set> <!-- tempban duration in minutes -->
</settings>
</configuration>

and my voting.py:
Code: [Select]
__version__ = '2.1'
__author__  = 'Melroy'

import b3
import b3.plugin
import b3.cron
from b3 import clients
import time

class VotingPlugin(b3.plugin.Plugin):
    _adminPlugin = None
    _currentVote = None

    _caller = None

    _in_progress = False
    _yes = 0
    _no = 0
    _vetoed = 0
    _times = 0
    _vote_times = 3
    _vote_interval_announcements = 1
    _vote_interval_failed = 2
    _vote_minvotes = 6
    _votes = {}
   
    def startup(self):
        """\
        Initialize plugin settings
        """

        # get the plugin so we can register commands
        self._adminPlugin = self.console.getPlugin('admin')
        if not self._adminPlugin:
            # something is wrong, can't start without admin plugin
            self.error('Could not find admin plugin')
            return False
       
        self._vote_times = self.config.getint('settings', 'vote_times')
        self._vote_interval_announcements = self.config.getint('settings', 'vote_interval_announcements')
        self._vote_interval_failed = self.config.getint('settings', 'vote_interval_failed')
        self._vote_minvotes = self.config.getint('settings', 'vote_minvotes')

        try:
            minLevel_vote = self.config.getint('settings', 'min_level_vote')
        except:
            minLevel_vote = 1
        try:
            modLevel = self._adminPlugin.config.getint("settings","admins_level") 
        except:
            minLevel = 20
       
       
        self._adminPlugin.registerCommand(self, 'voteyes', minLevel_vote,  self.cmd_voteyes,  'vy')
        self._adminPlugin.registerCommand(self, 'voteno', minLevel_vote, self.cmd_voteno,  'vn')
        self._adminPlugin.registerCommand(self, 'voteveto', modLevel, self.cmd_veto,  'vveto')

        try:
            minLevel_kick = self.config.getint('votekick', 'min_level_kick')
        except:
            minLevel_kick = 20
        self._adminPlugin.registerCommand(self, 'votekick', minLevel_kick, self.cmd_votekick,  'vk')

        self._votes["kick"] = KickVote()
        self._votes["kick"].startup(self._adminPlugin,  self.console,  self.config)

 
    def pre_vote(self,  client):
        if self._in_progress:
            client.message("A vote is already in progress, wait until it finishes")
            return False
       
        if client.var(self,  'holding_vote').value:
            client.message("You have to wait between failed votes!")
            return False
        return True


    def cmd_votekick(self, data, client, cmd=None):
        """\
        <name> <motive> - call a votekick on that player for that motive
        """
        if not self.pre_vote(client):
            return False
       
        self._currentVote = self._votes["kick"]
       
        if not self._currentVote.start_vote(data, client):
            return False
       
        self.go_vote(client)

    def go_vote(self,  client):
        self._caller = client
        self._in_progress = True
        self._times = self._vote_times
        self._no = 0
        self._vetoed = 0
       
        self._yes = 1
        client.var(self,  'voted').value = True #The caller of the vote votes yes by default
       
        reason = self._currentVote.vote_reason()
        self.console.say("Calling a vote " + reason)
        self.console.say("Type ^1!vy ^7to vote ^1yes^7, ^2!vn ^7to vote ^2no")
        self.console.cron + b3.cron.OneTimeCronTab(self.update_vote,  "*/%s" %self._vote_interval_announcements)
   

    def cmd_veto(self, data, client, cmd=None):
        """\
        Cancel current vote
        """
        self._vetoed = 1

    def update_vote(self):
        if not self._vetoed:
            reason = self._currentVote.vote_reason()
            self.console.say("[%d/%d] Voting " % (self._vote_times - self._times + 1,  self._vote_times) + reason)
            self.console.say("Type ^1!vy ^7to vote ^1yes^7, ^2!vn ^7to vote ^2no")
            self.console.say("^1Yes: %s^7, ^2No: %s" %(self._yes,  self._no))
            self._times -= 1
            if self._times > 0:
                self.console.cron + b3.cron.OneTimeCronTab(self.update_vote,  "*/%s" %self._vote_interval_announcements)
            else:
                self.console.cron + b3.cron.OneTimeCronTab(self.end_vote,  "*/1")
        else:
            self.console.say("Vote ^1vetoed!")
            self._in_progress = False
            self._currentVote = None
   
    def end_vote(self):
        self.console.say("Vote ended")
        self._in_progress = False
        self.console.say("^1Yes: %s^7, ^2No: %s" %(self._yes,  self._no))
        if self._yes > self._no:
            if self._yes >= self._vote_minvotes:
                self._currentVote.end_vote_yes(self._yes,  self._no)
            else:
                self._caller.message('^7Vote failed. Too few people voted ^2yes')
        else:
            self._currentVote.end_vote_no(self._yes,  self._no)
            #The vote failed, the caller can't call another vote for a while
            self._caller.var(self,  'holding_vote').value = True
            temp = self._caller
            def let_caller_vote():
                self.debug("clearing %s" % temp.exactName)
                temp.var(self,  'holding_vote').value = False
           
            self.console.cron + b3.cron.OneTimeCronTab(let_caller_vote,  0, "*/%s" %self._vote_interval_failed)
       
        self._in_progress = False
        self._currentVote = None
   
        for c in self.console.clients.getList():
            c.var(self,  'voted').value = False

    def cmd_voteyes(self, data, client, cmd=None):
        if self.vote(client,  cmd):
            self._yes += 1
            cmd.sayLoudOrPM(client,  "Voted ^1YES")

    def cmd_voteno(self, data, client, cmd=None):
        if self.vote(client,  cmd):
            self._no += 1
            cmd.sayLoudOrPM(client,  "Voted ^2NO")
   
    def vote(self,  client,  cmd):
        if self._in_progress:
            if not client.var(self,  'voted').value:
                client.var(self,  'voted').value = True
                return True
            else:
                cmd.sayLoudOrPM(client,  "You already voted!")
        else:
            cmd.sayLoudOrPM(client,  "No vote in progress")
        return False

class KickVote(object):
    _adminPlugin = None
    console = None
    config = None
   
    _victim = None
    _caller = None
    _reason = None

    _modLevel = 20

    _tempban_duration = 9000
    _tempban_percent  = 55

    def startup(self,  adminPlugin,  console,  config):
        """\
        Initialize plugin settings
        """

        self._adminPlugin = adminPlugin
        self.console = console
        self.config = config

        self._modLevel = self._adminPlugin.config.getint("settings","admins_level")   
   
        self._tempban_percent = self.config.getint('votekick', 'tempban_percent')
        self._tempban_duration = self.config.getint('votekick', 'tempban_duration')
       
    def start_vote(self,  data,  client):
        m = self._adminPlugin.parseUserCmd(data)
        if not m:
            client.message('^7Invalid parameters')
            return False
        if not m[1]:
            client.message('^7Invalid parameters, must provide a reason!')
            return False           
        if len(m[1]) < 3:
            client.message("^7You should write a better motive")
       
        cid = m[0]
        sclient = self._adminPlugin.findClientPrompt(cid, client)
        if not sclient:
            return False
           
        if sclient.maxLevel >= self._modLevel:
            client.message("You can't kick an admin! Owned :)")
            return False
       
        self._caller = client
        self._victim = sclient
        self._reason = m[1]
        return True

    def vote_reason(self):
        return "against ^3%s because ^3%s" % (self._victim.exactName,  self._reason)
   
    def end_vote_yes(self,  yes,  no):
        self.console.say("^1KICKING ^3%s" %self._victim.exactName)
        self._victim.kick("Voted out",  self._caller)
        if self._tempban_duration and ((yes*100.0 / no) > self._tempban_percent):
            self._victim.tempban("", "Voted out", self._tempban_duration, self._caller)
        self._victim = None

    def end_vote_no(self,  yes,  no):
        self.console.say("Player is ^2safe!")
        self._victim = None

Can someone help me pls.

Offline danger89

  • Full Member
  • ***
  • Posts: 129
    • JoinMyServer - Game Servers
Re: Voting Plugin (by danger89)
« Reply #39 on: April 20, 2011, 06:44:56 PM »
Hello, i am using your voting plugin, but doesnt work in MW2 right. I am using voting plugin 2.1.

I want that 6 votes are needed to kick, but only 2 votes are needed to kick someone with it.

Can someone help me pls.


The setting:
Quote
<set name="vote_minvotes">6</set>

Should be do that right. Apparently no in your case.

Are you sure you place the voting.xml in the right directory (b3_root/conf)? And if you set the config path right in your b3.xml?:
Quote
.... config="@b3/conf/voting.xml"/>

Code: python [Select]
            if self._yes >= self._vote_minvotes:
                self._currentVote.end_vote_yes(self._yes,  self._no)
            else:
                self._caller.message('^7Vote failed. Too few people voted ^2yes')

Code for checking if votes yes are equal or higher then minimum votes (set in the config)

Maybe you can tell me a bit more about which message you get and even better... can you give me a debug log which makes it much easier for me to debug the problem.

Thanks in advance.

Kind regards,
Melroy vd Berg
« Last Edit: April 20, 2011, 06:49:52 PM by danger89 »
JoinMyServer.com
Call of Duty 4 Game Servers

Offline Kid Cudi

  • Jr. Member
  • **
  • Posts: 27
Re: Voting Plugin (by danger89)
« Reply #40 on: April 22, 2011, 05:15:18 PM »
yea i looked again, and the py file is right, but i putted the voting.xml into B3/config.

Then i added it to B3.xml.
Quote
   
            -->
        <plugin name="admin" config="C:\Program Files (x86)\Activision\BigBrotherBot_1.5.0\conf/plugin_admin.xml" />
      <plugin name="stats" config="C:\Program Files (x86)\Activision\BigBrotherBot_1.5.0\conf/plugin_stats.xml" />
      <plugin name="adv" config="C:\Program Files (x86)\Activision\BigBrotherBot_1.5.0\conf/plugin_adv.xml" />
      <plugin name="status" config="C:\Program Files (x86)\Activision\BigBrotherBot_1.5.0\conf/plugin_status.xml" />
      <plugin name="status" config="C:\Program Files (x86)\Activision\BigBrotherBot_1.5.0\conf/voting.xml" />

      <!-- The next plugins are external, 3rd party plugins and should reside in the external_dir. Example: -->
      <!-- plugin config="@b3/extplugins/conf/newplugin.xml" name="newplugin" -->
      <plugin config="C:\Program Files (x86)\Activision\BigBrotherBot_1.5.0\extplugins\conf/aimbotdetector.xml" name="aimbotdetector" />
      <plugin config="C:\Program Files (x86)\Activision\BigBrotherBot_1.5.0\extplugins\conf/autoreg.xml" name="autoreg" />
      <plugin config="C:\Program Files (x86)\Activision\BigBrotherBot_1.5.0\extplugins\conf/plugin_pingkicker.xml" name="pingkicker" />
      <plugin config="C:\Program Files (x86)\Activision\BigBrotherBot_1.5.0\extplugins\conf/report.xml" name="report" />
      <plugin config="C:\Program Files (x86)\Activision\BigBrotherBot_1.5.0\extplugins\conf/plugin_spree.xml" name="spree" />

      <!-- You can add new/custom plugins to this list using the same form as above. -->
      

and at least i puted the voting.py into plugins folder like in Readme.
But when i start it i get this error:

Quote
110422 17:17:45   BOT       Loading Plugin #5 status [C:\Program Files (x86)\Activision\BigBrotherBot_1.5.0\conf\voting.xml]
110422 17:17:45   BOT       StatusPlugin: Loading config C:\Program Files (x86)\Activision\BigBrotherBot_1.5.0\conf\voting.xml for StatusPlugin
110422 17:17:45   CRITICAL   Error loading plugin: No option 'output_file' in section: 'settings'
Traceback (most recent call last):
  File "b3\parser.pyo", line 555, in loadPlugins
  File "b3\plugin.pyo", line 64, in __init__
  File "b3\plugins\status.pyo", line 71, in onLoadConfig
  File "b3\config.pyo", line 109, in get
NoOptionError: No option 'output_file' in section: 'settings'


I dont get it.

Thx for your help.
« Last Edit: April 22, 2011, 05:18:17 PM by Kid Cudi »

Offline Beber888

  • B3 Contrib/Support
  • Sr. Member
  • *
  • Posts: 179
Re: Voting Plugin (by danger89)
« Reply #41 on: May 11, 2011, 01:15:01 PM »
Hello, I have done another version of this plugins for urbanterror.
My version add new votes for specials functions. (My server votes are disactived because of the possibility of hack)
This function are votekick, sniperonly, pistolonly, knifeonly, moonmode. For this 4 last votes the special function is disactived with a timer.
So you change the server config for a little time.

If peoples are interrested by my plugin, aswer plz I will released my plugin if someone interrested.
Python, Php, UrT SourceCode

Offline MordyT

  • Moderator
  • Hero Member
  • *
  • Posts: 3644
  • Over $300 Donated to B3!
    • MordyT
Re: Voting Plugin (by danger89)
« Reply #42 on: May 11, 2011, 02:46:19 PM »
Interested, but for CoD4... Could they activate a .cfg file (basically send a RCON command?).
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 Beber888

  • B3 Contrib/Support
  • Sr. Member
  • *
  • Posts: 179
Re: Voting Plugin (by danger89)
« Reply #43 on: May 11, 2011, 03:25:40 PM »
I think you can modify easily the pluging by changin the value by console.write("exec xxx.cfg").

Ok i will release my plugin tonight....
Python, Php, UrT SourceCode

Offline BlumentopfErde

  • Jr. Member
  • **
  • Posts: 12
    • Bleilust
Re: Voting Plugin (by danger89)
« Reply #44 on: May 15, 2011, 03:04:41 PM »
Hi!

What is the problem with

!vm killhouse instead of !vm mp_killhouse in CoD4?

I use this feature in UrbanTerror an it seems to work there.

 


Rate this page +1 at Google Search

anything