A timer question :|
#9

Well, firstly, you would need to get the textdraw info using the link that Mansonh posted, it should look something like:

pawn Код:
new Text:Textdraw0;
// In OnGameModeInit prefferably, we procced to create our textdraws:
Textdraw0 = TextDrawCreate(17.000000, 429.000000, "Timeleft: 432423");
TextDrawBackgroundColor(Textdraw0, 65535);
TextDrawFont(Textdraw0, 1);
TextDrawLetterSize(Textdraw0, 0.500000, 1.000000);
TextDrawColor(Textdraw0, 16777215);
TextDrawSetOutline(Textdraw0, 1);
TextDrawSetProportional(Textdraw0, 1);
Now, what we do from here is add the timer.

pawn Код:
new Timer;
new TimeM, TimeS;
public OnPlayerEnterCheckpoint(playerid)
{
  //your textdraw stuff
  Timer = SetTimer("UpdateTD",1000, true);
  TimeM = 0/*However many minutes you want the timer to go for*/;
  TimeS = 30/*However many seconds you want the timer to go for*/;
  return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
  KillTimer(Timer);
  TextDrawHideForAll(Textdraw0);
  //Kill the timer because the player exited the CP.
  return 1;
}

forward UpdateTD();
public UpdateTD()
{
  TimeS --;
  if(TimeS == 0 && TimeM == 0)
  {
    //The player has been in the CP long enough, the round ends?
  }
  new Str[35];
  if(TimeS < 10) format(Str, 35, "%d:0%d", TimeM, TimeS);
  if(TimeS > 9) format(Str, 35, "%d:%d", TimeM, TimeS);
  TextDrawSetString(Textdraw0, Str);
  return 1;
}

Reply


Messages In This Thread
A timer question :| - by [Bm]rap45 - 13.02.2010, 06:30
Re: A timer question :| - by [HiC]TheKiller - 13.02.2010, 06:36
Re: A timer question :| - by [Bm]rap45 - 13.02.2010, 06:53
Re: A timer question :| - by mansonh - 13.02.2010, 07:21
Re: A timer question :| - by [Bm]rap45 - 13.02.2010, 07:24
Re: A timer question :| - by mansonh - 13.02.2010, 07:34
Re: A timer question :| - by [Bm]rap45 - 13.02.2010, 07:41
Re: A timer question :| - by mansonh - 13.02.2010, 07:43
Re: A timer question :| - by [HiC]TheKiller - 13.02.2010, 08:50
Re: A timer question :| - by [Bm]rap45 - 13.02.2010, 09:07

Forum Jump:


Users browsing this thread: 3 Guest(s)