I was writing a piece of script for driving wheelchairs.
I thought to create the object, apply an animation to the player to make him sitting, and then moving the object and the player at the same time.
Then I realised it was easier attaching the object to the player, so I did.
I added a few timers for moving the player. It worked, but it's a little bit jerky.
Код:
if (strcmp("/wheelchair", cmdtext, true, 10) == 0)
{
new Float:OffsetX,Float:OffsetY,Float:OffsetZ;
new Float:rZ;
GetPlayerPos(playerid, OffsetX, OffsetY, OffsetZ);
GetPlayerFacingAngle(playerid, rZ);
Wheelchair[playerid] = CreateObject(1369, OffsetX, OffsetY, OffsetZ-0.5, 0.00, 0.00, 0.00);
AttachObjectToPlayer(Wheelchair[playerid], playerid, 0.0, -0.5, -0.5, 0.0, 0.0, 180);
ApplyAnimation(playerid,"PED","SEAT_idle",4.0,1,0,0,1,1);
return 1;
}
public OnPlayerUpdate(playerid)
{
new Keys,ud,lr;
GetPlayerKeys(playerid,Keys,ud,lr);
if(ud < 0) //UP
{
TimerForward = SetTimerEx("MoveWheelchairForward",100,0,"i",playerid);
return 1;
}
else if(ud > 0) //DOWN
{
TimerBack = SetTimerEx("MoveWheelchairBack",30,0,"i",playerid);
return 1;
}
}
public MoveWheelchairForward(playerid)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
GetXYInFrontOfPlayer(playerid, x, y, 0.3);
SetPlayerPos(playerid, x, y, z);
return 1;
}
public MoveWheelchairBack(playerid)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
GetXYBehindPlayer(playerid, x, y, 0.2);
SetPlayerPos(playerid, x, y, z);
return 1;
}
I tried a few values in milliseconds for the timer in MoveWheelchairForward and Back.
You can bump only after 42 hours or something if needed and not getting any possible answer, so please don't and be patient you'll get answer.