SetText3DAttached: Difference between revisions

From Onset Developer Wiki
No edit summary
No edit summary
 
Line 1: Line 1:
{{Info|Function|Server|1.0}}
{{Info|Function|Server|1.0}}


{{FuncDescription|__EDIT_ME__}}
{{FuncDescription|Attaches a 3D Text to another entity.}}


{{FuncSyntax|SetText3DAttached(text3d, attachtype, attachid, x, y, z [, rx, ry, rz, SocketName])}}
{{FuncSyntax|SetText3DAttached(text3d, attachtype, attachid, x, y, z [, rx, ry, rz, SocketName])}}

Latest revision as of 18:38, 27 May 2021

SetText3DAttached

Type: Function
Context: Server
Introduced: v1.0

Description

Attaches a 3D Text to another entity.

Syntax

SetText3DAttached(text3d, attachtype, attachid, x, y, z [, rx, ry, rz, SocketName])

Parameters

  • text3d
    The text 3D indentifier.
  • attachtype
    AttachType
  • attachid
    The identifier of the attach type (entity)
  • 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)
    The socket name

Return Value

  • Returns true on success.

Example

The example given below creates a 3D Text above a player's head!

AddCommand("text", function(playerid, ...)
    local textCheck = GetPlayerPropertyValue(playerid, "_3DText")
    if textCheck and IsValidText3D(textCheck) then
        DestroyText3D(textCheck)
        SetPlayerPropertyValue(playerid, "_3DText", nil)
        return AddPlayerChat(playerid, "The text has been removed!")
    end

    if #{...} == 0 then
        return AddPlayerChat(playerid, "Usage: /text <message>")
    end

    local message = table.concat({...}, " ")
    local text = CreateText3D(message, 10, 0, 0, 0, 0, 0, 0)
    SetText3DAttached(text, ATTACH_PLAYER, playerid, 25, 0, 0, 0, 90, -90, "head")
    SetPlayerPropertyValue(playerid, "_3DText", text)

    return AddPlayerChat(playerid, "Text added!")
end)

See also