[SCRIPT] greteleport

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


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
Attachments
greteleport.py
(2.27 KiB) Downloaded 234 times
Last edited by Kuma on Sat Oct 19, 2013 8:53 am, edited 1 time in total.
TimeToDie
Green Master Race
Green Master Race
Posts: 37
Joined: Tue Sep 17, 2013 3:52 pm


Thank you very much !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Green_Happy3 Green_BigSmile Blue_BigSmile Green_Happy1 Green_Wink1 Blue_Tongue Blue_BigSmile Green_BigSmile
Kuma
Scripter
Scripter
Posts: 758
Joined: Fri Mar 22, 2013 10:05 am


idantheking99 wrote:
Thank you very much !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Green_Happy3 Green_BigSmile Blue_BigSmile Green_Happy1 Green_Wink1 Blue_Tongue Blue_BigSmile Green_BigSmile
Your welcome
epicfacethe3rd
Deuced Up
Posts: 395
Joined: Fri Sep 27, 2013 11:07 pm


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
Zekamalikyd
Modder
Modder
Posts: 4219
Joined: Mon Apr 01, 2013 3:40 pm


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
Jdrew
Mapper
Mapper
Posts: 4808
Joined: Tue Oct 30, 2012 10:48 pm


when you toggle it are you toggling it for yourself or for everyone?
Kuma
Scripter
Scripter
Posts: 758
Joined: Fri Mar 22, 2013 10:05 am


Jdrew wrote:
when you toggle it are you toggling it for yourself or for everyone?
you do it for everyone
Jdrew
Mapper
Mapper
Posts: 4808
Joined: Tue Oct 30, 2012 10:48 pm


you should make it toggle for youself, then make something like /toggleall for everyone
8 posts Page 1 of 1 First unread post
Return to “Completed Releases”

Who is online

Users browsing this forum: No registered users and 32 guests