Pages: [1]   Go Down
  Print  
Author Topic: Warnings system  (Read 396 times) Bookmark and Share
Jr. Member
**
OS: Windows
Type: Owner dedicated server(s)
Gameservers: Urt
Posts: 20
Offline Offline
« on: January 01, 2012, 01:34:58 AM »

I do my little own plugin, but i dont know how to provide a warning after some actions. I searched in spam plugin and others but i got errors every time..

For example lets take a part from funnydeath:
Code:
def someoneKilled(self, client, target, data=None):
        if data[1] == self.console.MOD_SUICIDE:
            self._nbHWK += 1
            if self._nbHWK + 0:
                self.console.write('bigtext "^3%s ^7decided to see God!"' % (client.exactName))

After this i want to do a warning. What i need to write and include in code?

UPD: i have object has no attribute error in b3.log when plugin trying to warn
« Last Edit: January 01, 2012, 02:05:30 AM by Laggi » Logged

Jr. Member
**
OS: Windows
Type: Owner dedicated server(s)
Gameservers: Urt
Posts: 20
Offline Offline
« Reply #1 on: January 01, 2012, 03:49:50 AM »

Ok what i put here (example):

Code:
def someoneKilled(self, client, target, data=None):
        if data[1] == self.console.MOD_SUICIDE:
            self._nbHWK += 1
            if self._nbHWK + 0:
                self.console.write('bigtext "^3%s ^7decided to see God!"' % (client.exactName))
                self.penalizeClient(event.client)
        
 def penalizeClient(self, client, data=''):
        if not client :
            return False
        self._adminPlugin.warnClient(client, 'warning ! blabla', None, True, '', 1)


And i got an error, which i think very popular to python coders. global name 'event' is not defined what to fix here?

UPD2: fixed this error. but it doesnt work and i still want to know how to use warnings correctly here. please some help!
« Last Edit: January 01, 2012, 03:56:16 AM by Laggi » Logged
Jr. Member
**
OS: Windows
Type: Owner dedicated server(s)
Gameservers: Urt
Posts: 20
Offline Offline
« Reply #2 on: January 01, 2012, 12:41:35 PM »

Any help? please   Huh
Logged
Support Hero
*
OS: Windows
Type: Gameserver Rental Co.
Gameservers: 2x CoD4, 1x BF3
Posts: 2627
Offline Offline
Owner of Host4B3.com - Over 70 bots hosted!
WWW
« Reply #3 on: January 02, 2012, 05:51:09 AM »

Relax. Your post was on Sunday, which also was New Years. Not many people online then.
People will be around to try to help you but you have to have patience.
Logged

Need B3 Bot hosting? Check out Host4B3.com
Check Twitter.com/Host4B3 for updates if the site it down.

Help will be given to those with a b3.log

System: Python 2.7.1 - B3 Source Code - Locally hosted MySQL & Apache - Win 2k3
B3 Contrib/Support
*
OS: Linux
Type: Owner dedicated server(s)
Gameservers: UrT
Posts: 133
Offline Offline
WWW
« Reply #4 on: January 02, 2012, 07:47:08 AM »

I do not understand what you want to but saw your code
for do simply

Code:
import b3
import b3.events
import b3.plugin

class PbtestPlugin(b3.plugin.Plugin):
    _adminPlugin = None
 
    def onLoadConfig(self):
        self._adminPlugin = self.console.getPlugin('admin')
        if not self._adminPlugin:
            self.error('Could not find admin plugin')
            return False
        
    def onStartup(self):

        self.registerEvent(b3.events.EVT_CLIENT_SUICIDE)
    
    def onEvent(self, event):
        if event.type == b3.events.EVT_CLIENT_SUICIDE:
            client = event.client
            self.console.write('bigtext "^3%s ^7decided to see God!"' % (client.exactName))
            self._adminPlugin.warnClient(sclient, 'warning ! blabla', None, False, '', 10)

Logged
Jr. Member
**
OS: Windows
Type: Owner dedicated server(s)
Gameservers: Urt
Posts: 20
Offline Offline
« Reply #5 on: January 03, 2012, 12:24:08 AM »

Thanks guys! already get it working! Smiley
Logged
Tags:
Pages: [1]   Go Up
  Print  
 
Jump to:  


Rate this page +1 at Google Search


SimplePortal 2.3.1 © 2008-2009, SimplePortal