SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 12/08/2009, 10:05 AM   #1
Oi!
Big Clucker
 
Join Date: May 2009
Posts: 104
Reputation: 5
Default Timer help

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?
Oi! is offline  
Old 12/08/2009, 10:07 AM   #2
James_Alex
Gangsta
 
Join Date: Dec 2008
Posts: 570
Reputation: 0
Default Re: Timer help

visit this
http://forum.sa-mp.com/index.php?topic=91713.0
it's a countdown include
James_Alex is offline  
Old 12/08/2009, 10:08 AM   #3
Oi!
Big Clucker
 
Join Date: May 2009
Posts: 104
Reputation: 5
Default Re: Timer help

Nah, I want it to tell them in their stats how many minutes the have left before they can do /quitjob again.
Oi! is offline  
Old 12/08/2009, 10:34 AM   #4
WrathOfGenesis
Big Clucker
 
Join Date: Apr 2008
Posts: 175
Reputation: 4
Default Re: Timer help

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 ) );
WrathOfGenesis is offline  
Old 12/08/2009, 11:24 AM   #5
James_Alex
Gangsta
 
Join Date: Dec 2008
Posts: 570
Reputation: 0
Default Re: Timer help

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;
}
James_Alex is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Timer bartje01 Help Archive 6 17/03/2010 04:43 PM
PLS help with TIMER DRIFT_HUNTER Help Archive 4 16/03/2010 03:18 PM
Timer help TouR Help Archive 21 07/12/2009 07:39 PM
C4 TIMER Frankox Help Archive 15 09/07/2009 12:21 PM
How to add this onto a timer? JoeDaDude Help Archive 5 28/05/2009 06:53 PM


All times are GMT. The time now is 10:41 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.