[SCRIPT]Bad Builder

Intended for use on live public servers.
9 posts Page 1 of 1 First unread post
LinktersHD
Deuced Up
Posts: 124
Joined: Thu Nov 01, 2012 12:27 pm


Base of script is from jail.py

Finally i've made my first script by my-self. This script allows you to disable a person from building with a reason. Instead of /togglebuild you can do "/bb <name <reason>" which disables them from building. You can also list all the bad builders by typing "/bblist" and check if someone is a bad builder with "/bblist <name>" which will tell you if he is and why. To allow someone to build again do "/freebb <name>.

This is my first script so feedback would be nice.

Commands:
Code: Select all
/badbuilder <player> [reason] Disables a person from building
/bb <player> <reason> Disables a person from building
/free <player> Lets a player build again
/freebb <player> Lets a player build again
/badbuilders [player] checks if a player is a bad builder. If no arguments are entered, it lists all bad builders players.
/bblist [player] checks if a player is a bad builder. If no arguments are entered, it lists all bad builders players.
/freeall WOOT, FREES EVERYONE WHO WAS A BAD BUILDER!
This script itself.
Code: Select all
"""
Bad Builders by LinktersHD

/badbuilder <player> [reason] Disables a person from building
/bb <player> <reason> Disables a person from building
/free <player> Lets a player build again
/freebb <player> Lets a player build again
/badbuilders [player] checks if a player is a bad builder. If no arguments are entered, it lists all bad builders players.
/bblist [player] checks if a player is a bad builder. If no arguments are entered, it lists all bad builders players.
/freeall WOOT, FREES EVERYONE WHO WAS A BAD BUILDER!
"""

from commands import add, admin, get_player, join_arguments, name, alias
from pyspades.common import to_coordinates, coordinates
from pyspades.constants import *

badbuilders_location = 0, 0, 0 # Ignore them, Not very usefull
badbuilders_coords   = ["B4"] # Ignore them

class Banleave(object): #IGNORE this, It will be used for a later update
    duration = 120.0 # 2 minutes
    interval = 2 * 60.0 # 3 minutes
    ban_duration = 15.0
    public_votes = True
    schedule = None

badbuilders_list = []

@name('badbuilder') # Long command to set a bad builder
@alias('bb') # Lets you use a shorter command
@admin
def setbadbuilder_player(connection, value = None, *args):
    protocol = connection.protocol
    player = get_player(protocol, value)
    reason = join_arguments(args[0:])
    if player not in protocol.players:
        raise ValueError() # If player doesn't exist, raise error
    else:
        if player.badbuilder:
            return 'Player ' + player.name + ' is already a badbuilder'
        elif not player.badbuilder:
            player.badbuilder = True
            player.reason = reason
            player.squad  = None
            player.squad_pref = None
            connection.protocol.send_chat("%s is a bad builder by for : %s" % (player.name, reason)) # Message
            connection.protocol.irc_say("* %s set %s as a bad builder for reason: %s" % (connection.name, player.name, reason)) # Message
            badbuilders_	.append(player.name)
add(setbadbuilder_player)

@name('badbuilders')
@alias('bblist')
def is_badbuilder(connection, value = None):
    if value is None:
        if not badbuilders_list:
            return 'There are no bad builder(s)'
        else:
            return "Bad builders are: " + ", ".join(badbuilders_list)
    elif value is not None:
        protocol = connection.protocol
        player = get_player(protocol, value)
        if player not in protocol.players:
            raise ValueError()
        else:
            if player.badbuilder:
                return 'Player %s is a bad builder for: %s' % (player.name, player.reason)
            else:
                return 'Player %s is not a bad builder' % (player.name)
add(is_badbuilder) # Adds "def is_badbuilder"

@name('free')
@alias('freebb') # Lets you use a shorter command
@admin
def free_from_badbuilder(connection, value):
    protocol = connection.protocol
    player = get_player(protocol, value)
    if player not in protocol.players:
        raise ValueError()
    else:
        if not player.badbuilder:
            return 'Player ' + player.name + ' is not a bad builder'
        elif player.badbuilder:
            player.badbuilder = False
            connection.protocol.send_chat("%s is allowed to build again. Freed from %s" % (player.name, connection.name))
            connection.protocol.irc_say('* %s was allowed to be build again. Freed from %s' % (player.name, connection.name))
            badbuilders_list.remove(player.name)
add(free_from_badbuilder)

