Miscellaneous Scripts (NEW: Suicide script)

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


These are just for fun scripts that are too small or have no serious usage. But they might be useful.

HP Tools
This is the script I wrote after peace, I never released it as I considered it to be useless. It basically allows you to hit a player for a specific value.

Commands
Spoiler:
/hit - example - /hit kuma 99 (you could also do -99 that would heal the player)
/hpc - example - /hpc kuma (returns the current hp of the player)
Code: Select all
#HP tools by Kuma
#Version 1

from commands import add, alias, admin, get_player
from pyspades.constants import *

@admin
def hit(connection, name = None, value = None):
    protocol = connection.protocol
    if name and value is not None:
        player = get_player(protocol, name)
        player.set_hp(player.hp - int(value))
    elif name is not None and value is None:
        player = get_player(protocol, name)
        player.set_hp(player.hp - 50)
    else:
        raise ValueError()

@alias('hpc')
def hpcheck(connection, name= None):
    protocol = connection.protocol
    if name is not None:
        player = get_player(protocol, name)
        connection.send_chat("{} has {} HP".format(player.name, player.hp))

add(hpcheck)

add(hit)

def apply_script(protocol, connection, config):
    return protocol, connection

hptools.py
(862 Bytes) Downloaded 285 times
Kick All
This might be a really useful script, it simply kicks all players on the server but it excludes the admins.
Commands
Spoiler:
/kickall - Self explanatory
Code: Select all
#Kick All script by Kuma
#Version 1.0

from commands import add, admin, alias

@admin
def kickall(connection):
    protocol = connection.protocol
    players_to_be_kicked = []
    for player in protocol.players.values():
        if not player.admin:
            players_to_be_kicked.append(player) #I need to do this as changing the size of the array between the execution = errors
    for player in players_to_be_kicked:
        player.kick(silent = True)
    protocol.send_chat("All players were kicked by {}".format(connection.name))

add(kickall)

def apply_script(protocol, connection, config):                    
    return protocol, connection
kickall.py
(672 Bytes) Downloaded 258 times
No Empty Chat
This is a script to prevent this kind of chat(see below). Simple add it to your script and it will do its job
Image
Code: Select all
#No Empty Chat by Kuma

NO_WHITESPACE = "Your message cannot be empty."

def apply_script(protocol, connection, config):

    class chatConnection(connection):
        def on_chat(self, value, global_message):
            if value.isspace():
                self.send_chat(NO_WHITESPACE)
                return False
            return connection.on_chat(self, value, global_message)
    return protocol, chatConnection
noemptychat.py
(433 Bytes) Downloaded 250 times
Suicide
Yes, it blows you up with a grenade when you type /su or /suicide also it hurts nearby enemy players.(Don't be offended at them because they seem like suicide bombing)
Code: Select all
#Suicide script by Kuma

from commands import add, admin, alias, get_player
from pyspades.server import grenade_packet
from pyspades.world import Grenade
from pyspades.common import Vertex3
from math import floor

DEAD = "You are already dead."

@alias('su')
def suicide(connection):
    protocol = connection.protocol
    if connection in protocol.players:
        obj = connection.world_object
        position = obj.position
	if connection.hp <= 0:
            connection.send_chat(DEAD)
	else:
            grenade_spawn(connection, position.x, position.y, position.z, fuse = 0, z_block = 0)
			
add(suicide)

def grenade_spawn(connection, x, y, z, fuse = 1, z_block = 10): #This function was copied off from explode.py written by me
    protocol = connection.protocol
    x, y, z = floor(x), floor(y), floor(z) - z_block
    v_position = Vertex3(x, y, z)
    grenade = protocol.world.create_object(Grenade, fuse, v_position, None, Vertex3(0, 0, 0), connection.grenade_exploded)
    grenade_packet.player_id = connection.player_id
    grenade_packet.value = grenade.fuse
    grenade_packet.position = grenade.position.get()
    grenade_packet.velocity = grenade.velocity.get()
    protocol.send_contained(grenade_packet)

def apply_script(protocol, connection, config):
    return protocol, connection
suicide.py
(1.31 KiB) Downloaded 270 times
Last edited by Kuma on Fri Oct 25, 2013 4:59 pm, edited 1 time in total.
TimeToDie
Green Master Race
Green Master Race
Posts: 37
Joined: Tue Sep 17, 2013 3:52 pm


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


New script suicide added.
[RUS] Vlad01
League Participant
League Participant
Posts: 1610
Joined: Sun Dec 16, 2012 7:37 am


nice k
Kuma
Scripter
Scripter
Posts: 758
Joined: Fri Mar 22, 2013 10:05 am


The suicide script has a bug, I recommend not to use it. I will fix the glitch shortly.
learn_more
Coder
Coder
Posts: 891
Joined: Sun Mar 24, 2013 9:59 pm


Kuma wrote:
The suicide script has a bug, I recommend not to use it. I will fix the glitch shortly.
the bug made it fun :D
6 posts Page 1 of 1 First unread post
Return to “Completed Releases”

Who is online

Users browsing this forum: No registered users and 1 guest