SA-MP Forums

Go Back   SA-MP Forums > SA-MP DL Edition > SA-MP 0.3.DL

 
 
Thread Tools Display Modes
Old 14/11/2017, 10:31 PM   #1
Baboon
Banned
 
Join Date: Nov 2010
Location: The Netherlands
Posts: 918
Reputation: 348
Post Bug MoveObject (movetime)

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.
http://wiki.sa-mp.com/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.
Attached Files
File Type: pwn movetimebug.pwn (1.8 KB, 2 views)
File Type: amx movetimebug.amx (1.7 KB, 0 views)
Baboon is offline  
Old 14/11/2017, 11:23 PM   #2
IstuntmanI
High-roller
 
IstuntmanI's Avatar
 
Join Date: Mar 2009
Location: Romania
Posts: 1,802
Reputation: 375
Default Re: Bug MoveObject (movetime)

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:
http://wiki.sa-mp.com/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.
__________________



Last edited by IstuntmanI; 15/11/2017 at 02:01 AM.
IstuntmanI is offline  
Old 14/11/2017, 11:48 PM   #3
Baboon
Banned
 
Join Date: Nov 2010
Location: The Netherlands
Posts: 918
Reputation: 348
Default Re: Bug MoveObject (movetime)

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.
Baboon is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Ajuda] MoveObject Scorpion659 Português/Portuguese 11 23/04/2017 09:03 PM
[Ajuda] MoveObject - 0.3x DreyPT Português/Portuguese 6 23/02/2013 02:23 AM
MoveObject Vasu99 Server Support 3 16/04/2012 10:26 PM
Help with MoveObject Vasu99 Server Support 0 15/04/2012 01:02 PM


All times are GMT. The time now is 04:16 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.