How do I count the time? [SERVER] -
blackwave - 27.12.2010
Well, I think everyone already seen a counting time on a server, at least once. When a race is over, or a time between messages (avoid flood). The question is: How do I count this time? Like Showing the seconds left until the certain period is over. On Gamerx, there's a house buyable, which shows: Time left to buy 26 minutes. And the time counts, and changes
Re: How do I count the time? [SERVER] -
WillyP - 27.12.2010
Easy, use some variables to count mins&time.
Re: How do I count the time? [SERVER] -
Retardedwolf - 27.12.2010
You could use getTickCount ( ) too.
Re: How do I count the time? [SERVER] -
blackwave - 27.12.2010
Quote:
Originally Posted by [FU]Victious
Easy, use some variables to count mins&time.
|
Give me a example please. Most of counting times I've seen were like: 5.67 seconds
Код:
Player %s ended the race in %d.00 seconds
Quote:
Originally Posted by Retardedwolf
You could use getTickCount ( ) too.
|
I tried with a SetTimer together, and didn't count =S
Re: How do I count the time? [SERVER] -
Babul - 27.12.2010
GetTickCount. no doubt. it doesnt need a timer, and its only 2 or 3 commands to calculate the precise time in MS. no timer will do that more precise.
Код:
new TimeOld=GetTickCount();
//your huge code
new TimeNew=GetTickCount()-TimeOld;
Re: How do I count the time? [SERVER] -
blackwave - 27.12.2010
Dude, I just made a command:
pawn Код:
dcmd_range(playerid, params[])
{
#pragma unused params
PlayerRange(playerid);
SendClientMessage(playerid, azul, "Time is counting from now...");
SetTimer("toxic", 5000, false);
TimeOld = GetTickCount();
return 1;
}
And a callback
pawn Код:
public toxic(playerid)
{
new string[128];
TimeNew=GetTickCount()-TimeOld
format(string,sizeof(string),"The time were ran into: %f",TimeNew-TimeOld);
return SendClientMessage(playerid, color, string);
}
I tried this using a timer as "example", and showed 0.0000.. and on %d, 5761 (another example). Just give me a example of how to count this time, with a timer, and how to kill this time of keep counting =X
Re: How do I count the time? [SERVER] -
WillyP - 27.12.2010
pawn Код:
forward Round();
public Round()
{
if(GameSeconds || GameMinutes)
{
GameSeconds--;
if(GameSeconds <= -1)
{
GameMinutes--;
GameSeconds=59;
}
new TimeString[14];
format(TimeString,sizeof(TimeString),"%02d:%02d",GameMinutes,GameSeconds);
TextDrawSetString(rclock,TimeString);
if(GameMinutes == 0 && GameSeconds == 0)
{
for(new i; i < MAX_PLAYERS; i++)
{
GameTextForAll("~r~Round Ended!",5000,3);
TogglePlayerControllable(i,0);
SH = SetTimer("ShowHonours",1000,true);
KillTimer(rcount);
}
}
}
return 1;
}
Set the timer to 1second, delete the unnecessary stuff, it was from my GM. :P
Re: How do I count the time? [SERVER] - [03]Garsino - 27.12.2010
You could use something like this:
Example of usage
pawn Код:
stock GetSecondsBetweenAction(action) // By [03]Garsino
{
return floatround(floatdiv((GetTickCount() - action), 1000), floatround_tozero);
}
Re: How do I count the time? [SERVER] -
Lorenc_ - 27.12.2010
Use
pawn Код:
stock TimeConvert(seconds)
{
new tmp[16];
new minutes = floatround(seconds/60);
seconds -= minutes*60;
format(tmp, sizeof(tmp), "%d:%02d", minutes, seconds);
return tmp;
}
For counting times..
Re: How do I count the time? [SERVER] -
blackwave - 27.12.2010
Quote:
Originally Posted by [03]Garsino
You could use something like this:
Example of usage
pawn Код:
stock GetSecondsBetweenAction(action) // By [03]Garsino { return floatround(floatdiv((GetTickCount() - action), 1000), floatround_tozero); }
|
Thank you.