Timer help
#1

Okay heres the deal, I made a Job Contract timer for my server, the timer is 25 minutes long, heres how many seconds it is. 1500000. However I put the job contract time in stats in this format "Job contract time left:[%d min]" and instead of telling me how many minutes they have left in their job contract it tells them how many seconds they have left. Is there anyway I can get it to tell them how many minutes they have?
Reply
#2

visit this
http://forum.sa-mp.com/index.php?topic=91713.0
it's a countdown include
Reply
#3

Nah, I want it to tell them in their stats how many minutes the have left before they can do /quitjob again.
Reply
#4

pawn Code:
stock FormatTime ( time )
{
  new count;
   
  while ( time > 60 )
  {
    time = time - 60;
    count = count + 1;
  }
   
  new string [ 256 ];
  format ( string , sizeof ( string ) , "%02d:%02d" , count , time );

  return string;
}
Takes a number (Eg. 210) and returns the string: 03:30.

Example of usage:

pawn Code:
printf ( "%s" , FormatTime ( 500 ) );
Reply
#5

try this
pawn Code:
// put this in the top of the script
new pSec[MAX_PLAYERS];
new pMin[MAX_PLAYERS];
new plSe[MAX_PLAYERS];
// Timers
new STimer[MAX_PLAYERS];

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/contract", true) == 0)
    {
      STimer[playerid] = SetTimerEx("Seconds", 1000, true, "i", playerid);
      pSec[playerid] = 1500000;
      plSe[playerid] = 60;
      pMin[playerid] = 25;
      return 1;
    }
    if(strcmp(cmdtext, "/stats", true) == 0)
    {
        new Sstr[128]; format(Sstr, 128, "Contract time left:[%d min / %d second]", pMin[playerid], plSe[playerid]);
      SendClientMessage(playerid, 0x33AA33AA, Sstr);
      return 1;
    }
    return 0;
}

forward Seconds(playerid);
public Seconds(playerid)
{
    pSec[playerid] -= 1000;
    plSe[playerid] --;
    if(plSe[playerid] == 0) { plSe[playerid] = 60; pMin[playerid] -= 1; return 1; }
    else if(pSec[playerid] == 0)
    {
      KillTimer(STimer[playerid]);
      pMin[playerid] = 0;
      pSec[playerid] = 0;
      plSe[playerid] = 0;
        // do here the function when the timer finish
      return 1;
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)