SetText3DAttached: Difference between revisions

From Onset Developer Wiki
Created page with "{{Info|Function|Server|1.0}} {{FuncDescription|__EDIT_ME__}} {{FuncSyntax|SetText3DAttached(text3d, attachtype, attachid, x, y, z [, rx, ry, rz, SocketName])}} {{FuncParame..."
 
No edit summary
 
(3 intermediate revisions by 2 users not shown)
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])}}


{{FuncParameters}}
{{FuncParameters}}
{{FuncParam|object|__EDIT_ME__}}
{{FuncParam|text3d|The text 3D indentifier.}}
{{FuncParam|attachtype|__EDIT_ME__}}
{{FuncParam|attachtype|[[AttachType]]}}
{{FuncParam|attachid|__EDIT_ME__}}
{{FuncParam|attachid|The identifier of the attach type (entity)}}
{{FuncParam|x|__EDIT_ME__}}
{{FuncParam|x|Relative X location.}}
{{FuncParam|y|__EDIT_ME__}}
{{FuncParam|y|Relative Y location.}}
{{FuncParam|z |__EDIT_ME__}}
{{FuncParam|z|Relative Z location.}}
{{FuncParamOptional|rx|__EDIT_ME__}}
{{FuncParamOptional|rx|Relative pitch rotation.}}
{{FuncParamOptional|ry|__EDIT_ME__}}
{{FuncParamOptional|ry|Relative yaw rotation.}}
{{FuncParamOptional|rz|__EDIT_ME__}}
{{FuncParamOptional|rz|Relative roll rotation.}}
{{FuncParamOptional|SocketName|__EDIT_ME__}}
{{FuncParamOptional|SocketName|The socket name}}


{{FuncReturnValue|__EDIT_ME__}}
{{FuncReturnValue|Returns '''true''' on success.}}


== Example ==
== Example ==
__EDIT_ME__
The example given below creates a 3D Text above a player's head!
<syntaxhighlight lang="Lua">
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)
</syntaxhighlight>


{{RelatedFunctions}}
{{RelatedFunctions}}
__EDIT_ME__
{{Text3DFunctions}}

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