Bind key to player.
#3

Okay heres the code,

First, the keys defined under OnPlayerUpdate:
Код:
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);
	    }
    }
}
And Second, the keys defined under OnPlayerKeyStateChange:
Код:
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);
    	}
 	}
}
Reply


Messages In This Thread
Bind key to player. - by xXDaniiXx - 02.06.2011, 11:26
Respuesta: Bind key to player. - by usrb1n - 02.06.2011, 11:28
Re: Bind key to player. - by xXDaniiXx - 02.06.2011, 11:58
Respuesta: Bind key to player. - by usrb1n - 02.06.2011, 12:01
Re: Bind key to player. - by xXDaniiXx - 02.06.2011, 12:10
Respuesta: Bind key to player. - by usrb1n - 02.06.2011, 12:12
Re: Bind key to player. - by xXDaniiXx - 02.06.2011, 12:24
Respuesta: Bind key to player. - by usrb1n - 02.06.2011, 13:44

Forum Jump:


Users browsing this thread: 1 Guest(s)