|
|
#1 |
|
Little Clucker
![]() Join Date: Sep 2008
Posts: 2
Reputation: 0
|
Hi
I was just making my own racescript, which included 60-seconds countdown before race starts. Here's the part: RaceTimerId is the global variable. Code:
if(strcmp(cmd, "/race", true) == 0)
{
(...)
CountdownTime = 61;
RaceTimerId = SetTimer("FinalCountdown", 1000, 1);
(...)
return 1;
}
Code:
public FinalCountdown()
{
CountdownTime -= 1;
if(CountdownTime == 0)
{
SendClientMessageToAll(0xFF0000FF,"The race is starting !");
KillTimer(RaceTimerId);
}
}
So I made a few changes, tested, tested, tested, nothing. Then I discovered "timertest" gamemode and modified it a little bit. The changed version: Code:
#include <a_samp>
forward OneSecTimer();
new previous;
main()
{
print("Test");
}
public OnGameModeInit()
{
SetTimer("OneSecTimer", 1000, 1);
return 1;
}
public OneSecTimer() {
new sText[10];
if(previous != 0){
format(sText,sizeof(sText),"%d ms",GetTickCount()-previous);
print(sText);
previous = GetTickCount();
}
else{
previous = GetTickCount();
}
}
So, for me it returns ~1170 ms (interval set to 1000ms), which leads to conclusion that there is about 170ms lag. Then it's easy to calculate than if we make 60 seconds countdown in the way I did, it's going to take 60000 ms + 60 * 170 ms = 70,2 seconds. My question : is there any way to avoid the lag? I have an idea of taking the value of time we want for interval, divide it by 1.17 and set the result as interval. 1000 ms : 1.17 = 854 ms. I changed SetTimer("OneSecTimer", 1000, 1); to SetTimer("OneSecTimer", 854, 1); and results are 996ms-1002ms. If you could compile the code and run the server, we would know if the 170ms lag is constant for different computers ![]() And by the way. The same code executed on samp server v.0.2x returns ~1075ms. [post edit] Well, this may be confusing. I wrote that there is about 170ms lag, but it's only for 1000ms interval. 170ms is 0.17 of 1000ms, so the "lag multiplier" is 0.17. If I set interval to 5000ms, I get about 5850ms (5000ms * 1.17 = 5850ms). Also, I tested it under windows seven (earlier - windows xp) and lag is lower. Sorry for messing this
|
|
|
|
|
#2 |
|
Gangsta
![]() ![]() ![]() ![]() Join Date: Nov 2007
Location: Shenzhen,China
Posts: 679
Reputation: 1
|
This is interesting..., specially 1160 in 0.3a,1072ms in 0.2x server
Try pawn Code:
|
|
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How do i use settimer | jonas4334 | Help Archive | 2 | 09/04/2010 08:50 PM |
| [SetTimer] i need help | KDlivest954 | Help Archive | 8 | 01/04/2010 06:28 PM |
| [Help]Settimer | Caio_Cartaxo | Português/Portuguese | 9 | 28/03/2010 03:37 PM |
| Settimer witha settimer in it | 02manchestera | Help Archive | 2 | 07/03/2010 01:01 PM |
| SetTimer(PLAYERID,"name",interval,0); This possible?? | introzen | Help Archive | 3 | 11/03/2009 04:11 PM |