There's plenty of ways.
You could make a system that checks if player A is facing player B. If player A presses a
button, player B gets a
message on their screen, telling them to press a specific button. They'll have 1-2 seconds to press it.
If they fail to press it, put them in an anim or do whatever you have planned. If they manage to press it, rebound the attack or allow player B to retaliate? Something like that but I guess it kind of sums up what you're trying to achieve?
To do this, I suggest looking in to
this script and taking the function that shows the random key and checking if that specific key is pressed. I already have the IsPlayerAimingAtPlayer function for you:
pawn Код:
stock IsPlayerAiming(playerid, aimid)
{
new Float:X1, Float:Y1, Float:Z1, Float:X2, Float:Y2, Float:Z2;
GetPlayerPos(playerid, X1, Y1, Z1);
GetPlayerPos(aimid, X2, Y2, Z2);
new Float:Distance = floatsqroot(floatpower(floatabs(X1-X2), 2) + floatpower(floatabs(Y1-Y2), 2));
if(Distance < 100)
{
new Float:A;
GetPlayerFacingAngle(playerid, A);
X1 += (Distance * floatsin(-A, degrees));
Y1 += (Distance * floatcos(-A, degrees));
Distance = floatsqroot(floatpower(floatabs(X1-X2), 2) + floatpower(floatabs(Y1-Y2), 2));
if(Distance < 0.5)
{
return true;
}
}
return false;
}
stock IsPlayerLookingAtPlayer(player1, player2)
{ // Simon edited by Carlton
if (!IsPlayerConnected(player1) || !IsPlayerConnected(player2)) return 0;
if(player1 == player2) return 0;
new
Float: distance,
Float: vectorX,
Float: vectorY,
Float: vectorZ,
Float: plyrPos[2][3],
Float: projPos[3];
GetPlayerCameraFrontVector(player1, vectorX, vectorY, vectorZ);
GetPlayerCameraPos(player1, plyrPos[0][0], plyrPos[0][1], plyrPos[0][2]);
GetPlayerPos(player2, plyrPos[1][0], plyrPos[1][1], plyrPos[1][2]);
#define SQUARE(%1) ((%1)*(%1))
distance = floatsqroot(
SQUARE(plyrPos[1][0]-plyrPos[0][0]) + SQUARE(plyrPos[1][1]-plyrPos[0][1]) + SQUARE(plyrPos[1][2]-plyrPos[0][2]));
projPos[0] = plyrPos[0][0] + vectorX * distance;
projPos[1] = plyrPos[0][1] + vectorY * distance;
projPos[2] = plyrPos[0][2] + vectorZ * distance;
return ((SQUARE(plyrPos[1][0]-projPos[0]) + SQUARE(plyrPos[1][1]-projPos[1]) + SQUARE(plyrPos[1][2]-projPos[2])) <= SQUARE(distance / 6));
#undef SQUARE
}