This part (326-333) could be pulled into a script like PluginEnqueueMessage(packetID, player, bufferish), which also copies the contents of the bufferish (buffer or socket :P), and returns whether the packetID was found or not.