SetObjectAttached
From Onset Developer Wiki
Description
Attaches an object to another entity.
Syntax
SetObjectAttached(object, attachtype, attachid, x, y, z [, rx, ry, rz, SocketName])
Parameters
- object
The object identifier from CreateObject. - attachtype
AttachType - attachid
The identifier of the other entity you want to attach to. - x
Relative X location. - y
Relative Y location. - z
Relative Z location. - rx (optional)
Relative pitch rotation. - ry (optional)
Relative yaw rotation. - rz (optional)
Relative roll rotation. - SocketName (optional)
Socket where to attach to (PlayerBones). Can be empty.
Return Value
- Returns true on success.
Example
function cmd_hat(player, hatobject)
if (PlayerData[player].hat ~= 0) then
DestroyObject(PlayerData[player].hat)
PlayerData[player].hat = 0
end
local hatModel = 0
if hatobject == nil then
local startHats = 398
local endHats = 477
hatModel = Random(startHats, endHats)
else
hatModel = math.tointeger(hatobject)
end
local x, y, z = GetPlayerLocation(player)
PlayerData[player].hat = CreateObject(hatModel, x, y, z)
SetObjectAttached(PlayerData[player].hat, ATTACH_PLAYER, player, 14.0, 0.0, 0.0, 0.0, 90.0, -90.0, "head")
SetObjectAttached(PlayerData[player].hat, ATTACH_PLAYER, player, 14.0, 0.0, 0.0, 0.0, 90.0, -90.0, "head")
AddPlayerChat(player, "Attached object model id as hat: "..hatModel)
end
AddCommand("hat", cmd_hat)
See also
__EDIT_ME__