@name('freeall')
@alias('freeallbb') # Lets you use a shorter command
@admin
def free_all(connection):
    protocol = connection.protocol
    for playersbadbuilder in badbuilders_list:
        player = get_player(protocol, playersbadbuilder)
        player.badbuilder = False
        player.reason = None
        badbuilders_list.remove(playersbadbuilder)
    return 'All players who were not allowed to build are allowed to build now'

add(free_all)

class Badboy(object):
    duration = 120.0 # 2 minutes
    interval = 2 * 60.0 # 3 minutes
    ban_duration = 15.0
    public_votes = True
    schedule = None

def apply_script(protocol, connection, config):
    class BuilderConnection(connection):
        badbuilder = False 
        def on_block_build_attempt(self, x, y, z):
            x, y, z = self.get_location()
            coord = to_coordinates(x, y)
            if self.badbuilder:
                self.send_chat("You can't build when you're a bad builder! You were set as a bad builder for %s" % (self.reason))
                return False
            elif coord in badbuilders_coords and not self.user_types.admin:
                self.send_chat("You can't build because you are a bad builder, %s!" % self.name)
                return False
            return connection.on_block_build_attempt(self, x, y, z)
        def on_block_destroy(self, x, y, z, mode):
            x, y, z = self.get_location()
            coord = to_coordinates(x, y)
            if self.badbuilder:
                self.send_chat("You can't destroy blocks when you're a bad builder! You are a bad builder for: %s" % (self.reason))
                return False
            elif coord in badbuilders_coords and not self.user_types.admin:
                self.send_chat("Stop trying to destroy buildings, %s!" % self.name)
                return False
            return connection.on_block_destroy(self, x, y, z, mode)
        def on_line_build_attempt(self, points):
            x, y, z = self.get_location()
            coord = to_coordinates(x, y)
            if self.badbuilder:
                self.send_chat("You can't build when you're a bad builder! You're not allowed to build for: %s" % (self.reason))
                return False
            elif coord in badbuilders_coords and not self.user_types.admin:
                self.send_chat("You can't build, %s!" % self.name)
                return False
            return connection.on_line_build_attempt(self, points)
        def on_disconnect(self):
            if self.badbuilder:
                badbuilders_list.remove(self.name)
                self.badbuilder = False
            return connection.on_disconnect(self)
    return protocol, BuilderConnection
Last edited by LinktersHD on Mon Mar 25, 2013 5:48 pm, edited 1 time in total.
topo
Global Moderator
Global Moderator
Posts: 179
Joined: Thu Nov 01, 2012 12:43 pm


yet again you've taken someone else's stuff, changed a couple lines around and released it as your own
bravo


