SA-MP Forums Archive
MoveObject, Have I done this wrong? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MoveObject, Have I done this wrong? (/showthread.php?tid=305101)



MoveObject, Have I done this wrong? - AstonDA-G - 21.12.2011

Hi all, so I've been trying to make these automatic gates, and it seems to have worked, except when i want the barriers to move, they seem to 'teleport' instead of animate. Is that caused by lag, or is it not possible to actually animate them?
Video...
Here's my code.

pawn Код:
public OnPlayerUpdate(playerid)
{
    if(GetPVarInt(playerid, "Admin") != 0) {
    if(PlayerToPoint(5, playerid, 1297.25671387,-2057.27441406,58.80771637)) {
    MoveObject(Barrier1, 1297.25671387,-2064.52441406,58.80771637, 1.00, 0,0,0);
    MoveObject(Barrier2, 1297.25671387,-2050.27441406,58.8077163, 1.00, 0,0,0);
    SetTimer("BarrierTime", 7000, false);
    }
        }
    return 1;
}
public BarrierTime()
{
    MoveObject(Barrier1, 1297.25671387,-2064.52441406,58.80771637, 2.00, 270.00000000,0.00000000,0.00000000);
    MoveObject(Barrier2, 1297.25671387,-2050.27441406,58.80771637, 2.00, 90.00000000,0.00000000,0.00000000);
    return 1;
}
And if anyone knows if theres a way to stop that camera thing happening, it's because I've put an object(speaker) on the back seats, but i don't know how to fix it.
Thanks, Aston.


Re: MoveObject, Have I done this wrong? - Thresholdold - 21.12.2011

MoveObject(objectid, X, Y, Z, speed, Float:RotX, Float:RotY, Float:RotZ);

RotX, Y and Z should match your CreateObject rotations.

EDIT: Default is 1000, if left blank.


Re: MoveObject, Have I done this wrong? - AstonDA-G - 21.12.2011

They do, I copied the two createobject lines and changed the params to mach MoveObject ones, but they just don't animate when they move, it's like i've donee SetObjectPos orsomething


Re: MoveObject, Have I done this wrong? - Thresholdold - 21.12.2011

Sorry, I just finished watching the video... I would try moving your OnPlayerUpdate code somewhere else... I think because it is under OnPlayerUpdate, it is basically working every few seconds. Have you forwarded BarrierTime?


Re: MoveObject, Have I done this wrong? - Thresholdold - 21.12.2011

Oh... Try using :
pawn Код:
SetObjectRot(objectid, Float:RotX, Float:RotY, Float:RotZ);
MoveObject doesn't normally work smoothly when the rotations on each MoveObject are different.


Re: MoveObject, Have I done this wrong? - WooTFTW - 21.12.2011

Quote:
Originally Posted by Threshold
Посмотреть сообщение
Oh... Try using :
pawn Код:
SetObjectRot(objectid, Float:RotX, Float:RotY, Float:RotZ);
MoveObject doesn't normally work smoothly when the rotations on each MoveObject are different.
SetObjectRot will 'teleport' the object.


Re: MoveObject, Have I done this wrong? - Thresholdold - 21.12.2011

Unless you use MoveObject before it...


Re: MoveObject, Have I done this wrong? - Thresholdold - 21.12.2011

Try using this:
pawn Код:
public OnPlayerUpdate(playerid)
{
    if(GetPVarInt(playerid, "Admin") != 0) {
    if(PlayerToPoint(5, playerid, 1297.25671387,-2057.27441406,58.80771637)) {
    MoveObject(Barrier1, 1297.25671387,-2064.52441406,58.80771637, 1.00, 0,0,0);
    MoveObject(Barrier2, 1297.25671387,-2050.27441406,58.8077163, 1.00, 0,0,0);
    SetTimer("BarrierTime", 7000, false);
    }
        }
    return 1;
}
public BarrierTime()
{
    MoveObject(Barrier1, 1297.25671387,-2064.52441406,58.80771637, 2.00, 0,0,0);
    SetObjectRot(Barrier1, 270,0,0);
    MoveObject(Barrier2, 1297.25671387,-2050.27441406,58.80771637, 2.00, 0,0,0);
    SetObjectRot(Barrier2, 90,0,0);
    return 1;
}
Sorry for the late reply, I'm watching a movie :P

(If this doesn't work, try moving the code to somewhere other than OnPlayerUpdate)