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) async def on_player_shoot(self, player, payload): await self.spawn_sniper(player) async def on_player_hit(self, player, shooter, damage, weapon): # make player die #await self.server.broadcast_gamedata(MSG_PLAYER_DIE(player, 1)) pass async def give_stuff(self, player): # remove current weapon #await self.remove_current_weapon(player) # add sniper await self.spawn_sniper(player) async def spawn_sniper(self, player): await self.server.broadcast_gamedata(MSG_DROP_WEAPON(player, self.server.new_oid(), 6, 255).to_packet()) 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 maxdist = 2000 x = randint(-(maxdist/2), maxdist/2) y = randint(-(maxdist/2), maxdist/2) z = randint(-(maxdist/2), maxdist/2) await self.server.broadcast_gamedata(MSG_PLAYER_TELEPORT(player, x, y, z, 0).to_packet()) def setup(server): plugin = Instagib(server) server.add_plugin(plugin)