Page 1 of 1

[SCRIPT] PEACE 2.4

Posted: Fri Oct 04, 2013 6:20 pm
by Kuma
This script mode just started as a experiment, resulted in something like super cool build. This script oriented towards build servers (its free for all, meaning any one can build) As the name suggests players can't kill each other and there is no fall damage.
Public Commands:-
/f - Enables a user to fly, But it can't be used on other players. Thus it prevents trolls
/ib - Infinite blocks
/gt <name_of_coordinate> - Goes to the given coordinate (example - /gt a1)
/peacehelp - Some information about this mode

Admin Commands:-
/peace - toggles peace mode
/sf - Removes fly from all players
/ta - Teleports all players in at one coordinate (works perfectly Blue_Happy3 )
Code: Select all
#PEACE script by Kuma
#This script is mainly aimed at build servers, has useful commands for building

#VERSION 2.4
#LOT OF STUFF ADDED

from commands import add, alias, admin, name, move
from twisted.internet.task import LoopingCall

PEACE_ENABLED_MESSAGE = "Peace mode has been enabled, Type /peacehelp for more information."
PEACE_DISABLED_MESSAGE = "Peace mode has been disabled."
NO_PEACE = "Peace mode is not enabled."
FLY_STRIPED = "All players were striped of their fly."
NO_GRENADE_MESSAGE = "Grenades won't do anything."

PEACE = True #Change this to False if you don't want peace from start
NO_GRENADE = True #Change this to False if you want grenades (Only for PEACE mode)

@alias('peace')
@admin
def peacemode(connection):
    global PEACE, strip
    protocol = connection.protocol
    PEACE = not PEACE
    if PEACE:
        protocol.send_chat(PEACE_ENABLED_MESSAGE)
    else:
        protocol.send_chat(PEACE_DISABLED_MESSAGE)
        strip_fly(connection)

@alias('sf')        
@admin
def strip_fly(connection):
    protocol = connection.protocol    
    for player in protocol.players.values():
        while(player.fly):
            player.fly = False
    connection.send_chat(FLY_STRIPED)

def peacehelp(connection):
    protocol = connection.protocol
    help = ["-" * 50,"Some of the commands are: /f, /ib, /gt","Players don't take fall damage or grenade damage","In peace mode, no player can be killed by a normal player", "-" * 50]
    if connection in protocol.players:
        for line in help:
            connection.send_chat(line)

@alias('f')
def peace_fly(connection):
    protocol = connection.protocol
    if PEACE:
        if connection in protocol.players:
            player = connection
            player.fly = not player.fly
            message = 'now flying' if player.fly else 'no longer flying'
            player.send_chat("You're {0}".format(message))
    else:
        connection.send_chat(NO_PEACE)

@alias('gt')
def peace_go_to(connection, value):
    if PEACE:
        protocol = connection.protocol
        if connection in protocol.players:
            move(connection, connection.name, value) #Imported from commands.py
    else:
        connection.send_chat(NO_PEACE)

@alias('ib') 
def peace_infi_blocks(connection):
    protocol = connection.protocol
    if PEACE:
        if connection in protocol.players:
            connection.infinite_blocks = not connection.infinite_blocks
            message = 'now in infinite blocks mode' if connection.infinite_blocks else 'not in infinite blocks mode'
            connection.send_chat("You're {0}".format(message))
    else:
        connection.send_chat(NO_PEACE)

@alias('ta')
def teleportall(connection, value = None):
    protocol = connection.protocol
    if not value is None and PEACE:
        for player in protocol.players.values():
            move(player, player.name, value, silent = True)
        protocol.send_chat("All players were teleported to {}".format(value))
      
add(peacemode)
add(peacehelp)
add(peace_fly)
add(peace_go_to)
add(peace_infi_blocks)
add(strip_fly)
add(teleportall)

def apply_script(protocol, connection, config):

    class peaceConnection(connection):
        infinite_blocks = False
        strip = False
        
        def on_block_build(self, x, y, z):
            if PEACE:
                if self.infinite_blocks:
                    self.refill()
                    return connection.on_block_build(self, x, y, z)
            return connection.on_block_build(self, x, y, z)

        def on_line_build(self, points):
            if PEACE:
                if self.infinite_blocks:
                    self.refill()
                    return connection.on_line_build(self, points)
            return connection.on_line_build(self, points)

        def on_hit(self, hit_amount, hit_player, type, grenade):
            if PEACE:
                return False
            return connection.on_hit(self, hit_amount, hit_player, type, grenade)

        def on_fall(self, damage):
            if PEACE:
                return False
            return connection.on_fall(self, damage)

        def grenade_exploded(self, grenade):
            if PEACE:
                if NO_GRENADE:
                    self.send_chat(NO_GRENADE_MESSAGE)
                    return False
            return connection.grenade_exploded(self, grenade)

    return protocol, peaceConnection

