14.11.2017, 22:23
(
Last edited by IstuntmanI; 15/11/2017 at 01:01 AM.
)
Actually, there are other problems:
1. Your code. You can improve it by simply using GetTickCount. Also, you made few weird things in it, for me it was displaying mostly zeroes.
2. Timers calls are actually delayed:
https://sampwiki.blast.hk/wiki/Bugs
As far as I know, timers are called with a delay of 25% milliseconds later.
------
How to test it exactly:
1. Install some timerfix plugin/include. For my test I used Dan's TimerFix plugin, it calls timers with a delay of +-5 milliseconds by default (can be improved further by setting "sleep" to a smaller value in server.cfg)
2. Well, for this step I don't think you need the timerfix plugin at all: Use GetTickCount directly, see this code:
The output for me is
As you can see, the difference between the return value of MoveObject and the actual object move finish is really small, which means that MoveObject is correct.
1. Your code. You can improve it by simply using GetTickCount. Also, you made few weird things in it, for me it was displaying mostly zeroes.
2. Timers calls are actually delayed:
https://sampwiki.blast.hk/wiki/Bugs
Quote:
SetTimer, SetTimerEx: Inaccurate call time. |
------
How to test it exactly:
1. Install some timerfix plugin/include. For my test I used Dan's TimerFix plugin, it calls timers with a delay of +-5 milliseconds by default (can be improved further by setting "sleep" to a smaller value in server.cfg)
2. Well, for this step I don't think you need the timerfix plugin at all: Use GetTickCount directly, see this code:
PHP Code:
#include <a_samp>
new
object,
counter,
time;
public OnFilterScriptInit( )
{
SetTimer( "StartTest", 1, 0 );
return 1;
}
forward StartTest( );
public StartTest( )
{
object = CreateObject( 1946, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 );
StartMoving( );
}
StartMoving( )
{
new Float:pos[ 3 ];
GetObjectPos( object, pos[ 0 ], pos[ 1 ], pos[ 2 ] );
printf( "%d. Object will be moved in %dms...", ++ counter, MoveObject( object, pos[ 0 ], pos[ 1 ], pos[ 2 ] + ( random( 5 ) + 1 ), 0.725 ) );
time = GetTickCount( );
}
public OnObjectMoved( objectid )
{
if( objectid == object )
{
printf("Object has finished moving in %dms.\n", GetTickCount( ) - time );
StopObject( object );
StartMoving( );
}
return 1;
}
Quote:
1. Object will be moved in 2758ms... Object has finished moving in 2763ms. 2. Object will be moved in 2758ms... Object has finished moving in 2763ms. 3. Object will be moved in 5517ms... Object has finished moving in 5521ms. 4. Object will be moved in 1379ms... Object has finished moving in 1381ms. 5. Object will be moved in 6896ms... Object has finished moving in 6901ms. 6. Object will be moved in 4137ms... Object has finished moving in 4140ms. 7. Object will be moved in 6896ms... Object has finished moving in 6899ms. 8. Object will be moved in 6896ms... Object has finished moving in 6898ms. 9. Object will be moved in 2758ms... Object has finished moving in 2759ms. 10. Object will be moved in 1379ms... Object has finished moving in 1381ms. 11. Object will be moved in 4137ms... Object has finished moving in 4140ms. |