Jump to content

About This File

This resource adds wrappers for these natives:

  • GET_TATTOO_SHOP_DLC_ITEM_DATA
  • GET_SHOP_PED_COMPONENT
  • GET_SHOP_PED_PROP
  • GET_DLC_WEAPON_DATA
  • GET_DLC_WEAPON_COMPONENT_DATA
  • GET_PED_HEAD_BLEND_DATA
  • GET_WEAPON_HUD_STATS
  • GET_WEAPON_COMPONENT_HUD_STATS
  • GET_DLC_VEHICLE_DATA
  • GET_SHOP_PED_OUTFIT
  • GET_SHOP_PED_OUTFIT_PROP_VARIANT
  • GET_SHOP_PED_OUTFIT_COMPONENT_VARIANT

Before 1.1.0, you couldn't use these natives because they needed pointers to their respective structures but since 1.1 allows developers to use ArrayBuffers, that is no longer a problem. Thing is, you still need to create a buffer, invoke the native and read the data from your buffer. (too much work)

This resource is made to prevent that.

 

Installing

Put gamedata into your server's client_packages directory, then add require('gamedata'); to client_packages/index.js.

 

Clientside API

This resource extends "mp.game" by adding a "data" object that contains multiple functions.

/*
    Returns information about a decoration/tattoo.

    characterType:
    * 0 = Michael
    * 1 = Franklin
    * 2 = Trevor
    * 3 = MPMale
    * 4 = MPFemale
    
    decorationIndex:
    * Decoration/tattoo index between 0 and GET_NUM_TATTOO_SHOP_DLC_ITEMS(characterType).
    
    Returned object:
    * { lockHash, id, collection, preset, cost, eFacing, updateGroup, textLabel }
    
    This native was researched & documented by TomGrobbe. (https://github.com/TomGrobbe)
*/
mp.game.data.getTattooShopDlcItemData(characterType, decorationIndex);

/*
    Returns information about a clothing item.
    
    componentHash:
    * Obtained by GET_HASH_NAME_FOR_COMPONENT.
    
    Returned object:
    * { lockHash, uniqueNameHash, locate, drawableIndex, textureIndex, cost, eCompType, eShopEnum, eCharacter, textLabel }
*/
mp.game.data.getShopPedComponent(componentHash);

/*
    Returns information about a clothing item. (prop)
    
    propHash:
    * Obtained by GET_HASH_NAME_FOR_PROP.
    
    Returned object:
    * { lockHash, uniqueNameHash, locate, propIndex, textureIndex, cost, eAnchorPoint, eShopEnum, eCharacter, textLabel }
*/
mp.game.data.getShopPedProp(propHash);

/*
    Returns information about a ped's headblend data.
    
    entityOrHandle:
    * Entity (mp.players.local) or handle (mp.players.local.handle) of the ped you want to get headblend data of.
    
    Returned object:
    * { shapeFirstId, shapeSecondId, shapeThirdId, skinFirstId, skinSecondId, skinThirdId, shapeMix, skinMix, thirdMix, isParent }
*/
mp.game.data.getPedHeadBlendData(entityOrHandle);

/*
    Returns information about a weapon's HUD stats.
    
    weaponHash:
    * Hash of the weapon you want to get HUD stats of.
    
    Returned object:
    * { hudDamage, hudSpeed, hudCapacity, hudAccuracy, hudRange }
*/
mp.game.data.getWeaponHudStats(weaponHash);

/*
    Returns information about a weapon component's HUD stats.
    
    componentHash:
    * Hash of the weapon component you want to get HUD stats of.
    
    Returned object:
    * { hudDamage, hudSpeed, hudCapacity, hudAccuracy, hudRange }
*/
mp.game.data.getWeaponComponentHudStats(componentHash);

