pyCraft icon indicating copy to clipboard operation
pyCraft copied to clipboard

Sending messages.

Open Godwhitelight opened this issue 4 years ago • 5 comments

how can i send messages as the player?

Godwhitelight avatar Jan 02 '21 21:01 Godwhitelight

If you run the file start.py from console you can type chat messages and run server commands by just starting the message with an slash.

Seadragon91 avatar Jan 02 '21 21:01 Seadragon91

If you run the file start.py from console you can type chat messages and run server commands by just starting the message with an slash.

not this way. i wanna in a line of code.

Godwhitelight avatar Jan 03 '21 07:01 Godwhitelight

i am trying to make smth that joining from alot accounts. i cant just type it i wanna smth that typeing it for me

Godwhitelight avatar Jan 03 '21 07:01 Godwhitelight

If you look at the file start.py the lines for sending a message are this:

packet = serverbound.play.ChatPacket()
packet.message = "This is a chat message"
connection.write_packet(packet)

You could create a function like this:

def send_chat_message(connection, message):
	packet = ChatPacket()
	packet.message = message
	connection.write_packet(packet)

And use it like this:

send_chat_message(connection, "One")
send_chat_message(connection, "Two")
send_chat_message(connection, "Three")
send_chat_message(connection, "This is a chat message")

Seadragon91 avatar Jan 03 '21 08:01 Seadragon91

you should close this issue if you understand

Cassy-Lee avatar Apr 22 '23 07:04 Cassy-Lee