here's a diff with jail.py
Code: Select all
2c2
< Jail script by PXYC
---
> Bad Builders by LinktersHD
4,7c4,10
< /jail <player> [reason] jails a player. Default reason is "None"
< /free <player> frees a player.
< /jailed [player] checks if a player is jailed. If no arguments are entered, it lists jailed players.
< /jailbreak frees all jailed players.
---
> /badbuilder <player> [reason] Disables a person from building
> /bb <player> <reason> Disables a person from building
> /free <player> Lets a player build again
> /freebb <player> Lets a player build again
> /badbuilders [player] checks if a player is a bad builder. If no arguments are entered, it lists all bad builders players.
> /bblist [player] checks if a player is a bad builder. If no arguments are entered, it lists all bad builders players.
> /freeall WOOT, FREES EVERYONE WHO WAS A BAD BUILDER!
10d12
< from pyspades.common import to_coordinates, coordinates
11a14
> from pyspades.common import to_coordinates, coordinates
14,15c17,18
< jail_location = 0, 0, 0 # x, y, z of the jail
< jail_coords   = [ ] # e.g. ["B4", "B5"]
---
> badbuilders_location = 0, 0, 0 # Ignore them, Not very usefull
> badbuilders_coords   = ["B4"] # Ignore them
17c20,25
< jail_list = []
---
> class Banleave(object): #IGNORE this, It will be used for a later update
>     duration = 120.0 # 2 minutes
>     interval = 2 * 60.0 # 3 minutes
>     ban_duration = 15.0
>     public_votes = True
>     schedule = None
19,20c27,30
< @name('jail')
< @alias('j')
---
> badbuilders_list = []
> 
> @name('badbuilder') # Long command to set a bad builder
> @alias('bb') # Lets you use a shorter command
22,25c32,35
< def jail_player(connection, value = None, *args):
<     protocol = connection.protocol # Meh
<     player = get_player(protocol, value) # Get player
<     reason = join_arguments(args[0:]) # Convert reason args into one string
---
> def setbadbuilder_player(connection, value = None, *args):
>     protocol = connection.protocol
>     player = get_player(protocol, value)
>     reason = join_arguments(args[0:])
29,32c39,42
<         if player.jailed:
<             return 'Player ' + player.name + ' is already jailed!' # Player is already jailed!
<         elif not player.jailed:
<             player.jailed = True # Set player to jailed
---
>         if player.badbuilder:
>             return 'Player ' + player.name + ' is already a badbuilder'
>         elif not player.badbuilder:
>             player.badbuilder = True
36,43c46,53
<             player.set_location(jail_location) # Move player to jail
<             connection.protocol.send_chat("%s was sent to jail by %s for reason(s): %s" % (player.name, connection.name, reason)) # Message
<             connection.protocol.irc_say("* %s jailed %s for reason: %s" % (connection.name, player.name, reason)) # Message
<             jail_list.append(player.name)
< add(jail_player) # Add command
< 
< @name('jailed')
< def is_jailed(connection, value = None):
---
>             connection.protocol.send_chat("%s is a bad builder by for : %s" % (player.name, reason)) # Message
>             connection.protocol.irc_say("* %s set %s as a bad builder for reason: %s" % (connection.name, player.name, reason)) # Message
>             badbuilders_   .append(player.name)
> add(setbadbuilder_player)
> 
> @name('badbuilders')
> @alias('bblist')
> def is_badbuilder(connection, value = None):
45,46c55,56
<         if not jail_list:
<             return 'No jailed players.'
---
>         if not badbuilders_list:
>             return 'There are no bad builder(s)'
48c58
<             return "Jailed players: " + ", ".join(jail_list)
---
>             return "Bad builders are: " + ", ".join(badbuilders_list)
55,56c65,66
<             if player.jailed:
<                 return 'Player %s jailed for: %s' % (player.name, player.reason)
---
>             if player.badbuilder:
>                 return 'Player %s is a bad builder for: %s' % (player.name, player.reason)
58,59c68,69
<                 return 'Player %s is not jailed.' % (player.name)
< add(is_jailed)
---
>                 return 'Player %s is not a bad builder' % (player.name)
> add(is_badbuilder) # Adds "def is_badbuilder"
61a72
> @alias('freebb') # Lets you use a shorter command
63,65c74,76
< def free_from_jail(connection, value):
<     protocol = connection.protocol # Meh
<     player = get_player(protocol, value) # Get player
---
> def free_from_badbuilder(connection, value):
>     protocol = connection.protocol
>     player = get_player(protocol, value)
67c78
<         raise ValueError() # Errors again
---
>         raise ValueError()
69,76c80,87
<         if not player.jailed: # If player isn't jailed
<             return 'Player ' + player.name + ' is not jailed!' # Message
<         elif player.jailed: # If player is jailed
<             player.jailed = False # Player is not jailed anymore
<             player.kill() # Kill the player
<             connection.protocol.send_chat("%s was freed from jail by %s" % (player.name, connection.name)) # Message
<             connection.protocol.irc_say('* %s was freed from jail by %s' % (player.name, connection.name)) # Message
<             jail_list.remove(player.name)
---
>         if not player.badbuilder:
>             return 'Player ' + player.name + ' is not a bad builder'
>         elif player.badbuilder:
>             player.badbuilder = False
>             connection.protocol.send_chat("%s is allowed to build again. Freed from %s" % (player.name, connection.name))
>             connection.protocol.irc_say('* %s was allowed to be build again. Freed from %s' % (player.name, connection.name))
>             badbuilders_list.remove(player.name)
> add(free_from_badbuilder)
78,80c89,90
< add(free_from_jail)
< 
< @name('jailbreak')
---
> @name('freeall')
> @alias('freeallbb') # Lets you use a shorter command
84,87c94,96
<     for playersJailed in jail_list:
<         player = get_player(protocol, playersJailed)
<         player.kill()
<         player.jailed = False
---
>     for playersbadbuilder in badbuilders_list:
>         player = get_player(protocol, playersbadbuilder)
>         player.badbuilder = False
89,90c98,99
<         jail_list.remove(playersJailed)
<     return 'All players freed.'
---
>         badbuilders_list.remove(playersbadbuilder)
>     return 'All players who were not allowed to build are allowed to build now'
93a103,109
> class Badboy(object):
>     duration = 120.0 # 2 minutes
>     interval = 2 * 60.0 # 3 minutes
>     ban_duration = 15.0
>     public_votes = True
>     schedule = None
> 
95,100c111,112
<     class JailConnection(connection):
<         jailed = False
<         def on_spawn_location(self, pos):
<             if self.jailed:
<                 return jail_location
<             return connection.on_spawn_location(self, pos)
---
>     class BuilderConnection(connection):
>         badbuilder = False
104,105c116,117
<             if self.jailed:
<                 self.send_chat("You can't build when you're jailed! You were jailed for %s" % (self.reason))
---
>             if self.badbuilder:
>                 self.send_chat("You can't build when you're a bad builder! You were set as a bad builder for %s" % (self.reason))
107,108c119,120
<             elif coord in jail_coords and not self.user_types.admin: # Stuff
<                 self.send_chat("You can't build near the jail, %s!" % self.name)
---
>             elif coord in badbuilders_coords and not self.user_types.admin:
>                 self.send_chat("You can't build because you are a bad builder, %s!" % self.name)
114,115c126,127
<             if self.jailed:
<                 self.send_chat("You can't destroy blocks when you're in jail! You were jailed for: %s" % (self.reason))
---
>             if self.badbuilder:
>                 self.send_chat("You can't destroy blocks when you're a bad builder! You are a bad builder for: %s" % (self.reason))
117,118c129,130
<             elif coord in jail_coords and not self.user_types.admin:
<                 self.send_chat("Stop trying to destroy the jail, %s!" % self.name)
---
>             elif coord in badbuilders_coords and not self.user_types.admin:
>                 self.send_chat("Stop trying to destroy buildings, %s!" % self.name)
124,125c136,137
<             if self.jailed:
<                 self.send_chat("You can't build when you're jailed! You were jailed for: %s" % (self.reason))
---
>             if self.badbuilder:
>                 self.send_chat("You can't build when you're a bad builder! You're not allowed to build for: %s" % (self.reason))
127,128c139,140
<             elif coord in jail_coords and not self.user_types.admin:
<                 self.send_chat("You can't build near the jail, %s!" % self.name)
---
>             elif coord in badbuilders_coords and not self.user_types.admin:
>                 self.send_chat("You can't build, %s!" % self.name)
131,139d142
<         def on_hit(self, hit_amount, player, type, grenade):
<             if self.jailed:
<                 if self.name == player.name:
<                     self.send_chat("Suicide isn't an option!")
<                     return False
<                 else:
<                     self.send_chat("You can't hit people when you're jailed! You were jailed for: %s" % (self.reason))
<                     return False
<             return connection.on_hit(self, hit_amount, player, type, grenade)
141,143c144,146
<             if self.jailed:
<                 jail_list.remove(self.name)
<                 self.jailed = False
---
>             if self.badbuilder:
>                 badbuilders_list.remove(self.name)
>                 self.badbuilder = False
145c148
<     return protocol, JailConnection
---
>     return protocol, BuilderConnection
\ No newline at end of file
LinktersHD
Deuced Up
Posts: 124
Joined: Thu Nov 01, 2012 12:27 pm


