Jump to content

Ideas for a More Efficient Server

Guest n42

Recommended Posts

I'm pretty sure that right now every X milliseconds, the client sends their coordinates to the server (inefficient, but I think you've figured this out with 0.4) and the server sends it out to each client (I know it's more complicated, but for the sake of clarity leave it at that). This is rather inefficient as you can tell because not only does it take up bandwidth serverside, it takes CPU up clientside trying to draw the characters half way across the map. This isn't very necessary, and I've thought of a way around it.

I'm sure that the dev team knows their math, so I think that it'd be easier for the server to manage the coordinates. When the the server receives the coordinates from a user, it should put it in a 'memory table', where it calculates who in the server is within a three-dimensional radius of that location. This might be CPU intensive on high player servers, so if it is implemented you might want to have an option in the config file: "High CPU or high bandwidth?"

I assume that the GTA engine uses pixels for player coordinates, though I'm not absolutely certain. In any case, let's say you want the max drawing distance to be.. 1000 pixels. That's just a guess. Here's some pseudo-code:

plyr = player number;
for (int i=0; i < number of players; i++) {
 if (distance between i and plyr < 1000 && i != plyr) {
   send coordinates of i to plyr

The distance formula for three dimensions is:


You should probably even go as far as only sending the coordinates if they've changed since before. For all I know you may have already thought of this, but these are only suggestions for any future releases of MTA (0.4, woo!).

Oh, and if you haven't figured it out (which from the smooth helicopter videos, I think you did): sending only coordinates is bad and laggy. The client should assume where the player is gonna be next by sending vectors (the coordinates, direction and velocity). Not sure if you can get that info from GTA though.

By the way, thanks for makin this awesome mod. Keep up the good work! :D

Link to comment
  • 3 weeks later...
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...