2019-02-19 01:01:31 +01:00
|
|
|
from giants import ChatColor
|
|
|
|
import asyncio
|
|
|
|
import struct
|
|
|
|
|
|
|
|
|
|
|
|
class Commands:
|
|
|
|
def __init__(self, server):
|
|
|
|
self.server = server
|
|
|
|
|
|
|
|
async def on_player_chat(self, player, type, team, message):
|
2019-03-05 01:30:20 +01:00
|
|
|
await self.server.broadcast_message_except(player, "%s: %s" % (player.name, message), color=ChatColor.Yellow)
|
2019-02-19 01:01:31 +01:00
|
|
|
print(message)
|
|
|
|
command = message.split(" ")
|
|
|
|
|
|
|
|
if len(command) > 1 and command[0] == "team":
|
|
|
|
newteam = command[1].replace("\x00", "")
|
|
|
|
print("Changing team of %s to %s" % (player.name, newteam))
|
2019-03-07 02:09:50 +01:00
|
|
|
await self.server.broadcast_message("%s switched to team %s using command" % (player.name, newteam))
|
2019-02-19 01:01:31 +01:00
|
|
|
await player.change_team(int(newteam))
|
|
|
|
|
|
|
|
if len(command) > 1 and command[0] == "ping":
|
|
|
|
newping = command[1].replace("\x00", "")
|
|
|
|
print("Changing ping of %s to %s" % (player.name, newping))
|
|
|
|
await self.server.broadcast_message("%s set his ping to %s" % (player.name, newping))
|
|
|
|
await player.send_ping(int(newping))
|
|
|
|
|
|
|
|
if command[0] == "ping":
|
|
|
|
print("ping function")
|
|
|
|
await self.server.broadcast_message("pong")
|
|
|
|
|
|
|
|
if command[0] == "colors":
|
|
|
|
# color codes seem to go from 01 to 0F, loop and show each value:
|
|
|
|
for i in range(1, 0xf + 1):
|
|
|
|
print("Trying value %s" % i)
|
|
|
|
await player.send_message("Color %s" % i, color=i)
|
|
|
|
await asyncio.sleep(2) # sleep between each value to see what value makes the client crash
|
|
|
|
|
|
|
|
if command[0] == "chattypes":
|
|
|
|
# type codes seem to go from 00 to 0F, loop and show each value: CRASH
|
|
|
|
for i in range(0, 0xf+1):
|
|
|
|
print("Trying value %s" % i)
|
|
|
|
await self.server.broadcast_message("Type %s" % i, type=i)
|
|
|
|
await asyncio.sleep(2) # sleep between each value to see what value makes the client crash
|
|
|
|
|
|
|
|
if command[0] == "doomchat":
|
|
|
|
# tries every value of first byte and second byte
|
|
|
|
for i in range(3,0xff+1):
|
|
|
|
for j in range(0, 0x81):
|
|
|
|
if i == 0 and j == 2:
|
|
|
|
break # ;)
|
|
|
|
message = "(%s, %s)" % (i, j)
|
|
|
|
print(message)
|
|
|
|
await player.session.send_gamedata(b"\x35" + struct.pack("<B", i)+ struct.pack("<B", j) + message.encode("utf8") + b"\x00\x00", acknow=False)
|
|
|
|
await asyncio.sleep(0.1) # sleep between each value to see what value makes the client crash
|
|
|
|
|
|
|
|
if command[0] == "die" and len(command) > 1:
|
|
|
|
diemethod = int(command[1])
|
|
|
|
await player.send_message("Death by id: %s" % diemethod)
|
|
|
|
await player.session.send_gamedata(bytes.fromhex("0b1a0000000002070000a5b0d4c35d9714c450abef354a68fb410914000000020700000402000000")+struct.pack("<L",diemethod)+bytes.fromhex("0000"))
|
|
|
|
|
2019-03-05 01:30:20 +01:00
|
|
|
if command[0] == "spawn" and len(command) > 1:
|
2019-03-05 03:58:01 +01:00
|
|
|
await self.server.broadcast_message("Spawning " + command[1] + "")
|
|
|
|
await self.server.spawn(player, 0, int(command[1]))
|
|
|
|
|
|
|
|
if command[0] == "changeme" and len(command) > 1:
|
|
|
|
await self.server.broadcast_message("Changing your model to " + command[1] + "")
|
|
|
|
await self.server.change_model(player, int(command[1]))
|
|
|
|
|
|
|
|
if command[0] == "change" and len(command) > 2:
|
|
|
|
await self.server.broadcast_message("Changing model of "+command[1]+" to "+command[2]+"")
|
|
|
|
await self.server.change_model(self.server.get_player_by_index(int(command[1])), int(command[2]))
|
2019-03-05 01:30:20 +01:00
|
|
|
|
2019-03-07 02:09:50 +01:00
|
|
|
if command[0] == "debug":
|
|
|
|
if player.opts["debug"]:
|
|
|
|
player.opts["debug"] = False
|
|
|
|
await player.send_message("Debug disabled")
|
|
|
|
else:
|
|
|
|
player.opts["debug"] = True
|
|
|
|
await player.send_message("Debug enabled")
|
|
|
|
|
2019-02-19 01:01:31 +01:00
|
|
|
|
|
|
|
def setup(server):
|
|
|
|
plugin = Commands(server)
|
|
|
|
server.add_plugin(plugin)
|