Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (Konsti, AndrewAMD, 1 invisible), 1,376 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 3 1 2 3
Re: Multiplayer Concept [Re: sheefo] #94604
10/16/06 11:48
10/16/06 11:48
Joined: Jul 2006
Posts: 783
London, UK
sheefo Offline OP
User
sheefo  Offline OP
User

Joined: Jul 2006
Posts: 783
London, UK
OK, I still don't understand. I made an array and it creates all player entities first (without the player pointer) and handles them to the array. I need it so when someone joins they pick a player (for testing they pick the next player in the list) and then the "player" pointer is assigned to them and it represents them only.

I need to know how to load my levels, because there read from a files. It "level_load"'s the level then reads all entities from a file. How do I set up the level on each client? Do I just run that on the server or do I create it for every client?


BTW, debugging Multiplayer takes AGES! I need to run it with the "-sv -cl" and wait ages for it to load, then I have to run the same thing with "-cl" and wait for that to load, then usually wait until it crashes then start again. I can't get anything done

Re: Multiplayer Concept [Re: sheefo] #94605
10/16/06 18:51
10/16/06 18:51
Joined: Jul 2006
Posts: 783
London, UK
sheefo Offline OP
User
sheefo  Offline OP
User

Joined: Jul 2006
Posts: 783
London, UK
The "send_var" instruction is a load of [censored], it doesn't work at all. I tired to send it when the client doesn't exist and when the client does exist but it doesn't do anything. The client reads the variable as 0 when the server says it's 2.

I use A6.50, why doesn't it bloody work? I hate 3DGS multiplayer, it's soooo long to debug. I change one little variable to see if it works and I have to restart the server and then the client and wait till it loads.

Code:

var players_connected = 0;
////////////////////////////////////////////////////////////
// Server Event
////////////////////////////////////////////////////////////
function server_event(str)
{
if(event_type == event_join)
{
players_connected += 1;
send_var(players_connected);

return;
}
if(event_type == event_leave)
{
players_connected -= 1;
send_var(players_connected);

return;
}
}



Re: Multiplayer Concept [Re: sheefo] #94606
10/16/06 19:27
10/16/06 19:27
Joined: Jan 2003
Posts: 4,305
Damocles Offline
Expert
Damocles  Offline
Expert

Joined: Jan 2003
Posts: 4,305
you forgot to include a delay.

insert a "sleep(1)" for example.

if(event_type == event_join)
{ sleep(1); //let the client get startet
players_connected += 1;

send_var(players_connected);

return;
}


Else, you cant be shure if the client is ready to get the message.
It might have just connect to the server, but needs some preparation before receiving data.

In a multiplayersystem is is a lot about timing the send data correctly,
as sending a variable / entity does not mean that it took place right after you send it.

send_var does work, just let the client have enough time to
get working properly.

Also creating entities like bullets on the server is a bad idea.
As it takes some time, until the client create the entity,
the bullet already hit the wall.
So either give a command using send_var(player_2_makebullet)
and create a local entity on the client,

or make a couple of bullets, that are hidden somewhere, and move them by time, whenever
they get shot.

Re: Multiplayer Concept [Re: Damocles] #94607
10/16/06 21:31
10/16/06 21:31
Joined: Jul 2006
Posts: 783
London, UK
sheefo Offline OP
User
sheefo  Offline OP
User

