Jump to content

Lag while spectating players


Recommended Posts

Hello dear community. Im currently developing a game mode from scraths and recently I have found an issue which I have no idea how to fix it.

When I die and I start to spectate someone, while im seeing to other player it is very very lag. I tried with my local machine and it is still looking lagging.

 

I tried to use the following function after the vehicle is created but it doesn't work.

myVehicle = createVehicle(v,x,y,z,0,0,rz)
if setElementSyncer then
	setElementSyncer( myVehicle, false )
end

I hope u can bring me a hand to fix it.

Edited by Overkillz
Link to comment
  • MTA Anti-Cheat Team

There's some general issues with spectating players in another dimension/int and also at coordinates far away, where it only "updates" the player's position every ~ 4 seconds resulting in something similar, but with a far lower interval than in your video. (you can even reproduce this with admin panel spectate across dim+int's) I didn't yet uncover the underlying issue or get a fix for the issue I am describing, it seems related to lightsync or something over that distance + dim, but I doubt we're talking about the same thing, although it could be related.

Please show us the code of your spectator, and attach it to a command to trigger it so you can start spectating a specific player while you're still alive. Does anything in your gamemode move the dead player's position upon death, like to some centralised location far away? De-spawn them?

@Overkillz

Link to comment
  • MTA Anti-Cheat Team
26 minutes ago, MisterQuestions said:

Maybe dimensions desyc

Exactly where I was getting to, try not to move dead players to another dimention/int once they're out and the spectator starts.. until the root cause surrounding that type of desync is revealed.. let us know if that changed anything, because as I said the update interval I can see in your video doesn't look like typical cases of the issue I've seen before.

Link to comment

Well, when the players and the car is created I have set them the same dimension 11 and the same interior(0)

  • The 3rd player you see on the video isn't in the arena.
  • Objects are created in the same dimension (11)

- Outputting Vehicle Dim and Players Dim Code

function sayPVdIM()
	local players = getElementsByType("player")
	for i,player in ipairs(players) do
		local pName = getPlayerName(player)
		local pDimension = getElementDimension(player)
		local vehicle = getPedOccupiedVehicle(player)
		if vehicle then
			local vDim = getElementDimension(vehicle)
			outputChatBox(pName.."#ffffff Dim:"..pDimension.." | Vehicle Dim: "..vDim)
		else
			outputChatBox(pName.."#ffffff Dim:"..pDimension.." | Vehicle Dim: none")
		end
	end
end

- Spawning player in Vehicle Code

function spawnPlayerInVehicle(thePlayer)
	if thePlayer then
		local rSpawn = math.random(1,#arenaSpawns)
		local v,x,y,z,rz = unpack(arenaSpawns[rSpawn])
		local pDimension = getElementData(thePlayer,"aDimension")
		spawnPlayer ( thePlayer, 0.0, 0.0, 5, 90, 0,0,pDimension )
		myVehicle = createVehicle(v,x,y,z,0,0,rz)
		setElementDimension(thePlayer,pDimension)
		setElementDimension(myVehicle,pDimension)
		setElementInterior(thePlayer,0)
		setElementInterior(myVehicle,0)
	end
end

Here I have done a second video about it

Thanks for reading.

Best regards.

Edited by Overkillz
Link to comment

The issue is probably that your spectating function is probably only client sided and that is exactly the issue.

If you ( localPlayer ) spectate someone in another dimension it will look desynced.
If you ( localPlayer ) set your dimension to the spectated players dimension client sided and then spectate it will look desynced.

So the only solution is setting the localPlayers dimension server sided to the spectated players dimension and then start spectating.

Link to comment
23 hours ago, Antix said:

The issue is probably that your spectating function is probably only client sided and that is exactly the issue.

If you ( localPlayer ) spectate someone in another dimension it will look desynced.
If you ( localPlayer ) set your dimension to the spectated players dimension client sided and then spectate it will look desynced.

So the only solution is setting the localPlayers dimension server sided to the spectated players dimension and then start spectating.

I tried making the spectating on both sides Client and server and I get the same result.

 

19 hours ago, IIYAMA said:

I wonder what happens if you set the dimension of the camera element:

https://wiki.multitheftauto.com/wiki/GetCamera

(experimental)

I did it and Im still geting the same issue.

Regards,

Link to comment

EDIT: Issue fixed. It was the unfreeze function on clientside instead serverside. Thanks for ur help.

On 10/3/2018 at 19:07, Keiichi32 said:

Hi!

Why don't you use setCameraTarget?

Im using setCameraTarget

On 10/3/2018 at 21:50, MisterQuestions said:

We cant really help anymore if you dont show current code of spectating system, also may be issue regarding how do you spawnPlayers, i do have worked with various multigamemodes and never had an issue like this regarding to spectator

Yes, here it is. Btw, the issue shouldn't be on the camera target. It must be on the spawning player, vehicle or soemthing like that due to I see the rest of players too lag.

function spectateSomeoneC()
	for i,player in ipairs(cArenaPlayers) do
		if getElementData(player,"state") == "alive" then
			setCameraTarget(player)
			local cam = getCamera()
			local myDim = getElementData(localPlayer,"aDimension")
			setElementDimension(cam,myDim)
			return
		end
	end
end
addEvent( "onClientSpectateSomeone", true )
addEventHandler( "onClientSpectateSomeone", getRootElement(), spectateSomeoneC)

And here it is my spawning player and vehicle function

function spawnPlayerInVehicle(thePlayer)
	if thePlayer then
		local rSpawn = math.random(1,#arenaSpawns)
		local v,x,y,z,rz = unpack(arenaSpawns[rSpawn])
		local pDimension = getElementData(thePlayer,"aDimension")
		spawnPlayer ( thePlayer, 0, 0, 5, 90, 0,0,pDimension )
		myVehicle = createVehicle(v,x,y,z,0,0,rz)
		setElementDimension(thePlayer,pDimension)
		setElementDimension(myVehicle,pDimension)
		setElementInterior(thePlayer,0)
		setElementInterior(myVehicle,0)
		setElementFrozen(myVehicle,true)
		warpPedIntoVehicle ( thePlayer, myVehicle )
		setCameraTarget(thePlayer)
	end
end

Btw, vehicle is unfrozen clientside. I don't know if this can affect to it.

Regards.

Edited by Overkillz
Link to comment
  • Moderators

Yes, that can affect it. As freezing/unfreezing elements client-side isn't synced with other players. And even you did unfreeze it for all clients without serverside, I wouldn't know how the server would manage that.

  • Like 1
Link to comment

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...