SetPlayerAttachedObject

SetPlayerAttachedObject

Description:
Function SetPlayerAttachedObject attach an object to a specific bone on a player.
Function SetPlayerAttachedObject was added in 0.3c and will not work in earlier versions!
This function is separate from the CreateObject/CreatePlayerObject pools.
In version 0.3d and onwards, 10 objects can be attached to a single player (index 0-9). In earlier versions, the limit is 5 (index 0-4).


Parameters:
(playerid, index, modelid, bone, Float:fOffsetX = 0.0, Float:fOffsetY = 0.0, Float:fOffsetZ = 0.0, Float:fRotX = 0.0, Float:fRotY = 0.0, Float:fRotZ = 0.0, Float:fScaleX = 1.0, Float:fScaleY = 1.0, Float:fScaleZ = 1.0, materialcolor1 = 0, materialcolor2 = 0)
int playerid The ID of the player to attach the object to.
int index The index (slot) to assign the object to (0-9 since 0.3d, 0-4 in previous versions).
int modelid The model to attach.
int bone The bone to attach the object to.
float fOffsetX (optional) X axis offset for the object position.
float fOffsetY (optional) Y axis offset for the object position.
float fOffsetZ (optional) Z axis offset for the object position.
float fRotX (optional) X axis rotation of the object.
float fRotY (optional) Y axis rotation of the object.
float fRotZ (optional) Z axis rotation of the object.
float fScaleX (optional) X axis scale of the object.
float fScaleY (optional) Y axis scale of the object.
float fScaleZ (optional) Z axis scale of the object.
int materialcolor1 (optional) The first object color to set, as an integer or hex in ARGB color format.
int materialcolors (optional) The second object color to set, as an integer or hex in ARGB color format


Return Values:
  • 1 on success.
  • 0 on failure.


Examples:
public OnPlayerSpawn(playerid)
{
    SetPlayerAttachedObject(playerid, 3, 1609, 2); //Attach a turtle to the playerid's head, in slot 3
    // example of using colors on an object being attached to the player:
    SetPlayerAttachedObject(playerid, 3, 19487, 2, 0.101, -0.0, 0.0, 5.50, 84.60, 83.7, 1.0, 1.0, 1.0, 0xFF00FF00);
    // Attach a white hat to the head of the player and paint it green
    return 1;
}

// Useful defines for updating to 0.3c
#define SetPlayerHoldingObject(%1,%2,%3,%4,%5,%6,%7,%8,%9) SetPlayerAttachedObject(%1,MAX_PLAYER_ATTACHED_OBJECTS-1,%2,%3,%4,%5,%6,%7,%8,%9)
#define StopPlayerHoldingObject(%1) RemovePlayerAttachedObject(%1,MAX_PLAYER_ATTACHED_OBJECTS-1)
#define IsPlayerHoldingObject(%1) IsPlayerAttachedObjectSlotUsed(%1,MAX_PLAYER_ATTACHED_OBJECTS-1)


Related Functions
The following functions may be useful, as they are related to this function in one way or another.