Bug MoveObject (movetime)
#2

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
Quote:

SetTimer, SetTimerEx: Inaccurate call time.

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:
PHP Code:
#include <a_samp>
new
    
object,
    
counter,
    
time;
public 
OnFilterScriptInit( )
{
    
SetTimer"StartTest"1);
    return 
1;
}
forward StartTest( );
public 
StartTest( )
{
    
object CreateObject19460.00.00.00.00.00.0 );
    
StartMoving( );
}
StartMoving( )
{
    new 
Float:pos];
    
GetObjectPosobjectpos], pos], pos] );
    
printf"%d. Object will be moved in %dms...", ++ counterMoveObjectobjectpos], pos], pos] + ( random) + ), 0.725 ) );
    
time GetTickCount( );
}
public 
OnObjectMovedobjectid )
{
    if( 
objectid == object )
    {
        
printf("Object has finished moving in %dms.\n"GetTickCount( ) - time );
        
StopObject( object );
        
StartMoving( );
    }
    return 
1;

The output for me is
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.

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.
Reply


Messages In This Thread
Bug MoveObject (movetime) - by Baboon - 14.11.2017, 21:31
Re: Bug MoveObject (movetime) - by IstuntmanI - 14.11.2017, 22:23
Re: Bug MoveObject (movetime) - by Baboon - 14.11.2017, 22:48

Forum Jump:


Users browsing this thread: 1 Guest(s)