Got quick ( and lazy^^ ) basic MP related questions...

Posted By: rayp

Got quick ( and lazy^^ ) basic MP related questions... - 04/23/15 21:41

Hi @all!

Today its me having a "iam2lazy4google" - like question. ^^
My problem atm: have 2much work ( reallife [i need the dollar baby] ) and 2much hobbyprojects running ( 4one life grin ).

Guess since A6 came out i never played around with 3dgs mp (mp = multiplayer) again. So i have a quick and really basic question ( or two ), simply trying 2save reading / searching - time while getting some noobinfos about mp related stuff ( on the fly ).

Lets say ive such simple kind of "normal" ( means: none mp ) script:
Code:
#define distX skill100       // X - axis movement in this example

action Monster_WED(){        // applyed2 monster-ent (placed in WED)
   while (!player) wait (1); // maybe wait until player - ent was spawned
   while (my){
      my.distX  = time_step * 4; // this must be done on server site not here? right (asynchron)?
      move_mode = IGNORE_ME | IGNORE_PASSABLE | IGNORE_SPRITES;
      c_move (me, vector (my.distX, 0, 20 * time_step), nullvector, move_mode);
      if (player){ // simply face player (while moving infront)
         VECTOR _temp;
         vec_set      (_temp,  player.x); 
         vec_sub      (_temp,  my.x);
         vec_to_angle (my.pan, _temp);
      }
      wait (1);
   }
   wait        (1);
   ptr_remove (me);
}


What would i add or modify now, 2turn "Monster_WED" in2 mp - compatible action ?
As far as i know the distance / movement - vector must be calculated on server - site ? Right ? shocked


Modified version of script ( mentioned above ) would help me alot 2get the first logic in2.

Thanks for your time n tips.
Greets
Posted By: EpsiloN

Re: Got quick ( and lazy^^ ) basic MP related questions... - 04/24/15 05:16

For best results, you should run this action simultaneously on client and server and have some method to correct once in a while with the server's position...
Posted By: Reconnoiter

Re: Got quick ( and lazy^^ ) basic MP related questions... - 04/24/15 10:11

As EpsiloN you will want to run the entity both on the server and client. And every once in a while you let server update it if needed.

So first off don't forget to set dplay_localfunction to either 1 or 2 somewhere in your script (actions run on clients too), you probably don't but just to be safe. I once forgot this and was searching for bugs like a headless chicken.

Add
Code:
white(connection != 0 && my.client_id < 0) wait(1);

as your first line in the action. Or it was white(connection != 0 && my.client_id == 0) wait(1); .

Than determine what part of the code you want to run on the server only, and what on both the server and client.

And add the lines to actually send the data from server to client (send_skill, ent_sendnow, whatever you prefer).

Also a tip I once saw on this forum was to set dplay_entrate to a very high number (high dplay_entrate means a long time between updates) and use send_skill and/or ent_sendnow, so you have more control. (allowing for better interpolation, optimizing bps etc.)
Posted By: DLively

Re: Got quick ( and lazy^^ ) basic MP related questions... - 04/24/15 14:08

Awesome laugh This is very helpful indeed!
Posted By: Superku

Re: Got quick ( and lazy^^ ) basic MP related questions... - 04/24/15 14:52

@rayp: Have you seen this already: http://opserver.de/rwik9/index.php?title=Multiplayer ?
Posted By: EpsiloN

Re: Got quick ( and lazy^^ ) basic MP related questions... - 04/24/15 19:36

Or this:
Multiplayer - Basic Extensive Tutorial

laugh

But, really, it's easier to start MP, than to convert into MP...
© 2024 lite-C Forums