Miscellaneous Scripts (NEW: Suicide script)
Posted: Wed Oct 23, 2013 11:22 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
This might be a really useful script, it simply kicks all players on the server but it excludes the admins.
Commands
This is a script to prevent this kind of chat(see below). Simple add it to your script and it will do its job

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)
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:
Code: Select all
Kick 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
This might be a really useful script, it simply kicks all players on the server but it excludes the admins.
Commands
Spoiler:
Code: Select all
No Empty Chat#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
This is a script to prevent this kind of chat(see below). Simple add it to your script and it will do its job

Code: Select all
Suicide#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
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