28.08.2015, 19:50
Quote:
How can I make the player to press the key "2" (KEY_LOOK_BEHIND) I know to detect in onplayerkeystatechange.
But i want to make something like this OnPlayerEnterCheckPoint(playerid) { if(CP[playerid] == 10) { PressKeyForPlayer(playerid,KEY_LOOK_BEHIND); SendClientMessage(playerid,-1,"Key '2' was pressed for you"); } return 1; } Is this possible? |
PHP код:
/*
* native IsPlayerKeyPress(playerid, keycode);
*/
stock IsPlayerKeyPress(playerid, keycode) {
new key, updown, leftright;
GetPlayerKeys(playerid, key, updown, leftright);
//printf("PRESS player %d key %d updown %d leftright %d",playerid, key, updown, leftright);
if(key & keycode) return true;
else if(keycode == KEY_UP && updown == -128 && leftright == 0) return true;
else if(keycode == KEY_DOWN && updown == 128 && leftright == 0) return true;
else if(keycode == KEY_LEFT && updown == 0 && leftright == -128) return true;
else if(keycode == KEY_RIGHT && updown == 0 && leftright == 128) return true;
return false;
}
public OnPlayerEnterCheckPoint(playerid)
{
if(CP[playerid] == 10 && IsPlayerKeyPress(playerid, KEY_LOOK_BEHIND))
{
SendClientMessage(playerid,-1,"Key '2' was pressed for you");
return 1;
}
return 1;
}