2
Donate to the B3 fund!

"even a small donation helps!"
Donate with PayPal!

Author Topic: Add a new Command  (Read 3525 times)

Offline Mr.Z

  • Newbie
  • *
  • Posts: 3
Add a new Command
« on: June 14, 2012, 06:03:02 PM »
Hello im trying to get a new command for amdins into B3


for the moment its looks like this

def cmd_ns(self, data, client=None, cmd=None):
"""\
<player> -Tell a Player He Done a Nice Shot!
"""

m = self.parseUserCmd(data)
if not m:
client.message('^7Invalid parameters, you must supply a player name')
return False

if m[0] == 'b3':
self.warnClient(client, 'B3 isn't a Player, Take a Vaild Player', None, False, '', 1)
else:
sclient = self.findClientPrompt(m[0], client)
if sclient:
self.console.say('^7%s %s^7!' % (Nice Shot (Name Of person), Make Other's like this and you will be as good as Z'), sclient.exactName))



there is my problem i dont know how to suply a player name and how to make it appear to every1,, not in PM


i want to put like the person who is said !ns in first and the person named in the Phrase



Ty

Offline Fenix

  • Dev. Team
  • Hero Member
  • *
  • Posts: 997
    • GitHub
Re: Add a new Command
« Reply #1 on: June 14, 2012, 08:06:43 PM »
Code: python [Select]

def cmd_ns(self, data, client=None, cmd=None):
    """\
    <player> - Tell a that he made a nice shot
    """
    if not data:
        client.message('^7Invalid data. Try !help ns')
        return False
    
    sclient = self.findClientPrompt(data, client)
    
    if not sclient
        # We were not able to find the specified player
        # We can exit here and the user will retry with a more specific name
        return False
        
    cmd.sayLoudOrPM(client, '^7Nice shot %s! Make other\'s like this and you will be as good as Z' % (sclient.exactName))
« Last Edit: July 03, 2012, 04:15:59 PM by Mr.Click »

Offline Mr.Z

  • Newbie
  • *
  • Posts: 3
Re: Add a new Command
« Reply #2 on: June 14, 2012, 08:48:45 PM »
ive putted that on the admins.py

after ive put the   <set name="ns">1</set>  in the plugins_admin.xml


after b3 doesnt starts


any ideas?

Offline 82ndAB.Bravo17

  • Dev. Team
  • Hero Member
  • *
  • Posts: 2616
Re: Add a new Command
« Reply #3 on: June 14, 2012, 09:45:49 PM »
You would need to check the log file for the error.

I would suggest that once you have it working  you create a separate plugin for it, it will make upgrading B3 much easier.

Offline Beber888

  • B3 Contrib/Support
  • Sr. Member
  • *
  • Posts: 179
Re: Add a new Command
« Reply #4 on: July 03, 2012, 02:02:16 PM »
Code: [Select]
    def cmd_ns(self, data, client=None, cmd=None):  
       """\
       <player> - Tell a that he made a nice shot
       """ 
       if not data: 
           client.message('^7Invalid data. Try !help ns') 
           return False 
         
       sclient = self.findClientPrompt(data, client) 
         
       if not sclient:
           # We were not able to find the specified player 
           # We can exit here and the user will retry with a more specific name 
           return False 
             
       cmd.sayLoudOrPM(client, '^7Nice shot %s! Make other\'s like this and you will be as good as Z' % (sclient.exactName)) 
         
Python, Php, UrT SourceCode

 


Rate this page +1 at Google Search