07-04-2014, 06:26 AM
How to send packets to player ?
Sorry for my bad english, I'm from Poland.
Sorry for my bad english, I'm from Poland.
Send packets to player
|
07-04-2014, 06:26 AM
How to send packets to player ?
Sorry for my bad english, I'm from Poland.
07-04-2014, 08:05 AM
Which packets and what is you're overall goal? The lua API generally isn't that low level so we can keep server state syncronised.
07-04-2014, 05:09 PM
Czesc, welcome to the forum.
We don't allow plugins to send packets because we support multiple protocol versions (from current 1.7.9 all the way down to 1.2.5) so it would be difficult for a plugin to provide all those versions. You can send most packets indirectly by doing the actions that send those packets. You want to send a player position packet? Set the player's position. You want an "update sign text" packet? Update the sign's text. Then there's the special "Plugin message" packet, that one can be sent and received by plugins directly, using cClientHandle:SendPluginMessage() function and HOOK_PLUGIN_MESSAGE hook. There's (currently) no way to register for the channels, though. If you want a working example, have a look at the WorldEdit plugin, it communicates with the WECUI client-side mod to provide visualisation for the player's selection. https://github.com/mc-server/WorldEdit/b...#L250-L276 Thanks given by: artur9010
07-05-2014, 12:19 AM
You could always use the cWorld::BroadcastX() exported functions if you feel that all players in a world need to know about something.
07-05-2014, 12:29 AM
There are only a few broadcast functions, not every packet could be sent that way. I'm thinking about actually exporting the cClientHandle sending functions, too, so that the plugins can send packets to individual players.
07-05-2014, 12:37 AM
07-05-2014, 01:27 AM
I don't think it makes sense to export the sending functions. Makes it too easy for a plugin to cause desyncs. What if a Plugin sends the update block packet?
07-05-2014, 01:34 AM
Some plugins want the client and server to desync. For example my attempt at an anti-xray plugin. It sends an update block packet(already exported) to the client making it think it's an ore. It only does this to blocks that aren't visible.
Thanks given by: LO1ZB
08-21-2014, 12:50 AM
I think we should bring this question back.
Maybe we should allow Lua to send packets if we want to support mods. (No idea what mod but I'm sure some mods add new packets) We could export the cPacketizer class. Then add a cClientHandle function called something like "SendPacket". With 2 parameters. The packet type and a callback function. pseudo-code: // The send packet function in clienthandle. void cClientHandle::SendPacket(Byte a_Packet, cLuaPacketCallback a_Callback) { m_Protocol->SendLuaPacket(a_Packet, a_Callback); } // The function that will actualy create the cPacketizer and call the Lua function. void cProtocol172::SendLuaPacket(Byte a_Packet, cLuaPacketCallback a_Callback) { cPacketizer Pkt(*this, a_Packet); a_Callback->Item(Pkt); } Thoughts??
08-21-2014, 01:11 AM
This could work with a single protocol, but it doesn't work for multiprotocol.
|
« Next Oldest | Next Newest »
|