Rotating object. -
Dan. - 24.07.2012
This code will spawn the object, and rotate it 180 degrees:
pawn Код:
CMD:object(playerid, params[])
{
new Float:XYZ[3];
GetPlayerPos(playerid, XYZ[0], XYZ[1], XYZ[2]);
Coffin[playerid] = CreateObject(2896, XYZ[0], XYZ[1], XYZ[2], 0, 0, 0, 100.0);
MoveObject(Coffin[playerid], XYZ[0], XYZ[1], XYZ[2]+0.0001, 0.0001, 0.0, 0.0, 180.0);
return 1;
}
But how to make it rotate for like 7 secs and 360 degrees? I tried changing the degree from 180 to 360, but then it wont move at all.
Re: Rotating object. -
[MM]RoXoR[FS] - 24.07.2012
UNTESTED
Will make coffin move for 7 times
pawn Код:
new objecttimer[100];
CMD:object(playerid, params[])
{
new Float:XYZ[3];
GetPlayerPos(playerid, XYZ[0], XYZ[1], XYZ[2]);
Coffin[playerid] = CreateObject(2896, XYZ[0], XYZ[1], XYZ[2], 0, 0, 0, 100.0);
new time;
time = MoveObject(Coffin[playerid], XYZ[0], XYZ[1], XYZ[2]+0.0001, 0.0001, 0.0, 0.0, 180.0);
objecttimer[Coffin[playerid]] = SetTimerEx("movecoffin",time,true,"i",playerid);
return 1;
}
forward movecoffin(playerid);
new timescoffinrotated=0;
public movecoffin(playerid)
{
++timescoffinrotated;
MoveObject(Coffin[playerid], XYZ[0], XYZ[1], XYZ[2]+0.0001, 0.0001, 0.0, 0.0, 180.0);
if( timescoffinrotated == 7) KillTimer(objecttimer[Coffin[playerid]]);
return 1;
}
Re: Rotating object. -
Dan. - 24.07.2012
I edited your code a bit, because you used X, Y, Z coordinates in the timer but they aren't global. This is my new code:
pawn Код:
CMD:object(playerid, params[])
{
new Float:XYZ[3], coffintxt[64], time;
GetPlayerPos(playerid, XYZ[0], XYZ[1], XYZ[2]);
Coffin[playerid] = CreateObject(2896, XYZ[0], XYZ[1], XYZ[2], 0, 0, 0, 100.0);
time = MoveObject(Coffin[playerid], XYZ[0], XYZ[1], XYZ[2]+0.0001, 0.0001, 0.0, 0.0, 180.0);
CoffinRotateTimer[playerid] = SetTimerEx("RotateCoffin", time, true, "ifff", playerid, XYZ[0], XYZ[1], XYZ[2]);
return 1;
}
And the timer:
pawn Код:
new CoffinRotateTime;
public RotateCoffin(playerid, x, y, z)
{
CoffinRotateTime ++;
MoveObject(Coffin[playerid], x, y, z+0.0001, 0.0001, 0.0, 0.0, 180.0);
if(CoffinRotateTime == 7)
{
KillTimer(CoffinRotateTimer[playerid]);
CoffinRotateTime = 0;
}
return 1;
}
But the coffin will rotate only once.. I think the problem is, when setting the timer, the time is "MoveObject" line what you gave me, how to fix this? The timer should execute when the MoveObject line finishes moving.