Game Development Community

Delay timer

by mb · in Torque Game Engine · 10/06/2006 (6:52 pm) · 5 replies

I'm trying to create a delay timer to basically wait 10 seconds or whatever then do something. i was looking in $Sim::Time and wasnt having much luck. whats the best way to do this?

thanks in advance

#1
10/06/2006 (7:40 pm)
Use Schedule

schedule(10000, 0, "doSomething");
#2
10/07/2006 (7:31 am)
Thanks!
#3
10/07/2006 (9:20 am)
When i try to use schedule from a serverCmd in command.cs it cant find the function I'm calling. this is all being called from a gui btw. (teamplay tutorial)



function serverCmdJoinTeam(%client, %teamid)
{
schedule(1000, 0, joinTeam, %this, %teamid);
}


in console it will say:

joinTeam : Unknown command.

but this works (without schedule):


function serverCmdJoinTeam(%client, %teamid)
{
%client.joinTeam(%teamid);
}



I've gotten it to work without client/server commands but i don't think its the proper way to do it... so i'm wondering how can i call that function using schedule in commands.cs? I cant seem to get it in scope.

the function looks like this in game.cs:
function GameConnection::joinTeam(%this, %teamid)
#4
10/07/2006 (10:36 am)
Use:

%client.schedule(1000, "jointeam", %teamid)
#5
10/07/2006 (11:41 am)
I couldnt ever get %client.schedule to work but I did get it working, so thanks :D

i ended up calling another function in TeamSelectDlg.cs like so:

function suicideJoinTeam(%teamid)
{
commandtoserver('Suicide');
schedule(10000,0,jointeam,%teamid);
Canvas.popDialog(TeamSelectDlg);
//Hide the dialog once selection was made
}

function jointeam(%teamid)
{
commandtoserver('JoinTeam', %teamid);
//Canvas.popDialog(TeamSelectDlg);
//Hide the dialog once selection was made
}