Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 18,580 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Multiplayer send_var problem #96364
10/29/06 02:21
10/29/06 02:21
Joined: Sep 2006
Posts: 61
E
elfersp Offline OP
Junior Member
elfersp  Offline OP
Junior Member
E

Joined: Sep 2006
Posts: 61
Hey guys -

I don't know if I should post this in scripting or in here (or in tutorials... since my issue actually comes from a tutorial...) but anyway...

I am making a very barebones multiplayer script. The script basically just creates cbabe at a random location when you connect. This code is a stripped down version of Locoweed's MP tutorial (which I have loved other than this issue.)

So... in the code there is a spot in "main" where if you are a client, you wait for "server_says_start" to be true. In the server_called event, we set that variable to true and then do a send variable. So... the client sees:


if(connection == 2) //connection is a client
{
while (server_says_start == FALSE) // wait for server to signal ok
{
wait(1);
}
}


and the server sees:


if ((event_type == event_join) && (people_connected <= MAX_CONNECTIONS))
{
ifdef server;
people_connected += 1; // another person connected
send_var(people_connected); // send number of people connected
server_says_start = TRUE; // send it's ok to go to newest client
send_var(server_says_start); // send start message
endif; // ifdef server
}

Again, this is all from Locoweed's tutorial.

However, what I'm seeing is that if you start one host, then one client, the client is stuck in that while loop. The client somehow misses the "server_says_start" being set to true.

However, if you start a second client... that second client gets stuck in the while loop, but the first client get the send_var from the second client joining.

Isn't this strange? What am I doing wrong?

Anyone who would like to see the whole small project, it is here:
http://www.iamimmortal.com/3dgs/launch.zip

Thanks, everyone!
Paul

Last edited by elfersp; 10/29/06 02:25.
Re: Multiplayer send_var problem [Re: elfersp] #96365
10/29/06 08:35
10/29/06 08:35
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline
Serious User
Dark_samurai  Offline
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Hi elfersp,
you have to wait around one second until the client has connected the session and is able to receve variables.

Code:

if ((event_type == event_join) && (people_connected <= MAX_CONNECTIONS))
{
sleep(1);
ifdef server;
people_connected += 1; // another person connected
send_var(people_connected); // send number of people connected
server_says_start = TRUE; // send it's ok to go to newest client
send_var(server_says_start); // send start message
endif; // ifdef server
}



That should solve your problem.

Ifdef server is not necessary, because only the server has the event event_join.

Dark_samurai

Last edited by Dark_samurai; 10/29/06 08:35.

ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: Multiplayer send_var problem [Re: Dark_samurai] #96366
10/29/06 12:39
10/29/06 12:39
Joined: Sep 2006
Posts: 61
E
elfersp Offline OP
Junior Member
elfersp  Offline OP
Junior Member
E

Joined: Sep 2006
Posts: 61
Thanks, Dark_samurai!

I will try this!

Paul


Moderated by  HeelX, Spirit 

Gamestudio download | 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