Jump to content

Pros and cons of loading objects clientside/serverside?


RizoN

Recommended Posts

Hello there.

I'm having a dilemma about this.

Is it better to create all elements(like objects) on client side, or server side?

Of course, there are lot of things which could determine which option is better. 

Pros of client-side
1. Creating thousands of objects on client-side is far better than on server-side (example: DM Maps)
2. Good for gamemodes which don't require too much sync

Cons of client-side
1. Vehicles, peds, breakable objects aren't that well synced as if they would be on server-side
2. Security issues (everything on client side could be manipulated into malicious client's will)
3. Maps could be stolen


Pros of server-side
1. Great sync for vehicles, peds, breakable objects
2. Clients cannot manipulate or steal server-sided elements by themselves
 

Cons of server-side
1. Huge performance impact when dealing with lot of elements(objects, vehicles)
2. Makes server laggy after some time
 

So, what do you think?
Is it better to sacrifice security for better loading or should the server handle it?
Should map loading type be based on gamemode/what we're loading?
Any better ideas?

Thanks for reading
I would appreciate if someone with experience could reply to this topic.

Link to comment
22 minutes ago, RizoN said:

1. Huge performance impact when dealing with lot of elements(objects, vehicles)

This is the most important point you should consider, since the performance of the server matters alot. I know an idea about having the map's on client sided. You can convert your maps to lua form using something like this and then use any client file protecting way for example the most common, 'cache=false' attribute in the meta. However this does not fully protect your files but there are many other tutorials by forum members, you can go look for them. :)

Link to comment
7 minutes ago, Gravestone said:

This is the most important point you should consider, since the performance of the server matters alot. I know an idea about having the map's on client sided. You can convert your maps to lua form using something like this and then use any client file protecting way for example the most common, 'cache=false' attribute in the meta. However this does not fully protect your files but there are many other tutorials by forum members, you can go look for them. :)

Thanks for replying,
I am already extracting XML data from .map files and placing it inside of a Lua table containing all elements. Using external convertor is a much slower method of achieving this, and in case of the website being offline/having bugs, I wouldn't be able to do anything about it. The maps when transferred to client are already in his computer's memory and are deleted when all necessary elements(objects, vehicles, etc) are created.

Link to comment
1 minute ago, RizoN said:

Thanks for replying,
I am already extracting XML data from .map files and placing it inside of a Lua table containing all elements. Using external convertor is a much slower method of achieving this, and in case of the website being offline/having bugs, I wouldn't be able to do anything about it. The maps when transferred to client are already in his computer's memory and are deleted when all necessary elements(objects, vehicles, etc) are created.

Are you sure? The website is online for me.

Link to comment

It really depends: Are you making a multigamemode? If so, go for client side because if you do it on server side, you will load map for every player in the server, which is not good. On the other hand, if you want to load a map for all players in the server, you should go for server side.

Link to comment
49 minutes ago, Gravestone said:

Are you sure? The website is online for me.

You've misread my post. I said: in case of being offline, I haven't said that it's offline :P
 

48 minutes ago, GTX said:

It really depends: Are you making a multigamemode? If so, go for client side because if you do it on server side, you will load map for every player in the server, which is not good. On the other hand, if you want to load a map for all players in the server, you should go for server side.

Thanks for replying,
What about the security issues? Maps could be stolen this way

Also, another question popped in my head. Which way would be recommended to download maps? (I believe you have experience with this)
There are couple of things that get transferred from a custom maploader to client
1. Map settings (extracted from .map file) (is sending this to a client via triggerClientEvent bad?)
2. Map files(sounds, mods) (would downloadFile be fine, or do i need to download it from a server via fetchRemote? there's also latent events, but I hear they're bad impact on server when lots of players)

I hope you or somebody else could give me a clear thought about this, since I'm not really sure anymore which is the best way.

Link to comment

Well, only people with experience in networking could steal maps if you use triggerLatentClientEvent (not triggerClientEvent, in latent event other network traffic isn't blocked while the data is being transfered). You could even encrypt data if you'd like. FetchRemote is definitely faster but it's not secure. I'd suggest to compress map data and send it through triggerLatentClientEvent (so you don't need to worry about security much) and files through fetchRemote (that's what I use).

So, you have three options:

  1. Go for fetchRemote on both (in terms of security, this is bad, but in terms of speed, it's faster than latent event, especially if you use Gzip compression)
  2. Go for latent event on both (in terms of speed, this is slow and is bad when all players download at the same time, but in terms of security, I think you're good to go)
  3. Use latent events and for files use fetchRemote (which are usually bigger than map and you usually don't need to protect them)

It's up to you.

If someone finds any other (better) way, let me know.

Edited by GTX
  • Like 1
Link to comment

Thank you for explaining this to me. Could you please tell me why is fetchRemote so insecure as you are saying?
Also I don't really know how to use that compression thing which you were saying (if you got the time could you shortly introduce me to it?)

Link to comment

Compile and Create a backdoor for yourself for example;

You set a root element data like

setElementData(root, "mapSecure", "randomCodes") and then in your every map put a check on very top before your main script if the elment data is right otherwise return false and not loading the maps.

Eg: 

if getElementData(root, "mapSecure") ~= "randomCodes" then return false end

--rest of the codes---

Link to comment
3 hours ago, NeverGiveup said:

Compile and Create a backdoor for yourself for example;

You set a root element data like

setElementData(root, "mapSecure", "randomCodes") and then in your every map put a check on very top before your main script if the elment data is right otherwise return false and not loading the maps.

Eg: 

if getElementData(root, "mapSecure") ~= "randomCodes" then return false end

--rest of the codes---

Could you please explain what is this useful for? I don't think there's a need for this since everything here is happening at server-side, and using root on setElementData is a little bit inefficient, don't you think? :P

Link to comment
12 hours ago, RizoN said:

Could you please explain what is this useful for? I don't think there's a need for this since everything here is happening at server-side, and using root on setElementData is a little bit inefficient, don't you think? :P

https://github.com/nokizorque/GTI-source-2014/tree/master/[Maps]/GTImapConverter

I thougjt you gonna make it clientside, i  usually convert my map file to lua using the res above then i put the security code and then compile it. Once you check the security code and it returns false then the map wont be loaded

Edited by NeverGiveup
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...