adding a timer
Posted: Sun Aug 10, 2008 2:41 pm
				
				Ok, what I am wanting to do is add a timer for how long the flag is held before its either dropped from being killed or captured.  Then it will display something like "name captured the flag! (held for xx:xx)."  Ive created a cvar (flag_held) for enabling/disabling when the timer should be activated.  I have added my timer to the ClientTimerActions function in g_action.c since it is run once every second.  Here is what I have...
I set flag_held.integer to 0/1 in g_team.c when it says the client got the flag, captured the flag, or flag was dropped due to being killed.  The problem I am having is that my seconds integer isn't being incremented in g_action.c.  It shows to only be set to 1 throughout the duration of having the flag.  Also, it shows in game that the flag was held for 0:0.  I set it using this command...
Any ideas?
			Code: Select all
if ( flag_held.integer = 0 ) {
  sec = 0;
  min = 0;
}
else if { flag_held.integer = 1 ) {
  if ( sec = 59 ) {
    sec = 0;
    min += 1;
  }
  else 
    sec += 1;
}
Code: Select all
PrintMsg( NULL, "%s" S_COLOR_WHITE " captured the %s flag! (held for %i:%i)\n", cl->pers.netname, TeamName(OtherTeam(team)), sec, min);