/*
    Returns information about a DLC weapon.
    
    dlcWeaponIndex:
    * DLC weapon index between 0 - GET_NUM_DLC_WEAPONS().
    
    Returned object:
    * { lockHash, weaponHash, id, cost, ammoCost, ammoType, defaultClipSize, textLabel, weaponDesc, weaponTT, weaponUppercase }
*/
mp.game.data.getDlcWeaponData(dlcWeaponIndex);

/*
    Returns information about a DLC weapon's component.
    
    dlcWeaponIndex:
    * DLC weapon index between 0 - GET_NUM_DLC_WEAPONS().
    
    dlcWeaponComponentIndex:
    * DLC weapon component index between 0 - GET_NUM_DLC_WEAPON_COMPONENTS(dlcWeaponIndex).
    
    Returned object:
    * { attachBone, isDefault, lockHash, componentHash, id, cost, textLabel, componentDesc }
*/
mp.game.data.getDlcWeaponComponentData(dlcWeaponIndex, dlcWeaponComponentIndex);

/*
    Returns information about a DLC vehicle.
    
    dlcVehicleIndex:
    * DLC vehicle index between 0 - GET_NUM_DLC_VEHICLES().
    
    Returned object:
    * { lockHash, modelHash, cost }
*/
mp.game.data.getDlcVehicleData(dlcVehicleIndex);

/*
    Returns information about an outfit.
    
    outfitHash:
    * uniqueNameHash of the outfit.
    
    Returned object:
    * { lockHash, uniqueNameHash, cost, numProps, numComponents, eShopEnum, eCharacter, textLabel }
*/
mp.game.data.getShopPedOutfit(outfitHash);

/*
    Returns information about an outfit's component.
    
    outfitHash:
    * uniqueNameHash of the outfit.
    
    componentIndex:
    * index of the outfit's component.
    
    Returned object:
    * { uniqueNameHash, enumValue, eCompType }
*/
mp.game.data.getShopPedOutfitComponentVariant(outfitHash, componentIndex);

/*
    Returns information about an outfit's prop.
    
    outfitHash:
    * uniqueNameHash of the outfit.
    
    propIndex:
    * index of the outfit's prop.
    
    Returned object:
    * { uniqueNameHash, enumValue, eAnchorPoint }
*/
mp.game.data.getShopPedOutfitPropVariant(outfitHash, propIndex);

 

Example Script

Writes bunch of information to the console. (which you can access by pressing F11)

