Scripting help (How to spawn grenades?)

Installation support, coding tips, and general tutorials.
4 posts Page 1 of 1
Kuma
Scripter
Scripter
Posts: 758
Joined: Fri Mar 22, 2013 10:05 am


I was just making a test script, Its a script that kills you when you have placed a certain amounts of blocks. The script works fine but I want to spawn a grenade on the xyz location of the block, Is there some pyspades function for it? Also I am facing problems with @alias, whenever I add @admin to the command the alias stops working but when i remove @admin it starts working..
Code: Select all
#Kill Build script by Kuma
#Version 2.0

from commands import  alias, add, admin

ENABLE = False
BLOCKS_PLACED = 0
TOTAL_BLOCKS = 10

#@admin
@alias('kb')
def killbuild(connection):
    global ENABLE
    protocol = connection.protocol
    ENABLE = not ENABLE
    if ENABLE:
        protocol.send_chat("Kill build has been activated!")
    else:
        protocol.send_chat("Kill build has been deactivated")        

add(killbuild)

def no_building(self):
    no_build = ["NO BUILDING","NIE STROIT", "BAUE NICHT"]
    for n in xrange(len(no_build)):
        self.send_chat("   {0} {1}   ".format(n+1, no_build[n]))
    self.kill()

def blocks(self):
    global BLOCKS_PLACED, TOTAL_BLOCKS
    if BLOCKS_PLACED != TOTAL_BLOCKS-1:
        BLOCKS_PLACED = BLOCKS_PLACED + 1
        self.send_chat("Don't Build, You will die. Blocks left: {}".format(TOTAL_BLOCKS - BLOCKS_PLACED))
        return False
    elif BLOCKS_PLACED == TOTAL_BLOCKS-1:
        no_building(self)
        BLOCKS_PLACED = 0
        return False

def apply_script(protocol, connection, config):
    
    class buildConnection(connection):
        
        def on_block_build_attempt(self, x, y, z):
            global ENABLE
            if ENABLE:
                blocks(self)
            else:
                return connection.on_block_build_attempt(self, x, y, z)

        def on_line_build_attempt(self, points):
            global ENABLE
            if ENABLE:
                blocks(self)
            else:
                return connection.on_block_build_attempt(self, x, y, z)
Dr.Morphman
Scripter
Scripter
Posts: 73
Joined: Sun Feb 24, 2013 9:55 am


as far as i understood you, you simply want to create a grenade

this will require sending a grenade_packet to the players client
Code: Select all
from pyspades.server import *

        grenade_packet.player_id = # the players id  
        grenade_packet.value =  # to be honest i dont know what this means
        grenade_packet.position = # the location you want your nade spawned at
        grenade_packet.velocity = # probably 0 
        
       player.send_contained(grenade_packet)
someone please correct me if i am mistaken there
Kuma
Scripter
Scripter
Posts: 758
Joined: Fri Mar 22, 2013 10:05 am


How can I get the players ID?
VladVP
Post Demon
Post Demon
Posts: 1425
Joined: Fri Dec 14, 2012 10:48 pm


Kuma wrote:
How can I get the players ID?
Code: Select all
connection.player_id
4 posts Page 1 of 1
Return to “Help!”

Who is online

Users browsing this forum: No registered users and 1 guest