Sign in to follow this  
barikat

setCameraMatrix delay

Recommended Posts

Hello friends,
I have a problem. I have a little delay when I watch the player.

 

Code:

function randomSpectatePlayer() 
    local playerGroup = getElementData(localPlayer, "player:group") or false 
    if playerGroup then 
        local inGame = getElementData(localPlayer, "player:game") or false 
        for k,v in ipairs(playerGroup) do 
            if isElement(v) and getElementData(v, "player:game") and getElementData(localPlayer, "player:onSpawn") then
                if v ~= localPlayer then
                    setElementFrozen ( localPlayer, true )
                    oldDim = getElementInterior(localPlayer)
                    oldInt = getElementDimension(localPlayer)
                    setElementInterior(localPlayer, getElementInterior(v))
                    setElementDimension(localPlayer, getElementDimension(v))
                    setCameraInterior(localPlayer, getCameraInterior(v))
                    spectating = v
                    setCameraTarget ( v )
                    outputChatBox("[SPECTATE] #ffffffYou spectating now "..getPlayerName(v), 255,100,100,true)
                    outputChatBox("[SPECTATE] #ffffffIf you want back to lobby use #ff0000/back #ffffffcommand.", 255,100,100,true)
                    addCommandHandler("back", onStopSpectating)
                end
            end
        end
    end
end

 

Share this post


Link to post

Probably lag... what's the ping of the player that you are watching?

Share this post


Link to post

Well your topic talks about a function you don't even use, how ever you also should break the loop.

Edit: The delay may be caused cause loop and way you get data, you should organize more such spectator system otherwise lag will keep, is really needed  do all such things everytime you call to a random spectate target?

Edited by MisterQuestions
  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.