That depends. I'm not a pro in multiplayer, only started a while back too, but I think I might be able to help a bit:
All right. If you want to make your client move an entity, there is multiple ways.
two ways I know of and have sucsessfully used:
1) Every client creates an entity (his player) using ent_create. This entity is then automatically created
on the server . It's function is also run
on the server . That means that every functions that the player's function calls are run
on the server . Example:
Code:
function move_ship()
{
vec_set(temp,nullvector);
temp.z = mouse_force.x; //This is the server/host's mouse!
c_move(my,temp,nullvector,glide);
}
action player_action
{
while(1)
{
move_ship();
wait(1);
}
}
function main()
{
level_load(...);
wait(5); //wait for level to load
player = ent_create("ship.mdl",nullvector,player_action);
}
I didn't test this code.. but this is what it should do: The host does the main function on his computer, and creates an entity, on his computer. this entity runs the function and all the function that function calls on the computer. The client, however, creates an enitiy, it's function is run on the server, and all functions that are called from there also.
So, what I would do is having the move_ship function called in the main function because then it is run on all computers, and replace the "my" in move_ship by "player", because my will not point to the player on the client. then, what you can also do is getting the input from the client via move_ship, and instead of acctually moving the ship in move_ship, you save the temp vector into 3 skills of the player entity, send it to the server, and then, in the ships function (run on the server), you can call them to move the ship:
temp.x = my.skill3;
temp.y = my.skill4;
temp.z = my.skill5; // or just vec_set(temp.x, my.skill3);
c_move(my,temp...);
and do this every frame. So: overview:
Server: (note: I'm using a host, witht he command lines -cl AND -sv)
1.connects.
2.loads level
3.creates player ON SERVER and runs it's function ON SERVER... note: every client can have a "player" entity, they don't interfere with each other...
4.starts move_ship from main() function
5.saves the velocity in the skill3,4 and 5 of the player entity
6.send the vector to the server (which is the computer also)
7.server calls those skills and uses them to move the ship.
client:
1.connects.
2.loads level
3.creates player ON SERVER and runs it's function ON SERVER...
4.starts move_ship from main() function
5.saves the velocity in the skill3,4 and 5 of the player entity now using the clients mouse_force, because this function is run ON THE CLIENT, becasue it was called from within function main.
6.send the vector to the SERVER
7.SERVER calls those skills and uses them to move the ship.
you can then send the my.x and my.pan vectors to the clients, to make sure those are updated every frame, but they should acctually be updated automatically by the engine (just maybe not fast enough, and often enough, depending on your settings).
2) the other method is the dummy method. I'll cover this very fast because i've got school tomorrow and i gtg to bed^^
Here the idea is that you create the player localy, using ent_createlocal. The function of that entity is then automatically run on the client. You make it invisible. You move this entity the way you would in a single player game, for now you ignore the fact that it's acctually a multiplayer game. then you create a visible (but passable???... i dunno) entity, using ent_create at the same time as you create the first one. this one doesn't need any function at all. now, every time you move the local entity on the server, you then set the global entity's x,y,z,pan,tilt and roll to the locals x,y,z,pan,tilt and roll using vec_set. then you can send those skills to the server (although it should be set automatically). to do this I used ent_create and ent_createlocal this way:
player = ent_creatlocal(...);
player_global = ent_create(...); //player_global is a pointer I created before.
now I can set the one's parameters to the other's parametwers using:
vec_set(player_global.x, player.x);
and then the server should send all the player_global's parameters to all the other clients every frame (or so).
I sure hope this helps, and I beg anyone who finds any mistakes to correct me! I'm just new to this too...
All right... about entities: You asked which ones to create where.
Gerneally, anything created on the server is also shown on the clients. that means that if you have an ammo pack that everyone can pick up, create it on the server. anything that you only want one person to see, get them to create it using ent_createlocal. I think that should answer your question...
man... I'm tired... dead tired... and I have a test tomorrow...:)
So... hang on in there, mulitplayer feels sooo good once you've done it...
The unknowing
Micha
Btw... you're not a pain in the ass, getting the conzepts of multiplayer is
... It takes some time, yes... but i think I've sort of gotten it now. patience is the key, as with all other programming:)