How can i get the attributes from a weapon

whoonga

Active member
Joined
Nov 6, 2014
Messages
52
Reaction score
0
Hello,

how can i get the attributes of the weapon that the local player is holding in his hands?
I want to get the id, ammo, slot and so on..

this is what i've got, i know its wrong:
C++:
uint8_t localPlayer::getWeaponId()
{
    return g_Players->pLocalPlayer->byteCurrentWeapon;
}
 

user88

Well-known member
Joined
Jun 29, 2017
Messages
426
Reaction score
165
Location
LINK CLEO DICE HACK HERE!
if u see sobeit samp.h file

its a bitfield bytecurrentweapon : 6

instead u can use


C++:
CPed +0x5A0 = [byte] Start of weapon data (28 bytes) (See structures: WeaponSlot)
CPed +0x718 = [byte] Current weapon slot (1 byte)
CPed +0x740 = Current Weapon ID (from default.dat)


WeaponSlot                 // Total 28Bytes

DWORD       type          // + 0

DWORD       state         // + 4 (0 idle, 1 firing, 2 reloading)

DWORD       AmmoInClip    // + 8

DWORD       AmmoRemaining // +12

FLOAT       unknown       // +16 (increases each time you fire your weapon, 0 when weapon not active,

                              probably used to count bullets fired to know when to reload?)

UNKNOWN     0..7 Bytes    // +20 (unknown - goggle mode, 0 off and 256 on)...+27





DWORD CPED == *(DWORD*)0xB6F5F0;
byte ownCurrentWeaponID = *(byte*)0xBAA410;
 

_=Gigant=_

Well-known member
Joined
Mar 21, 2017
Messages
353
Reaction score
16
Hello,

how can i get the attributes of the weapon that the local player is holding in his hands?
I want to get the id, ammo, slot and so on..

this is what i've got, i know its wrong:
C++:
uint8_t localPlayer::getWeaponId()
{
    return g_Players->pLocalPlayer->byteCurrentWeapon;
}

C++:
float GetDistance(D3DXVECTOR3 target)
{
    actor_info * playerR = actor_info_get(ACTOR_SELF, NULL);

    CPed *pPedSelf = pGameInterface->GetPools()->GetPed((DWORD*)playerR);

    D3DXVECTOR3 player(pPedSelf->GetPosition()->fX, pPedSelf->GetPosition()->fY, pPedSelf->GetPosition()->fZ);
    return sqrt((player.x - target.x) * (player.x - target.x) + (player.y - target.y) * (player.y - target.y) + (player.z - target.z) * (player.z - target.z));
}

void renderPlayersInfo()
{
    traceLastFunc("renderPlayersInfo()");


    if (gta_menu_active())
        return;

    if (cheat_state->_generic.cheat_panic_enabled)
        return;

    // Exit this function and enable samp nametags, if panic key


    if (!g_dwSAMP_Addr || !g_SAMP || !g_Players)
        return;


    // don't run if the CGameSA doesn't exist
    if (!pGameInterface)
        return;

    // don't run if we don't exist
    if (isBadPtr_GTA_pPed(pPedSelf))
        return;

        if (g_Scoreboard->iIsEnabled)
            return;

        updateScoreboardData();


        for (int i = 0; i < SAMP_MAX_PLAYERS; i++)
        {
            actor_info *actor = getGTAPedFromSAMPPlayerID(i);
            struct actor_info    *self = actor_info_get(ACTOR_SELF, 0);

            if (self == NULL)
                return;

            if (!actor)
                continue;

            D3DXVECTOR3 player_pos, screenposs , my_pos, my_screen_pos;

            float * f_pos = &actor->base.matrix[4 * 3];
            player_pos.x = f_pos[0];
            player_pos.y = f_pos[1];
            player_pos.z = f_pos[2];
            CalcScreenCoors(&player_pos, &screenposs);

            float * f_posme = &self->base.matrix[4 * 3];
            my_pos.x = f_posme[0];
            my_pos.y = f_posme[1];
            my_pos.z = f_posme[2];
            CalcScreenCoors(&my_pos, &my_screen_pos);

            char pos[256], ping[256], hparmw[256], pnameid[256];

            const char * playerName = getPlayerName(i);

            if (g_Players->iIsListed[I] [/I]!= 1)
                continue;

            stRemotePlayer *pPlayer = g_SAMP->pPools->pPlayer->pRemotePlayer;

            if (screenposs.z < 1.f)
                    continue;


                if (cheat_state->3DInformer) // bool
                {

                    _snprintf_s(pnameid, sizeof(pnameid) - 1, "{C235DD}Player{FFFFFF} %s <%d>{00FF00} Distance{FFFFFF} %.0f m", playerName, i, GetDistance(D3DXVECTOR3(player_pos.x, player_pos.y, player_pos.z)));
                    pD3DFont_sampStuff->PrintShadow(screenposs.x, screenposs.y - 38, COLOR_WHITE(255), pnameid);
                    
                    for (int wep = 0; weapon_list[wep].name != nullptr; wep++)
                    {
                        const struct weapon_entry *weapon = &weapon_list[wep];

                        if (weapon->id == pPlayer->pPlayerData->onFootData.byteCurrentWeapon)
                        {
                            _snprintf_s(hparmw, sizeof(hparmw) - 1, "{FF0F0F}Health{FFFFFF} %0.0f Armour %0.0f{FFA00F} Weapon{FFFFFF} %s{FFFFFF} %u", g_Players->pRemotePlayer->pPlayerData->fActorHealth, g_Players->pRemotePlayer->pPlayerData->fActorArmor, weapon->name, g_Players->pRemotePlayer->pPlayerData->onFootData.byteCurrentWeapon);
                            pD3DFont_sampStuff->PrintShadow(screenposs.x, screenposs.y - 26, COLOR_WHITE(255), hparmw);
                        }
                    }

                    _snprintf_s(ping, sizeof(ping) - 1, "{F0FF0F}Skin{FFFFFF} %d{00FF00} Ping{FFFFFF} %d Score %d", actor->base.model_alt_id, pPlayer->iPing, pPlayer->iScore);
                    pD3DFont_sampStuff->PrintShadow(screenposs.x, screenposs.y - 14, COLOR_WHITE(255), ping);

                    _snprintf_s(pos, sizeof(pos) - 1, "Pos X %0.02f Y %0.02f Z %0.02f", player_pos.x, player_pos.y, player_pos.z);
                    pD3DFont_sampStuff->PrintShadow(screenposs.x, screenposs.y, COLOR_WHITE(255), pos);

                }
    }
}
https://i.postimg.cc/wBJctFxc/sa-mp-330.png
 
Top