[SCRIPT] PEACE 2.4

Intended for use on live public servers.
15 posts Page 1 of 1 First unread post
Kuma
Scripter
Scripter
Posts: 758
Joined: Fri Mar 22, 2013 10:05 am


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
Attachments
peace.py
(4.43 KiB) Downloaded 367 times
Last edited by Kuma on Fri Oct 18, 2013 6:33 am, edited 7 times in total.
Electrix
League Participant
League Participant
Posts: 797
Joined: Mon Nov 12, 2012 5:34 pm


Awesome job Kuma! :) Really nice.
VladVP
Post Demon
Post Demon
Posts: 1425
Joined: Fri Dec 14, 2012 10:48 pm


Hm... excellent progress Kuma! You're already very far in when it comes to stepping into the world of programming! Green_Wink1
extra
Build and Shoot's 1st Birthday
Build and Shoot's 1st Birthday
Posts: 864
Joined: Mon Aug 26, 2013 10:56 pm


Great job!
Kuma
Scripter
Scripter
Posts: 758
Joined: Fri Mar 22, 2013 10:05 am


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
Kuma
Scripter
Scripter
Posts: 758
Joined: Fri Mar 22, 2013 10:05 am


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
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


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
VladVP
Post Demon
Post Demon
Posts: 1425
Joined: Fri Dec 14, 2012 10:48 pm


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?
Kuma
Scripter
Scripter
Posts: 758
Joined: Fri Mar 22, 2013 10:05 am


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
Kuma
Scripter
Scripter
Posts: 758
Joined: Fri Mar 22, 2013 10:05 am


Fixed glitch, in which /fly command was not usable after disabling peace
TimeToDie
Green Master Race
Green Master Race
Posts: 37
Joined: Tue Sep 17, 2013 3:52 pm


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
VladVP
Post Demon
Post Demon
Posts: 1425
Joined: Fri Dec 14, 2012 10:48 pm


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
Kuma
Scripter
Scripter
Posts: 758
Joined: Fri Mar 22, 2013 10:05 am


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.
Kuma
Scripter
Scripter
Posts: 758
Joined: Fri Mar 22, 2013 10:05 am


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
Kuma
Scripter
Scripter
Posts: 758
Joined: Fri Mar 22, 2013 10:05 am


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
15 posts Page 1 of 1 First unread post
Return to “Completed Releases”

Who is online

Users browsing this forum: No registered users and 2 guests