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!

You are here: Big Brother Bot ForumAdd-OnsPlugins Discussion (Moderator: MordyT)Random client select
Pages: 1 [2]   Go Down
  Print  
Author Topic: Random client select  (Read 768 times) Bookmark and Share
B3 Contrib/Support
*
OS: Linux
Type: Owner dedicated server(s)
Gameservers: UrT
Posts: 133
Offline Offline
WWW
« Reply #15 on: December 06, 2011, 02:37:16 AM »

Code:
    guy = random.randint(0, 20)  
    client.message('RANDOM CLIENT')  

    for x in self.console.clients.getList():

        if guy == x.cid :

            randomclient = x

I do not know if this is something like this you have need
« Last Edit: December 06, 2011, 02:40:25 AM by PtitBigorneau » Logged

Jr. Member
**
OS: Windows
Type: Renting Server with B3
Gameservers: CoD4
Posts: 24
Offline Offline
« Reply #16 on: December 08, 2011, 10:30:34 PM »

Code:
    def cmd_gift(self, data, client, cmd=None):
        """\
        Gives a random player a gift
        """
        m = self._adminPlugin.parseUserCmd(data)
        if not m:
            clients = random.choice(self.console.clients.getClientsByState(b3.STATE_ALIVE))
            guy = clients.cid
            gunList = ['punish give::' + guy + '::deserteagle', 'punish give::' + guy + '::deserteaglegold', 'punish give::' + guy + '::G3', 'punish give::' + guy + '::G36', 'punish give::' + guy + '::M4', 'punish give::' + guy + '::M16', 'punish give::' + guy + '::m40a3', 'punish give::' + guy + '::usp', 'punish give::' + guy + '::ak47', 'punish give::' + guy + '::mp5', 'punish give::' + guy + '::p90', 'punish give::' + guy + '::uzi', 'punish give::' + guy + '::remington700', 'punish give::' + guy + '::M60E4_reflex']
            giftList = ['punish give::' + guy + '::deserteagle', random.choice(gunList)]
            gun = random.choice(giftList)
            client.message(gun)
            self.console.write('%s' % (gun))
            self.console.say('^2Merry ^1Christmas ^7%s' % (clients.exactName))
            return False

        sclient = self._adminPlugin.findClientPrompt(m[0], client)
        if sclient:
            guy = sclient.cid
            gunList = ['punish give::' + guy + '::deserteagle', 'punish give::' + guy + '::deserteaglegold', 'punish give::' + guy + '::G3', 'punish give::' + guy + '::G36', 'punish give::' + guy + '::M4', 'punish give::' + guy + '::M16', 'punish give::' + guy + '::m40a3', 'punish give::' + guy + '::usp', 'punish give::' + guy + '::ak47', 'punish give::' + guy + '::mp5', 'punish give::' + guy + '::p90', 'punish give::' + guy + '::uzi', 'punish give::' + guy + '::remington700', 'punish give::' + guy + '::M60E4_reflex']
            giftList = ['punish give::' + guy + '::deserteagle', random.choice(gunList)]
            gun = random.choice(giftList)
            client.message(gun)
            self.console.write('%s' % (gun))
            self.console.say('^2Merry ^1Christmas ^7%s' % (sclient.exactName))

this works it works if you want to type in a name or just keep it random
Logged
Tags:
Pages: 1 [2]   Go Up
  Print  
 
Jump to:  


Rate this page +1 at Google Search


SimplePortal 2.3.1 © 2008-2009, SimplePortal