2 registered members (AbrahamR, AndrewAMD),
1,278
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Locoweeds MPTut
#120115
03/29/07 19:46
03/29/07 19:46
|
Joined: Oct 2000
Posts: 113
Lawrence
OP
Member
|
OP
Member
Joined: Oct 2000
Posts: 113
|
I have been working on this tutorial. Typing in all the commands(I find I learn and understand more if I type them in myself) to the point of the first test of a connection. I have built the small world and then tried it. It is the part where it places on the screen "people connected". My problem is the server shows '2' people connected and the client machine shows '0'. Does this matter or is it correct. I would have thought at worst case the client would say '1'. I thought maybe I had typed something in wrong, so cut pasted it to make sure and still have the same problem. Is this going to cause me a problem further on in the tutorial? Lawrence
|
|
|
Re: Locoweeds MPTut
[Re: PeterM]
#120117
05/09/07 04:12
05/09/07 04:12
|
Joined: Feb 2002
Posts: 357 Florida
Zelek
Senior Member
|
Senior Member
Joined: Feb 2002
Posts: 357
Florida
|
If there was only one response to this in over a month, I guess I'm probably out of luck, but I am having this exact same issue. I spent the last couple of days re-reading the tutorial and reviewing my code to make sure I hadn't missed something, but it looks like this is an actual bug with the code. I just ran the included source code (after fixing a typo in it) and it has the same problem: the client doesn't receive information, but the host does. No variables sent via 'send_var' are ever received by the client.The thing is, when I run the Biosphere .exe included with the tutorial, it works perfectly! Does anyone know what's going on? I'll keep looking through the tutorial to see if anything's mentioned, but if the source code itself contains this problem, I'm not terribly hopeful. If anyone can point me to another simple/current/working example of multiplayer code, that would be awesome too. Thanks.
|
|
|
Re: Locoweeds MPTut
[Re: Zelek]
#120120
05/10/07 17:21
05/10/07 17:21
|
Joined: Mar 2003
Posts: 5,377 USofA
fastlane69
Senior Expert
|
Senior Expert
Joined: Mar 2003
Posts: 5,377
USofA
|
Don't use sleep(.5); use wait(-.5). Sleep is likely to get dropped from the syntax and then your back to square one Also, here is the quote from the manual: Quote:
One frame cycle after this instruction the level is loaded, two frame cycles after the instruction the local entities in the new map are created and their actions are started.
So 1/2 second is probably overkill (unless you are running at 2 FPS), but a good precaution.
PS: also note that if you ever intend to use Session_Connect(), it used to be we had to put a pause after that instruction as well but JCL hardcoded that instruction into the function. Why this isn't the same with level_load, I don't know.
|
|
|
Re: Locoweeds MPTut
[Re: fastlane69]
#120121
06/02/07 11:45
06/02/07 11:45
|
Joined: Jan 2006
Posts: 29
oriongu
Newbie
|
Newbie
Joined: Jan 2006
Posts: 29
|
I have the same problem, the wait(0.5); doesnt seem to change anything...
The vars just doesnt seem to get to the client.
This code should just show the number of people connected... but only the server shows anything.
//////////////// my code /////////////
path "Wads"; path "Sounds"; path "Models"; path "Entities"; path "Bitmaps"; path "Scripts";
font standard_font = "ackfont.pcx", 6, 9; // small text font
// --------------------------------------- Engine STRINGS string world_str = <meetrikk.wmb>; // level string string str_cbabe = <cube.mdl>; // CBabe Model
string str_people_connected; // number of people connected to server
string str_temp; // temp string
// --------------------------------------- Engine DEFINES
define MAX_CONNECTIONS, 64; // maximum number of people who can be connected to server
define FALSE, 0; define TRUE, 1;
define player_number, skill1; // player number this entity owned by define health, skill5; // health define max_health, skill6; // max health of entity
// --------------------------------------- Engine VARIABLES
var fps_max = 60; // lock fps at 60 for all players var fps_lock = ON; var video_mode = 6; // screen size 800x600 var video_screen = 2; // start settings for Fullscreen var mouse_mode = 2; // does not effect forces
// --------------------------------------- GAMES VARIABLES var people_connected = 0; // number of people connected to server var number_of_players = 0; // # of players in game var server_says_start = FALSE; // client holds creating entity until server says go
var temp_loc[3]; // temp vector var vecFrom[3]; // temp vectors var vecTo[3];
//------------------------------------------PANELS------------------
text txt_people_connected { pos_x = 15; pos_y = 15; layer = 1; font standard_font; string str_people_connected; }
// --------------------------------------- Engine MAIN
function main()
{ // if not a single player game, wait for connection ifdef server; while(connection== 0) {wait(1);} // wait until level loaded and connection set endif; ifdef client; while(connection== 0) {wait(1);} // wait until level loaded and connection set endif; level_load(world_str); // load level
wait(1); // make sure level is loaded if(connection == 2) // client? { while (server_says_start == FALSE) // wait for server to signal ok to continue { wait(1); } }
if(connection == 3){people_connected = 1;} // Compte le serveur comme un joueur if(connection != 1) // if dedicated server skip these { display_info(); // continually display any information we want to show // if not single player mode, display multiplayer information if(connection) { txt_people_connected.visible = ON; } } }
function server_called() { // if new player connected, increment people connected // and tell him it's ok to continue
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 }
// some one disconnected if (event_type == event_leave) { ifdef server; people_connected -= 1; // one less person connected to server send_var(people_connected); // send number of people connected endif; } }
function display_info() { while(1) { str_cpy(str_people_connected, "People Connected: "); str_for_num(str_temp, people_connected); str_cat(str_people_connected, str_temp); wait(1); } }
on_server = server_called; // on server event, call server_called()
Last edited by oriongu; 06/02/07 11:46.
|
|
|
Re: Locoweeds MPTut
[Re: fastlane69]
#120123
06/04/07 18:17
06/04/07 18:17
|
Joined: Jan 2006
Posts: 29
oriongu
Newbie
|
Newbie
Joined: Jan 2006
Posts: 29
|
|
|
|
|