Teleport doesn't work when changing world
#5
Yeah, its pretty strange. I created a test command again called /pteleport, and it has the same values as the OnEntityChangedWorld, and it works when executing it, but not here. lol

Here is the code from the portal_main.lua (well, i only included the needed information here)
function Initialize(Plugin)
	PLUGIN = Plugin
	PLUGIN:SetName("Portal")
	PLUGIN:SetVersion(1)
	
	PluginManager = cRoot:Get():GetPluginManager()
	cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_MOVING, OnPlayerMoving)
	cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_LEFT_CLICK, OnPlayerBreakingBlock)
	cPluginManager:AddHook(cPluginManager.HOOK_ENTITY_CHANGED_WORLD, OnEntityChangedWorld)
	
	PluginManager:BindCommand("/ptoggle",	"portal.create",	HandleToggleCommand,   		" - switches volume selection mode")
	PluginManager:BindCommand("/pwarp",	"portal.create",	HandleMakeWarpCommand,		" (name) - creates warp point with given name")
	PluginManager:BindCommand("/penter",	"portal.create",	HandleMakeEnterCommand,		" (name) - creates portal volume out of selection and associates it with given warp")
	PluginManager:BindCommand("/pteleport",	"",	HandlePortalCommand,		"")
	
	Plugin:AddWebTab("Portals", HandleRequest_Portals)
	
	LoadPortalsData()
	LoadPlayersData()
	LOG("Initialized " .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion())
	return true
end

function OnEntityChangedWorld(Entity, World)
	if Entity:IsPlayer() then
		if HasTeleported then
			local _name = Entity:GetName()
			local _zone = PlayersData[_name].zones

			-- doesn\'t even teleport.
			-- Even if i type in 1254, 255, 31 manually for example, it refuses
			Entity:TeleportToCoords(PortalsData.warps["".._zone].point.x, PortalsData.warps["".._zone].point.y, PortalsData.warps["".._zone].point.z)
			-- Shows the correct values of the location
			print("x: " .. PortalsData.warps["".._zone].point.x)
			print("y: " .. PortalsData.warps["".._zone].point.y)
			print("z: " .. PortalsData.warps["".._zone].point.z)
			-- Gets executed
			Entity:SendMessage("You have been teleported!")
			IsWorld = false
			HasTeleported = false
		end
	end
	return false
end

function HandlePortalCommand(Split, Player)
	local _name = Player:GetName()
	local _zone = PlayersData[_name].zones
	
	-- Ditto, does the same thing, execpt it works
	Player:TeleportToCoords(PortalsData.warps["".._zone].point.x, PortalsData.warps["".._zone].point.y, PortalsData.warps["".._zone].point.z)
	print("x: " .. PortalsData.warps["".._zone].point.x)
	print("y: " .. PortalsData.warps["".._zone].point.y)
	print("z: " .. PortalsData.warps["".._zone].point.z)
	Player:SendMessage("You have been teleported!")
	return true
end
Reply
Thanks given by:


Messages In This Thread
RE: Teleport doesn't work when changing world - by JonnyBoy0719 - 10-11-2015, 01:06 AM



Users browsing this thread: 1 Guest(s)