Jump to content

questions about creating lobby system


Bydlo

Recommended Posts

I'm trying to create a multi arena lobby server. I know the idea is to assign to each arena a certain dimension then set players to that dimension but that only solves the problem of separating the players in the physical world it doesn't separate the synchronization of players, in other words, if a map started in deathmatch arena ALL players in the server will download that map.. not only those in the arena.. players in dd or shooter for example will unnecessarily download maps from other arenas. Here is my code:

function initResource()
	
	-- Lobby
	Arenas.lobby = createElement("Arena", "lobby")
	Arenas.lobby:setData("dimension", 16)
	Arenas.lobby:setParent(g_Root)
	
	-- Deathmatch arena
	Arenas.deathmatch = createElement("Arena", "deathmatch")
	Arenas.deathmatch:setData("dimension", 0)
	Arenas.deathmatch:setParent(g_Root)

	loadMaps()
	
end
addEventHandler("onResourceStart", g_resRoot, initResource)

then when player joins the server he goes automatically to lobby:

function onJoin()
	fadeCamera(source, true)
	setCameraMatrix(source, unpack(CameraCoordenates))
	setElementParent(source, Arenas.lobby)
end
addEventHandler("onPlayerJoin", g_Root, onJoin)

Loading a map. Called from bindKey for debugging purposes.

local map = loadMapData(xmlNode, Arenas.deathmatch)

So this is the way i tried loading the map I used the server function loadMapData and set its second parameter to the deathmatch arena hoping that the map will only load for childs in the deathmatch arena element but it didn't :/ the way i knew it didn't work is simply by staying at lobby and not joining the deathmatch arena then calling the function with bindkey... the download bar appeared obviously and downloaded about one to two megabytes of data..

So i have some questions:

  1. What does the second parameter of loadMapData do?
  2. Does createObject() work the same way client side and server side? Or does the object created in client side only appears to local player?
  3. How to separate synchronization of players?
Link to comment

Thanks for the reply.

Then why does the function take a parent element at its second parameter if its gonna load the map for all players anyway? So you're suggesting working client side, that's what I thought it would be the best too but will it work though? When I create my loadMapData client version I obviously will need to use the function createObject, will that function create the object then synchronizes it for all players too or only for local player? My question applies for many similar functions like createMarker, createPed, createBlip etc...

Link to comment

Element hierarchy and parenting has nothing to do with sync, its mostly about propagation. The second parameter is simply a question of where in the element tree the map will be loaded. On the second point, everything created on the client side is only created on client, it is not synced to the server. This includes objects, vehicles, markers, peds, blips, everything.

Edited by MrTasty
Link to comment
  • 3 weeks later...

Its actually complex if you have no experience at all.

You have to generate individual maps for only certain clients on each arena (a custom map manager), individual gamemode states, etc.

Generating map in client-side will make that map load for only that client, you also have to download map files and start map scripts which is another issue.

Link to comment
17 hours ago, sanyisasha said:

Why don't download all map datas in once? Maybe in a background progress (downloadFile).
The idea is good, but if a player want to play, and have bad internet, annoying to wait until he can play. (If everybody should that's th worst).

 

He's trying to make a race multigamemode I think, downloading almost thousands of maps at the same time?! I won't recommend this idea.

Link to comment
2 hours ago, N3xT said:

He's trying to make a race multigamemode I think, downloading almost thousands of maps at the same time?! I won't recommend this idea.

Why? Better wait always minutes before game? (Meaning with low internet players, not everybody have gigabit internet :) )

  • Haha 1
Link to comment

Dude, you're talking about downloading 17GB obviously no one will join your server and download a 17GB!

also, when you're making a multigamemode you can't download the map for every single player or this gonna cause a problem the only way is to read the map objects/markers etc.. and create them client-side.

Edited by N3xT
Link to comment
1 minute ago, N3xT said:

Dude, you're talking about downloading 17GB obviously no one will join your server and download a 17GB!

Didn't said download all in the default mta downloader :D He make a progressbar somewhere, and if a player want to download in yours way, can disable it. But think a bit: you go, play something, and in the "background" the game download all files. 
Next what you will say: But man, it will cause lag. Solution: pause download when a match start.

Link to comment
Just now, sanyisasha said:

Didn't said download all in the default mta downloader :D He make a progressbar somewhere, and if a player want to download in yours way, can disable it. But think a bit: you go, play something, and in the "background" the game download all files. 
Next what you will say: But man, it will cause lag. Solution: pause download when a match start.

You could skip all of this trouble by reading the map file for the client instead of downloading them all once.

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...