Re: [SCRIPT] PEACE

Posted: Fri Oct 04, 2013 6:24 pm
by Electrix
Awesome job Kuma! :) Really nice.

Re: [SCRIPT] PEACE

Posted: Fri Oct 04, 2013 9:39 pm
by VladVP
Hm... excellent progress Kuma! You're already very far in when it comes to stepping into the world of programming! Green_Wink1

Re: [SCRIPT] PEACE

Posted: Sat Oct 05, 2013 12:17 am
by extra
Great job!

Re: [SCRIPT] PEACE

Posted: Sat Oct 05, 2013 12:56 am
by Kuma
VladVP wrote:
Hm... excellent progress Kuma! You're already very far in when it comes to stepping into the world of programming! Green_Wink1
Din't I say I learn fast Blue_Wink1

Re: [SCRIPT] PEACE

Posted: Sat Oct 05, 2013 1:39 am
by Kuma
New version 2.0 added:
--No public command can be used now, if there is no peace mode
--People get a error message if they do that
--Removed unnecessary code
--Better messages

Re: [SCRIPT] PEACE

Posted: Sat Oct 05, 2013 10:20 am
by thepolm3
Wow. Words can not even begin to describe how much love there is for this script. IT IS AMAZING. It is scripting genius. It is just so lovable!And if you're wondering, this is a response to a pm

Re: [SCRIPT] PEACE

Posted: Sat Oct 05, 2013 11:01 am
by VladVP
thepolm3 wrote:
Wow. Words can not even begin to describe how much love there is for this script. IT IS AMAZING. It is scripting genius. It is just so lovable!And if you're wondering, this is a response to a pm
...what?

Re: [SCRIPT] PEACE

Posted: Sat Oct 05, 2013 11:54 am
by Kuma
thepolm3 wrote:
Wow. Words can not even begin to describe how much love there is for this script. IT IS AMAZING. It is scripting genius. It is just so lovable!And if you're wondering, this is a response to a pm
:333

Re: [SCRIPT] PEACE 2.1

Posted: Mon Oct 07, 2013 5:16 am
by Kuma
Fixed glitch, in which /fly command was not usable after disabling peace

Re: [SCRIPT] PEACE 2.1

Posted: Tue Oct 15, 2013 6:16 pm
by TimeToDie
can you change it that when the server start the peace mode will be off and the admin need to anable this ?
btw, if i hurt someone from other group or from mone group, that not write anything. i think it should write something.

Thanks a lot i loved the scripts !!! :D

Re: [SCRIPT] PEACE 2.1

Posted: Tue Oct 15, 2013 6:45 pm
by VladVP
idantheking99 wrote:
can you change it that when the server start the peace mode will be off and the admin need to anable this ?
btw, if i hurt someone from other group or from mone group, that not write anything. i think it should write something.

Thanks a lot i loved the scripts !!! :D
It says how to do that in the fucking code. learn2reed

Re: [SCRIPT] PEACE 2.1

Posted: Wed Oct 16, 2013 6:03 am
by Kuma
idantheking99 wrote:
can you change it that when the server start the peace mode will be off and the admin need to anable this ?
btw, if i hurt someone from other group or from mone group, that not write anything. i think it should write something.

Thanks a lot i loved the scripts !!! :D
vlad said you can change that yoruself, open it with notepad and then set PEACE = False (remember capital F)
Then you can enable it with the /peace command

@VladVP
Calm down vlad, a normal person who doesn't know how to code will never look at a scripts source.

Re: [SCRIPT] PEACE 2.3

Posted: Wed Oct 16, 2013 7:55 am
by Kuma
New Peace mode version! 2.3
--Removed a glitch and optimized a bit of code(Like made 13 lines of code into 4)
--Added /sf command

Re: [SCRIPT] PEACE 2.4

Posted: Thu Oct 17, 2013 4:13 pm
by Kuma
New Version! 2.4
--Fixed glitchy chat
--If NO_GRENADE = True then grenades don't do anything in build mode
--New command /ta
--Better grammar in message (I think)

I recommend using hompy's preserve color and polm's world edit if you want a proper build server