Jump to content

mp.game.data 1.0.0

   (2 reviews)

About This File

Ksc3AvX.png

 

Requires RAGE Multiplayer 1.1.0 and above.

This resource adds wrappers for these natives:

  • _GET_TATTOO_COLLECTION_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

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_DECORATIONS(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.getTattooCollectionData(characterType, decorationIndex);

/*
    Returns information about a clothing item.
    
    componentHash:
    * Obtained by GET_HASH_NAME_FOR_COMPONENT.
    
    Returned object:
    * { lockHash, uniqueNameHash, locate, drawableIndex, textureIndex, unk1, eCompType, unk2, unk3, 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, unk1, eAnchorPoint, unk2, unk3, 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, weaponHash2, 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, unk, cost, textLabel, componentDesc }
*/
mp.game.data.getDlcWeaponComponentData(dlcWeaponIndex, dlcWeaponComponentIndex);

 

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.getTattooCollectionData(3, 0);
    if (tattooData) {
        mp.console.logInfo(`Tattoo data: ${JSON.stringify(tattooData)}`);
    }

    // Players 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)}`);
    }

    // Players 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)}`);
        }
    }
});

 

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.
  • Like 4

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
Link to review
×
×
  • Create New...