Bug MoveObject (movetime)
#1

Hey,

Most likely many of you already know of this bug, however it's still out there.

When you use: new movetime = MoveObject(...);

The movetime isn't actually the real movetime as the wiki describes.
https://sampwiki.blast.hk/wiki/MoveObject

Instead, the actual movetime is a factor 0.69 or pretty much 0.7

I've created a small script for you to test this out yourself. Please fix this in the 0.3.8. RC series or change the misleading text: "Return Values: The time it will take for the object to move in milliseconds." on the wiki page.

It's something you can work-around easily, however that's just being salmon.




Attached the script.
Reply
#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
#3

Odd it shows zeros, since I'm not having that issue.

It's been a while as for scripting, which totally made me forget about the TimerFix plugin.
That makes it 0.7 instead of 0.75 then

I still think it's being salmon, as there's a need for the plugin. I'm sure a lot of beginners will run in to this issue. It's better to fix it at the source.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)