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

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.