SA-MP Forums Archive
Fighting - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Fighting (/showthread.php?tid=511110)



Fighting - kevin1990 - 04.05.2014

Ok,

I have a really good idea in mind and was wondering if someone could tell me where to start. I want to make an extensive fighting system. Hand to hand combat like UFC. Is there anyone to achieve this? If so, where would I begin, Can I get some example codes?


Re: Fighting - Dignity - 04.05.2014

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
}



Re: Fighting - superrobot48 - 04.05.2014

First add variables like,
pawn Код:
IsPlayerFighting[MAX_PLAYERS];
To check if player is fighting and to block player commands while fighting.
then .
when player /fight . i'll just tp them to the place they will fight(like A Ring)
and under the command i'll
pawn Код:
IsPlayerFighting = 0;
and OnPlayerDeath
check if player is dead
like
pawn Код:
IsPlayerFighting == 1 // checking if player in fight
and give the killer id some money and score :P
.
For this "extensive"
just add on
OnPlayerTakeDamage and all