Joined: Jul 2006
Posts: 783
London, UK
Oh yeah, it works now. But I can get my level to work in multiplayer. I get (sometimes when it doesn't completely kill the engine) an error saying something like "Invalid attempt to join "main.wmb"".

I still don't know how to create lots of players and store them to an array global to the network, then when someone joins it "ptr_for_handle"'s it and gives it the player handle, local to the client. So when I use "player" it mean YOU as a client (or server) and no one else. I can find anything in any tutorial (I looked at locoweed's tut).

BTW, my level is just a skycube and all entities are read from another file. There all "ent_create"'ed. Do I run this on all clients or just the server?

Re: Multiplayer Concept [Re: sheefo] #94608
10/17/06 02:20
10/17/06 02:20
Joined: Aug 2004
Posts: 1,305
New York
PrenceOfDarkness Offline
Serious User
PrenceOfDarkness  Offline
Serious User

Joined: Aug 2004
Posts: 1,305
New York
-_-'

how about making locoweed's level 1st... stop driving right in to wat ever you wanna make. my latest project is called test_cube. GUESS WHAT IT IS

It's a cube with the cyber babe mdl (dont ask) and i just play god with her and multiplayer. Every time i ran into a mistake I went 2 locoweed's tutorial. I will probably go back to it a few more times before I believe I have nothing left to learn from it. I went step by step, and made locoweeds level and learned ALOT.

All you questions will be answered there...

i'm not answering this question this time cuz it's already answered, in the tutorial.


"There is no problem that can't be solved with time and determination." -me
prenceofdarkness for instant messages on AIM.

Looking for a model designer
PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.
Re: Multiplayer Concept [Re: PrenceOfDarkness] #94609
10/17/06 08:31
10/17/06 08:31
Joined: Jul 2006
Posts: 783
London, UK
sheefo Offline OP
User
sheefo  Offline OP
User

Joined: Jul 2006
Posts: 783
London, UK
I've already made a test project called "multiplayer" and I try to make a working multiplayer game. So the questions I am asking are not in the tutorial, and I am working my way to what I wan't so I can LEARN and implement it in my real project.

I'm sorry to be such a pain in the ass.

The question I really need answered is:
Quote:


BTW, my level is just a skycube and all entities are read from another file. There all "ent_create"'ed. Do I run this on all clients or just the server?





Re: Multiplayer Concept [Re: sheefo] #94610
10/17/06 19:20
10/17/06 19:20
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline
Expert
Germanunkol  Offline
Expert

Joined: Jun 2006
Posts: 2,640
Earth
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:)

Last edited by Germanunkol; 10/17/06 19:40.

~"I never let school interfere with my education"~
-Mark Twain
Re: Multiplayer Concept [Re: Germanunkol] #94611
10/17/06 19:53
10/17/06 19:53
Joined: Jul 2006
Posts: 783
London, UK
sheefo Offline OP
User
sheefo  Offline OP
User

Joined: Jul 2006
Posts: 783
London, UK
Germanunkol, you don't know how much it means to me that you've taken the time to explain every step for me. I skimmed through it, I will read it properly tommorow. But thanks a lot. I am starting to understand how multiplayer works. Before (and still now)I was confused because everything was done on the server, and getting something local was complicated.

Thanks sooo much. When I finish my coursework and get some sleep and go to school, then I will get to work

Re: Multiplayer Concept [Re: sheefo] #94612
10/17/06 23:05
10/17/06 23:05
Joined: Sep 2006
Posts: 108
J
Jered Offline
Member
Jered  Offline
Member
J

Joined: Sep 2006
Posts: 108
@ Germanunkol


I didn't see any mistakes, and very nice explination of how things work.

@sheefo.

to answer your question, they were all created on the "server" and now all there functions are being done by the server. Remember though, that the more you have the server doing...the more you bogging it down as well, and the more information it has to send to all the clients to update them.


but also keep in mind that not all clients are "powerfull" machines. some are still way slow. So you have to strike a ballance between what all the server handles and what the clients will handle.


The "dummy" concept that Germanunkol is an option that is not usable in every game situation. To figure out if you need the characters to do there actions: walking, swimming...or whatever on the server or not, think about this:

is it "critical" or "not critical"? in other words if it is "critical" then you want it on the server....so no one can "cheat". if it is not critical, then let the client handle that work.

For instance, in a racing game...it is "critical" where the cars are at all times...so their movement needs to be done on the server and update on the clients. in a role playing game, where you are at, is not "truely" critiacal...so it would be ok to let the movement be done by the client and occasionaly update the server so the server can update all the other clients ( that is the "dummy" thing that Germanunkol was talking about).

You have to be carefull not to bog down your server, but also careful not to totaly bog down the client either...a ballance is needed, and that ballance is weighed by how critical something is.

So if you want the server to create all your characters, use ent_create. but if you want create it on the client only, then use ent_createlocal.


from the manual:

Ent_createlocal:

creates the entity on the local machine only. A local entity is not transmitted to the server, and thus not visible on other clients. The local entity function runs on the local machine only. Local entities can be used for advanced particle effects, player weapons or the like. In a single player system, both instructions are identical


also:
A local entities' function runs only on the client who has created it. Local entities perform collision detection, but are passable for global entities.
On a single player system, the entity function is started immediately when the entity is created. On multiplayer systems, entity functions are triggered by a server transmission, which can occur up to 0.5 seconds later. It is not determined whether the entity function is already running after this instruction, or not.



and finaly from the manual:

A level must be loaded before using these instructions. Thus they can not be called immediately at game start or on the client before it's connected to the server. In a multiplayer system, ent_create must not be used earlier than 0.5 seconds after level_load.


you can lear a lot from the manual itself best of luck to you Sheefo, hope you get this figured out, and if not keep asking....if you want to "learn" you have to ask and seek

I am a new to the whole multiplayer side as well, so we are all learning fro meach other


3DGS (6.4) Commercial
Re: Multiplayer Concept [Re: Jered] #94613
10/18/06 04:32
10/18/06 04:32
Joined: Aug 2004
Posts: 1,305
New York
PrenceOfDarkness Offline
Serious User
PrenceOfDarkness  Offline
Serious User

Joined: Aug 2004
Posts: 1,305
New York
I couldn't of put it better myself jered..


"There is no problem that can't be solved with time and determination." -me
prenceofdarkness for instant messages on AIM.

Looking for a model designer
PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.
Page 2 of 3 1 2 3

Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1