SetPlayerAttachedObject
From SA-MP Wiki
(Difference between revisions)
Revision as of 00:01, 30 May 2012 Smithy (Talk | contribs) ← Previous diff |
Revision as of 22:33, 31 January 2014 Connor Mead (Talk | contribs) Next diff → |
||
Line 1: | Line 1: | ||
{{Scripting}} | {{Scripting}} | ||
- | {{Title}} | ||
{{AddedIn0.3c|function}} | {{AddedIn0.3c|function}} | ||
Line 55: | Line 54: | ||
[[Category:Scripting Functions]] | [[Category:Scripting Functions]] | ||
+ | |||
+ | [[fr:SetPlayerAttachedObject]] |
Revision as of 22:33, 31 January 2014
Description:
Attach an object to a specific bone on a player.
(playerid, index, modelid, bone, Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ, Float:fRotX, Float:fRotY, Float:fRotZ, Float:fScaleX, Float:fScaleY, Float:fScaleZ, materialcolor1, materialcolor2)
playerid | The ID of the player to attach the object to. |
index | The index (slot) to assign the object to (0-9 since 0.3d, 0-4 in previous versions). |
modelid | The model to attach. |
bone | The bone to attach the object to. |
fOffsetX | (optional) X axis offset for the object position. |
fOffsetY | (optional) Y axis offset for the object position. |
fOffsetZ | (optional) Z axis offset for the object position. |
fRotX | (optional) X axis rotation of the object. |
fRotY | (optional) Y axis rotation of the object. |
fRotZ | (optional) Z axis rotation of the object. |
fScaleX | (optional) X axis scale of the object. |
fScaley | (optional) Y axis scale of the object. |
fScalez | (optional) Z axis scale of the object. |
materialcolor1 | (optional) The first object color to set, as an integer or hex in ARGB color format. |
materialcolor2 | (optional) The second object color to set, as an integer or hex in ARGB color format |
Return Values:
1 on success, 0 on failure.
Important | No more than 10 objects can be attached to a single player in 0.3d (5 in previous versions). Index must be 0-9 (0-4 in previous versions)). |
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, 1, 1, 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.
- RemovePlayerAttachedObject: Remove an attached object from a player
- IsPlayerAttachedObjectSlotUsed: Check whether an object is attached to a player in a specified index
- EditAttachedObject: Edit an attached object.