public OnPlayerUpdate(playerid) { new Keys,ud,lr; GetPlayerKeys(playerid,Keys,ud,lr); if(MakeBoatControllable==1) { if(ud > 0) { new Float:x1, Float:y1, Float:z1; GetObjectPos(PirateShip, x1, y1, z1); new Float:x2, Float:y2, Float:z2; GetObjectPos(PirateShip, x2, y2, z2); MoveObject(PirateShip, x1+ShipMovingValue, y1, z1, ShipSpeed); MoveObject(PirateShippart, x2+ShipMovingValue, y2, z2, ShipSpeed); } else if(ud < 0) { new Float:x1, Float:y1, Float:z1; GetObjectPos(PirateShip, x1, y1, z1); new Float:x2, Float:y2, Float:z2; GetObjectPos(PirateShip, x2, y2, z2); MoveObject(PirateShip, x1-ShipMovingValue, y1, z1, ShipSpeed); MoveObject(PirateShippart, x2-ShipMovingValue, y2, z2, ShipSpeed); } else if(lr > 0) { new Float:x1, Float:y1, Float:z1; GetObjectPos(PirateShip, x1, y1, z1); new Float:x2, Float:y2, Float:z2; GetObjectPos(PirateShip, x2, y2, z2); MoveObject(PirateShip, x1, y1+ShipMovingValue, z1, ShipSpeed); MoveObject(PirateShippart, x2, y2+ShipMovingValue, z2, ShipSpeed); } else if(lr < 0) { new Float:x1, Float:y1, Float:z1; GetObjectPos(PirateShip, x1, y1, z1); new Float:x2, Float:y2, Float:z2; GetObjectPos(PirateShip, x2, y2, z2); MoveObject(PirateShip, x1, y1-ShipMovingValue, z1, ShipSpeed); MoveObject(PirateShippart, x2, y2-ShipMovingValue, z2, ShipSpeed); } } }
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { if(MakeBoatControllable==1) { if (newkeys & KEY_CROUCH) { new Float:RotX,Float:RotY,Float:RotZ; GetObjectRot(PirateShip, RotX, RotY, RotZ); new Float:RotX2,Float:RotY2,Float:RotZ2; GetObjectRot(PirateShip, RotX2, RotY2, RotZ2); SetObjectRot(PirateShip, RotX, RotY, RotZ+3); SetObjectRot(PirateShippart, RotX2, RotY2, RotZ2+3); } if (newkeys & KEY_JUMP) { new Float:RotX,Float:RotY,Float:RotZ; GetObjectRot(PirateShip, RotX, RotY, RotZ); new Float:RotX2,Float:RotY2,Float:RotZ2; GetObjectRot(PirateShip, RotX2, RotY2, RotZ2); SetObjectRot(PirateShip, RotX, RotY, RotZ-3); SetObjectRot(PirateShippart, RotX2, RotY2, RotZ2-3); } } }
If a player uses /controlboat, he will be able to move the boat with the keys . |
if(strcmp(cmd, "/controlboat", true) == 0)
{
new IsABoatDriver[MAX_PLAYERS];
IsABoatDriver[playerid] = 1;
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(IsABoatDriver[playerid] && MakeBoatControllable==1)
{
if (newkeys & KEY_CROUCH)
{
new Float:RotX,Float:RotY,Float:RotZ;
GetObjectRot(PirateShip, RotX, RotY, RotZ);
new Float:RotX2,Float:RotY2,Float:RotZ2;
GetObjectRot(PirateShip, RotX2, RotY2, RotZ2);
SetObjectRot(PirateShip, RotX, RotY, RotZ+3);
SetObjectRot(PirateShippart, RotX2, RotY2, RotZ2+3);
}
if (newkeys & KEY_JUMP)
{
new Float:RotX,Float:RotY,Float:RotZ;
GetObjectRot(PirateShip, RotX, RotY, RotZ);
new Float:RotX2,Float:RotY2,Float:RotZ2;
GetObjectRot(PirateShip, RotX2, RotY2, RotZ2);
SetObjectRot(PirateShip, RotX, RotY, RotZ-3);
SetObjectRot(PirateShippart, RotX2, RotY2, RotZ2-3);
}
}
}