I was trying to write a plugin that lets u spectate a other player.
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 :)
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 :)


