I was trying to write a plugin that lets u spectate a other player.
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 :)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | 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 |
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 :)