- Регистрация
- 30 Июл 2018
- Сообщения
- 185
- Лучшие ответы
- 0
- Репутация
- 5
Вот код:
Куда будет лучше его вставить: в таймер, который вызывается каждые 50 мс. или в OnPlayerUpdate?
P.S. Вырезка из кода на FlyMode.
PHP:
new keys,ud,lr;
GetPlayerKeys(playerid,keys,ud,lr);
if(noclipdata[playerid][mode] && (GetTickCount() - noclipdata[playerid][lastmove] > 100))
{
// If the last move was > 100ms ago, process moving the object the players camera is attached to
MoveCamera(playerid);
}
// Is the players current key state different than their last keystate?
if(noclipdata[playerid][udold] != ud || noclipdata[playerid][lrold] != lr)
{
if((noclipdata[playerid][udold] != 0 || noclipdata[playerid][lrold] != 0) && ud == 0 && lr == 0)
{ // All keys have been released, stop the object the camera is attached to and reset the acceleration multiplier
StopPlayerObject(playerid, noclipdata[playerid][flyobject]);
noclipdata[playerid][mode] = 0;
noclipdata[playerid][accelmul] = 0.0;
}
else
{ // Indicates a new key has been pressed
// Get the direction the player wants to move as indicated by the keys
noclipdata[playerid][mode] = GetMoveDirectionFromKeys(ud, lr);
// Process moving the object the players camera is attached to
MoveCamera(playerid);
}
}
noclipdata[playerid][udold] = ud; noclipdata[playerid][lrold] = lr; // Store current keys pressed for comparison next update
P.S. Вырезка из кода на FlyMode.