28 lines
1.0 KiB
Python
28 lines
1.0 KiB
Python
import random
|
|
import asyncio
|
|
import struct
|
|
|
|
class Greetings:
|
|
def __init__(self, server):
|
|
self.server = server
|
|
self.messages = ["Welcome %s!", "Beware! %s has arrived!", "A wild %s appears", "%s has come and is ready to pwn."]
|
|
|
|
async def on_player_join(self, player):
|
|
await self.server.broadcast_message(random.choice(self.messages) % player.name)
|
|
#await Greetings.send_ping(player)
|
|
|
|
@staticmethod
|
|
async def send_ping(player):
|
|
while 1:
|
|
for ping in range(0, 999):
|
|
await player.session.send_gamedata(b"\x2f\x02\x00\x00" + struct.pack("<H", ping) + b"\x00",acknow=True) # acknow=True
|
|
for ping in range(999, 0, -1):
|
|
await player.session.send_gamedata(b"\x2f\x02\x00\x00" + struct.pack("<H", ping) + b"\x00",acknow=True) # acknow=True
|
|
|
|
async def on_map_change(self, newmap):
|
|
await self.server.broadcast_message("You are now playing on "+newmap.mapname)
|
|
|
|
|
|
def setup(server):
|
|
plugin = Greetings(server)
|
|
server.add_plugin(plugin) |