What am I doing wrong?
#1
Bug 
I was trying to write a plugin that lets u spectate a other player.
homeDir = \'Plugins/Spectate\' 

function Initialize(Plugin)
	require "posix"
	Plugin:SetName("Spectate")
	Plugin:SetVersion(1)
	PluginManager = cRoot:Get():GetPluginManager()
	PluginManager:BindCommand("/spectate","spectate.spectate",HandleSpectateCommand," - Spectate!")
	LOGINFO("Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion())
	return true;
end

function HandleSpectateCommand(Split, Player)
  time = 10
		username = Player:GetName()
		Playername = Split[2]
		_player = GetPlayerByName(Playername)
	while testzeit >= 0 do
	spectate(Player, Split)
	end
	return true
end

function GetPlayerByName( inPlayerName )
	local _player
	local PlayerSetter = function( Player )
		_player = Player
	end
	cRoot:Get():FindAndDoWithPlayer( inPlayerName, PlayerSetter )
	return _player
end

function spectate(Player, Split)
		posix.sleep(1)
		time = time - 1
		X = _player:GetPosX()
		Y = _player:GetPosY()
		Z = _player:GetPosZ()
		Y=Y+2
		Player:TeleportToCoords(X, Y, Z)
end
For the time delay I am using lua posix.
Here is my problem: For some reason the spectated player seems to stay at one place for the spectator.
I got absolutely no idea why that happens and I hope that someone can help me :)
Reply
Thanks given by:


Messages In This Thread
What am I doing wrong? - by jakibaki - 04-29-2014, 12:26 AM
RE: What am I doing wrong? - by xoft - 04-29-2014, 02:07 AM
RE: What am I doing wrong? - by worktycho - 04-29-2014, 02:18 AM
RE: What am I doing wrong? - by jakibaki - 04-29-2014, 02:22 AM
RE: What am I doing wrong? - by xoft - 04-29-2014, 05:40 AM



Users browsing this thread: 1 Guest(s)