Szerző Téma: body.inc  (Megtekintve 709 alkalommal)

body.inc
« Dátum: 2016. Augusztus 05. - 15:37:39 »
0 Show voters
Valakinek megvan a body.inc?

body.inc
« Válasz #1 Dátum: 2016. Augusztus 05. - 16:04:27 »
0 Show voters
Ezen a linken letöltheted. Kiderült hogy hibás a link.
 

/*
                                                                        Body Part Detection - Detect a player\'ss body part
                                                                                        By Seif
*/
/*x---------------------------------Important-------------------------------------x*/
//**INCLUDES**//
#include <a_samp>
/*x---------------------------------Defining-------------------------------------x*/
#define MAX_DISTANCE_UNIT   100.0   // maximum distance a player can shoot from
//**BODY PARTS**//
#define BODY_PART_HEAD  1
#define BODY_PART_TORSO 2
#define BODY_PART_LEGS  3
/*x---------------------------------CallBacks-------------------------------------x*/
/*
                                                                                        ---[isPlayerAimingBodyPart]---
                        »playerid: the player
                        »bodypart: the body part you want to check
                        *Return: 1 if true, 0 if false
                *-------------------------------------------------------------------*
                | Checks if the player is aiming at any player\'s certain body part.     |
                *-------------------------------------------------------------------*
*/
stock IsPlayerAimingBodyPart(playerid, bodypart)
{
        // Get the camera\'s positions
        new Float:x, Float:y, Float:z;
        new Float:vx, Float:vy, Float:vz;
        new Float:cx, Float:cy, Float:cz;
        GetPlayerCameraFrontVector(playerid, vx, vy, vz);
        GetPlayerCameraPos(playerid, cx, cy, cz);
        // Check if the player is aiming in a certain distance
        for(new Float:d; d < MAX_DISTANCE_UNIT; d += 1.5)
        {
            x = vx*d+cx;
            y = vy*d+cy;
            z = vz*d+cz;
            new Float:dist = floatsqroot((x-cx)*(x-cx)+(y-cy)*(y-cy));
                new Float:offset;
                switch (GetPlayerWeapon(playerid))
                {
                    case 24, 29, 22, 23, 25, 26, 27, 28, 32: offset = 1.1122047500310059125919013005129;
                    case 30, 31: offset = 1.07867820613690007867820613690008;
                    case 33, 34: offset = 1.0;
                }
                new Float:height;
                if (z > cz) height = z-cz;
                else height = cz-z;
                offset *= dist;
                height /= dist;
                new Float:part;
                if (bodypart == BODY_PART_HEAD) part = -0.4;
                else if (bodypart == BODY_PART_TORSO) part = 0.3;
                else if (bodypart == BODY_PART_LEGS) part = 1.0;
                z = z+offset-height+part;
            for(new i, m = GetMaxPlayers(); i < m; i++)
            {
                        if (!IsPlayerConnected(i)) continue;
                        if (playerid == i) continue;
                        if (IsPlayerInRangeOfPoint(i, 1.5, x, y, z-1.5)) return 1;
            }
        }
        return 0;
}
/*
                                                                                        ---[isPlayerAimingTargetBodyPart]---
                        »playerid: the player
                        »targetid: the target
                        »bodypart: the body part you want to check
                        *Return: 1 if true, 0 if false
                *-------------------------------------------------------------------*
                | Checks if the player is aiming at target\'s specific body part.        |
                *-------------------------------------------------------------------*
*/
stock IsPlayerAimingTargetBodyPart(playerid, targetid, bodypart)
{
        // Get the camera\'s positions
        new Float:x, Float:y, Float:z;
        new Float:vx, Float:vy, Float:vz;
        new Float:cx, Float:cy, Float:cz;
        GetPlayerCameraFrontVector(playerid, vx, vy, vz);
        GetPlayerCameraPos(playerid, cx, cy, cz);
        // Check if the player is aiming in a certain distance
        new Float:px, Float:py, Float:pz;
        GetPlayerPos(targetid, px, py, pz);
        new Float:dist = floatsqroot(((cx-px)*(cx-px)) + ((cy-py)*(cy-py)) + ((cz-pz)*(cz-pz)));
    x = vx*dist+cx;
    y = vy*dist+cy;
    z = vz*dist+cz;
    new Float:offset;
        switch (GetPlayerWeapon(playerid))
        {
            case 24, 29, 22, 23, 25, 26, 27, 28, 32: offset = 0.1122047500310059125919013005129;
            case 30, 31: offset = 0.07867820613690007867820613690008;
            case 33, 34: offset = 0.0;
        }
        new Float:height;
        if (z > cz) height = z-cz;
        else height = cz-z;
        offset *= dist;
        height /= dist;
        new Float:part;
        if (bodypart == BODY_PART_HEAD) part = -0.4;
        else if (bodypart == BODY_PART_TORSO) part = 0.3;
        else if (bodypart == BODY_PART_LEGS) part = 1.0;
        z = z+offset-height+part;
    if (IsPlayerInRangeOfPoint(targetid, 0.5, x, y, z-0.5)) return 1;
   
        return 0;
}
« Utoljára szerkesztve: 2016. Augusztus 05. - 16:11:44 írta #caysemax. »

Nem elérhető #ωᴇʙsᴛᴇʀ

  • 425
  • Aki hisz az megbocsatast nyer .. Egy jo nap
    • Profil megtekintése
body.inc
« Válasz #2 Dátum: 2016. Augusztus 05. - 17:42:51 »
0 Show voters

Nem elérhető ZyZu.

  • Globális moderátor
  • 8939
  • my turbo diesel forum
  • Discord: ZyZu.
    • Profil megtekintése
body.inc
« Válasz #3 Dátum: 2016. Augusztus 09. - 07:11:02 »
0 Show voters
[gmod]Máskor legyél szíves használni, a \'Téma megoldva\' funkciót![/gmod]

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal