Page 1 of 1

[SCRIPT] greteleport

Posted: Sat Oct 19, 2013 7:21 am
by Kuma
I am proud of this script. Its like a prototype for a gamemode I was planning (but i rq on that) So here it is, a script which allows you teleport where your grenade exploded.
script requested by TimeToDie

Commands

public commands
/u - simply a /unstick but can only be used on himself/herself

admin commands
/gtp or /grenadeteleport - toggle grenade teleport
/zb <number> - sets how high will the server teleport you when you throw the grenade (default value: 5)

This script also supports adding stuff to the config file, you can add something like this at the end of the config file.
Code: Select all
	"z_blocks" : <number>,
	"grenade_teleport" : <true or false>
NOTE: the values in <> must be replaced by something
The actual scipt:
Code: Select all
#greteleport by Kuma
#Version 1

from commands import add, admin, name, alias
from pyspades.server import position_data
from math import floor

GRENADE_TELEPORT_MESSAGE = "Grenade teleport has been turned {bool}"
GRENADE_OUT = "You can't throw the grenade out of the map"

@alias('gtp')
@admin
def grenadeteleport(connection):
  protocol = connection.protocol
  protocol.grenade_teleport = not protocol.grenade_teleport
  on_off = "ON" if protocol.grenade_teleport else "OFF"
  protocol.send_chat(GRENADE_TELEPORT_MESSAGE.format(bool = on_off))

@alias('zb')
@admin
def grenadezblock(connection, value = None):
  protocol = connection.protocol
  if not value is None:
    value = int(value)
    protocol.z_blocks = value    
    protocol.send_chat("Spawn Z block set to {}".format(value))
  else:
    protocol.z_blocks = 5
    protocol.send_chat("Spawn Z block set to default value")  

@alias('u')
@name('uns')
def unstick_player(connection):
  protocol = connection.protocol
  player = connection
  if player in protocol.players:
    player.set_location_safe(player.get_location())
  
add(grenadeteleport)
add(grenadezblock)
add(unstick_player)

def apply_script(protocol, connection, config):

  class gtpConnection(connection):
    def grenade_exploded(self, grenade):
      protocol = self.protocol
      if protocol.grenade_teleport:
        position = grenade.position
        x, y, z = position.x, position.y, position.z
        x, y, z = int(floor(x))-0.5, int(floor(y))-0.5, protocol.map.get_height(x, y) - protocol.z_blocks +0.5
        if position.x < 0 or position.y < 0 or position.x > 512 or position.y > 512 or position.z < 0 or position.z > 64:
          self.send_chat(GRENADE_OUT)
          return False        
        else:
          self.world_object.set_position(x, y, z)
          position_data.x = x
          position_data.y = y 
          position_data.z = z
          self.send_contained(position_data)
          connection.set_location_safe(self, self.get_location())
      else:
        return connection.grenade_exploded(self, grenade)
        
  class gtpProtocol(protocol):
    grenade_teleport = config.get('grenade_teleport', True)
    z_blocks = config.get('z_blocks', 5)
      
      
  return gtpProtocol, gtpConnection

Re: [SCRIPT] greteleport

Posted: Sat Oct 19, 2013 7:41 am
by TimeToDie
Thank you very much !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Green_Happy3 Green_BigSmile Blue_BigSmile Green_Happy1 Green_Wink1 Blue_Tongue Blue_BigSmile Green_BigSmile

Re: [SCRIPT] greteleport

Posted: Sat Oct 19, 2013 8:51 am
by Kuma
idantheking99 wrote:
Thank you very much !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Green_Happy3 Green_BigSmile Blue_BigSmile Green_Happy1 Green_Wink1 Blue_Tongue Blue_BigSmile Green_BigSmile
Your welcome

Re: [SCRIPT] greteleport

Posted: Sat Dec 14, 2013 10:29 pm
by epicfacethe3rd
Kuma wrote:
I am proud of this script. Its like a prototype for a gamemode I was planning (but i rq on that) So here it is, a script which allows you teleport where your grenade exploded.
anyone besides me see a disaster when combined with the demoman (gives you infinite ammo and grenades) script?
also, notice this?
Kuma wrote:
I am proud of this script.
hmmm.....
Image

Re: [SCRIPT] greteleport

Posted: Sat Dec 14, 2013 10:32 pm
by Zekamalikyd
epicfacethe3rd wrote:
Kuma wrote:
I am proud of this script. Its like a prototype for a gamemode I was planning (but i rq on that) So here it is, a script which allows you teleport where your grenade exploded.
anyone besides me see a disaster when combined with the demoman (gives you infinite ammo and grenades) script?
also, notice this?
also, what's wrong? you also get infinite health with the demoman script
epicfacethe3rd wrote:
Kuma wrote:
I am proud of this script.
hmmm.....
what's wrong with being proud of your work

Re: [SCRIPT] greteleport

Posted: Thu Jan 30, 2014 1:31 am
by Jdrew
when you toggle it are you toggling it for yourself or for everyone?

Re: [SCRIPT] greteleport

Posted: Thu Jan 30, 2014 12:31 pm
by Kuma
Jdrew wrote:
when you toggle it are you toggling it for yourself or for everyone?
you do it for everyone

Re: [SCRIPT] greteleport

Posted: Thu Jan 30, 2014 12:37 pm
by Jdrew
you should make it toggle for youself, then make something like /toggleall for everyone