mp.keys.bind(0x75, false, () => {
    // First freemode male tattoo
    const tattooData = mp.game.data.getTattooShopDlcItemData(3, 0);
    if (tattooData) {
        mp.console.logInfo(`Tattoo data: ${JSON.stringify(tattooData)}`);
    }

    // Player's top
    const component = 11;
    const componentHash = mp.game.invoke("0x0368B3A838070348", mp.players.local.handle, component, mp.players.local.getDrawableVariation(component), mp.players.local.getTextureVariation(component));
    const topData = mp.game.data.getShopPedComponent(componentHash);

    if (topData) {
        mp.console.logInfo(`Top data: ${JSON.stringify(topData)}`);
    }

    // Player's hat
    const prop = 0;
    const propHash = mp.game.invoke("0x5D6160275CAEC8DD", mp.players.local.handle, prop, mp.players.local.getPropIndex(prop), mp.players.local.getPropTextureIndex(prop));
    const hatData = mp.game.data.getShopPedProp(propHash);

    if (hatData) {
        mp.console.logInfo(`Hat data: ${JSON.stringify(hatData)}`);
    }

    // Headblend
    mp.players.local.setHeadBlendData(21, 2, 0, 21, 2, 0, 0.75, 0.5, 0.0, false);

    const blendData = mp.game.data.getPedHeadBlendData(mp.players.local.handle);
    if (blendData) {
        mp.console.logInfo(`Headblend data: ${JSON.stringify(blendData)}`);
    }

    // Current weapon HUD stats
    const weaponData = mp.game.data.getWeaponHudStats(mp.players.local.weapon);
    if (weaponData) {
        mp.console.logInfo(`Current weapon HUD stats: ${JSON.stringify(weaponData)}`);
    }

    // COMPONENT_AT_MUZZLE_04 HUD stats
    const componentData = mp.game.data.getWeaponComponentHudStats(mp.game.joaat("COMPONENT_AT_MUZZLE_04"));
    if (componentData) {
        mp.console.logInfo(`Component HUD stats: ${JSON.stringify(componentData)}`);
    }

    // DLC weapon data
    const dlcWeaponIndex = 7;

    const dlcWeaponData = mp.game.data.getDlcWeaponData(dlcWeaponIndex);
    if (dlcWeaponData) {
        mp.console.logInfo(`DLC weapon data: ${JSON.stringify(dlcWeaponData)}`);

        // First component of weapon
        const dlcWeaponCompData = mp.game.data.getDlcWeaponComponentData(dlcWeaponIndex, 0);
        if (dlcWeaponCompData) {
            mp.console.logInfo(`DLC weapon first component data: ${JSON.stringify(dlcWeaponCompData)}`);
        }
    }

    // DLC vehicle data
    const dlcVehicleIndex = 21;

    const dlcVehicleData = mp.game.data.getDlcVehicleData(dlcVehicleIndex);
    if (dlcVehicleData) {
        mp.console.logInfo(`DLC vehicle data: ${JSON.stringify(dlcVehicleData)}`);
    }

    // Outfit data
    const outfitHash = mp.game.joaat("DLC_MP_SUM24_M_OUTFIT_0"); // Pizza This... Outfit

    const outfitData = mp.game.data.getShopPedOutfit(outfitHash);
    if (outfitData) {
        mp.console.logInfo(`Outfit data: ${JSON.stringify(outfitData)}`);

        // First component of outfit
        if (outfitData.numComponents > 0) {
            const outfitComponentData = mp.game.data.getShopPedOutfitComponentVariant(outfitHash, 0);
            if (outfitComponentData) {
                mp.console.logInfo(`First component of outfit: ${JSON.stringify(outfitComponentData)}`);
            }
        }

        // First prop of outfit
        if (outfitData.numProps > 0) {
            const outfitPropData = mp.game.data.getShopPedOutfitPropVariant(outfitHash, 0);
            if (outfitPropData) {
                mp.console.logInfo(`First prop of outfit: ${JSON.stringify(outfitPropData)}`);
            }
        }
    }
});

 

Notes

  • If mp.game.invoke fails (trying to get non-DLC item data/invalid params etc.), return value of the function will be null.
  • Most non-DLC items (core GTAV weapons like Pistol, Assault Rifle etc, initial freemode tattoos, initial freemode clothes) are not supported by the natives.
  • Strings returned by the functions (textLabel, componentDesc etc.) are GXT entries. You're supposed to use them with getLabelText or GXT::get.

Edited by rootcause
v2 changes


What's New in Version 2.0.0   See changelog

Released

This version has breaking changes!

Changelog

  • Added mp.game.data.getDlcVehicleData, mp.game.data.getShopPedOutfit, mp.game.data.getShopPedOutfitComponentVariant, mp.game.data.getShopPedOutfitPropVariant functions
  • mp.game.data.getShopPedComponent & mp.game.data.getShopPedProp: unk1, unk2 and unk3 properties are now named costeShopEnum and eCharacter
  • mp.game.data.getDlcWeaponDataweaponHash2 property is now named id
  • mp.game.data.getTattooCollectionData: renamed to mp.game.data.getTattooShopDlcItemData
  • switched to DataView for reading the buffers
  • uint32 values are now int32
  • Like 5

User Feedback

Create an account or sign in to leave a review

You need to be a member in order to leave a review

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

JamesBeast

   1 of 1 member found this review helpful 1 / 1 member

really nice work

  • Like 1
×
×
  • Create New...