Yes it is from jail.py and edited, though i've decided that i will be remaking this so that if a player leaves it bans them for x minutes and etc.
Silnius
Assistant Moderator
Assistant Moderator
Posts: 274
Joined: Mon Nov 05, 2012 8:15 am


What about, using /togglebuild nameofplayer or #id ?

Blue_BigSmile
matthew0901
Deuced Up
Posts: 105
Joined: Wed Nov 21, 2012 12:23 pm


Is this for pyspades?
LinktersHD
Deuced Up
Posts: 124
Joined: Thu Nov 01, 2012 12:27 pm


matthew0901 wrote:
Is this for pyspades?
Of course it's for pyspades/pysnip.
ReubenMcHawk
Organizer
Organizer
Posts: 853
Joined: Sat Nov 03, 2012 4:36 am


No shame. #YOLO
sax
Winter Celebration 2013
Winter Celebration 2013
Posts: 14
Joined: Mon Jan 28, 2013 11:23 am


LinktersHD wrote:
I finally made a script by myself
No, you stole jail.py and edited it.

Making a script involves writing the whole thing yourself. You merely downloaded an existing script, left all of its code in place and changed small parts of it so you can call it your own.
rakiru
Coder
Coder
Posts: 1349
Joined: Sun Nov 11, 2012 12:26 pm


sax wrote:
LinktersHD wrote:
I finally made a script by myself
No, you stole jail.py and edited it.

Making a script involves writing the whole thing yourself. You merely downloaded an existing script, left all of its code in place and changed small parts of it so you can call it your own.
Exactly what I was going to say. I mean, feel free to modify existing scripts, but don't then claim to have done more than you actually did.
9 posts Page 1 of 1 First unread post
Return to “Completed Releases”

Who is online

Users browsing this forum: No registered users and 3 guests