29.10.2012, 00:40
pawn Код:
new lastKeyStatus[MAX_PLAYERS][2];
public OnPlayerConnect(playerid)
{
lastKeyStatus[playerid][0] = 0;
lastKeyStatus[playerid][1] = 0;
return 1;
}
public OnPlayerUpdate(playerid)
{
new keys, upDown, leftRight;
GetPlayerKeys(playerid, keys, upDown, leftRight);
if(upDown < 0)
{
// up
}
else if(upDown > 0)
{
// down
}
if(leftRight < 0)
{
// left
}
else if(leftRight > 0)
{
// right
}
if(leftRight == 0 && leftRight != lastKeyStatus[playerid][0])
{
if(leftRight < 0)
{
// left released
}
else if(leftRight > 0)
{
// right released
}
}
if(upDown == 0 && upDown != lastKeyStatus[playerid][1])
{
if(upDown < 0)
{
// up released
}
else if(upDown > 0)
{
// down released
}
}
lastKeyStatus[playerid][0] = upDown;
lastKeyStatus[playerid][1] = leftRight;
return 1;
}