Game Development Community

I'm beside myself..

by Kevin Johnson · in Torque Game Engine · 07/01/2004 (7:14 pm) · 4 replies

Attempting to forward the player to another port..
in client script i have the following

schedule(0,0,"Disconnect");
   %conn = new GameConnection(ServerConnection);

   %conn.setConnectArgs($pref::Player::Name);
   %conn.setJoinPassword($Client::Password);
   %conn.connect("10.0.0.4:28005");

when i call this function it hangs..
server:
Got Connect challenge Request from IP:10.0.0.4:2191

client:
CDROP: 1375 local
Exporting server prefs...
Got Connect challenge Response

if i take the disconnect out it works but then there are 2 of me on the server, then a crash on exit. In fact if i call the function again there are 3 of me.. its kinda like that scene from the second matrix movie..

Has anyone got this working or something simular?

#1
07/01/2004 (9:24 pm)
You need to schedule the latter code, too, so that disconnect is called, THEN reconnect. Can't do it all in one code chunk.
#2
07/02/2004 (10:20 am)
Once again ben.. YOU are the man.breaking it up into two scheduled functions did the trick
ala
schedule(1000,0,"gotoNextServer");
 schedule(0,0,"Disconnect");
#3
07/02/2004 (11:23 am)
Kevin you can achieve the same results with...

schedule(0,0,"Disconnect");
schedule(0,0,"gotoNextServer");


The reason Ben said you needed to schedule the other was because the disconnect was not happening when you thought it was.


Scheduling an event for zero count does not make it happen instantly, in fact, it most likely didn't happen until the rest of the function had completed it's processing. So you were actually connecting before you disconnected.

Using a schedule basically tells the engine to do an action as close to this time as you can. In the case of a "schedule zero" that will most likely be after the current function completes.

so by running both of those as zero's should achieve the same effect provided you switch their order as I did.


Had you done an Eval, you would have gotten instant results. Had you used..

eval("disconnect();");

it would (if I understood correctly) have immediately put everything else on hold untill "disconnect" had been fully processed. An Eval can superceed all upcoming instructions.
#4
07/02/2004 (11:55 am)
I'll try eval tonite gonz thanx