giantsd/plugins/instagib.py

60 lines
1.8 KiB
Python
Raw Permalink Normal View History

2019-03-13 01:37:49 +01:00
from dpnet.packet import Packet
from dpnet.gamepackets import *
from random import randint
class Instagib:
def __init__(self, server):
self.server = server
async def on_player_spawn(self, player):
await self.server.broadcast_message("%s has spawned" % player.name)
# random teleport
await self.random_teleport(player)
# give stuff
await self.give_stuff(player)
async def on_player_respawn(self, player):
await self.server.broadcast_message("%s has respawned" % player.name)
# random teleport
await self.random_teleport(player)
# give stuff
await self.give_stuff(player)
2019-03-14 01:49:16 +01:00
async def on_player_shoot(self, player, payload):
2019-03-13 01:37:49 +01:00
await self.spawn_sniper(player)
async def on_player_hit(self, player, shooter, damage, weapon):
# make player die
2019-03-14 01:49:16 +01:00
#await self.server.broadcast_gamedata(MSG_PLAYER_DIE(player, 1))
pass
2019-03-13 01:37:49 +01:00
async def give_stuff(self, player):
# remove current weapon
2019-03-14 01:49:16 +01:00
#await self.remove_current_weapon(player)
2019-03-13 01:37:49 +01:00
# add sniper
await self.spawn_sniper(player)
async def spawn_sniper(self, player):
2019-03-14 01:49:16 +01:00
await self.server.broadcast_gamedata(MSG_DROP_WEAPON(player, self.server.new_oid(), 6, 255).to_packet())
2019-03-13 01:37:49 +01:00
async def remove_current_weapon(self, player):
await self.server.broadcast_gamedata(MSG_SWITCH_WEAPON(player, 0xff).to_packet())
async def random_teleport(self, player):
# random teleport
2019-03-14 01:49:16 +01:00
maxdist = 2000
2019-03-13 01:37:49 +01:00
x = randint(-(maxdist/2), maxdist/2)
y = randint(-(maxdist/2), maxdist/2)
z = randint(-(maxdist/2), maxdist/2)
2019-03-14 01:49:16 +01:00
await self.server.broadcast_gamedata(MSG_PLAYER_TELEPORT(player, x, y, z, 0).to_packet())
2019-03-13 01:37:49 +01:00
def setup(server):
plugin = Instagib(server)
server.add_plugin(plugin)