Attempting to get Bungeecord Teleportation Functional
#1
Using https://github.com/cuberite/cuberite/issues/1441 as a reference, but it seems the "hack" broke (or I just programmed it wrong), and I just learned Lua today so I have no idea where to go from here.

function Initialize(Plugin)
	Plugin:SetName("NewPlugin")
	Plugin:SetVersion(1)
	
	-- Hooks
	
	PLUGIN = Plugin -- NOTE: only needed if you want OnDisable() to use GetName() or something like that
	
	-- Command Bindings
	cPluginManager.BindCommand("/serverchange", "test.node", ServerChange, " - Description of command")
	
	
	LOG("Initialised " .. Plugin:GetName() .. " v." .. Plugin:GetVersion())
	return true
end

function ServerChange(a_Script,a_Player)
	local server = "TestServer1";
	local StringLen = server:len();
	local bytearray = ""
	for i = 1, StringLen do
		bytearray = bytearray .. "\\";
		local nextbyte = string.byte(server,i)
		local nextstring = tostring(nextbyte);
		bytearray = bytearray .. nextstring;
	end
--	cClientHandle:SendPluginMessage("BungeeCord", "\0\7Connect\0\14" .. bytearray);
	cClientHandle:SendPluginMessage("BungeeCord", "\0\7Connect\0\14TestServer1");
end

function OnDisable()
	LOG(PLUGIN:GetName() .. " is shutting down...")
end

This isn't the actual plugin, but this is a quick test one I made to see if Bungeecord Teleporting works (yes I realize I could just use /server or the slash server bungee plugin to do this exact thing, this is just a proof of concept plugin that you can do Bungee TP using Plugin Messages through Cuberite).

If you notice, I have two Plugin Message lines. The first (currently commented) spits out this error:
Code:
[22:03:45] LUA: Plugins/BungeeTest/Main.lua:29: error in function 'SendPluginMessage'.
     argument #1 is 'class cClientHandle'; 'cClientHandle' expected.

[22:03:45] Stack trace:
[22:03:45]   [C](-1): SendPluginMessage
[22:03:45]   Plugins/BungeeTest/Main.lua(29): (no name)
[22:03:45] Stack trace end
[22:03:45] Error in plugin BungeeTest calling function <callback>()
The second (currently in used) spits this error.
The Exact same thing but one line later:
Code:
[21:52:28] LUA: Plugins/BungeeTest/Main.lua:30: error in function 'SendPluginMessage'.
     argument #1 is 'class cClientHandle'; 'cClientHandle' expected.

[21:52:28] Stack trace:
[21:52:28]   [C](-1): SendPluginMessage
[21:52:28]   Plugins/BungeeTest/Main.lua(30): (no name)
[21:52:28] Stack trace end
[21:52:28] Error in plugin BungeeTest calling function <callback>()


I'm really hoping this is just me screwing up the code. If it isn't, it's probably something that only VERY few people can explain.

Edit: Just attempted converting everything to Byte (including the Connect), and it's the same error with a new line number.
Reply
Thanks given by:


Messages In This Thread
Attempting to get Bungeecord Teleportation Functional - by Zee1234 - 10-21-2015, 01:08 PM



Users browsing this thread: 1 Guest(s)