SetText3DAttached: Difference between revisions

From Onset Developer Wiki
No edit summary
No edit summary
Line 9: Line 9:
{{FuncParam|attachtype|[[AttachType]]}}
{{FuncParam|attachtype|[[AttachType]]}}
{{FuncParam|attachid|The identifier of the attach type (entity)}}
{{FuncParam|attachid|The identifier of the attach type (entity)}}
{{FuncParam|x|The X axis}}
{{FuncParam|x|Relative X location.}}
{{FuncParam|y|The Y axis}}
{{FuncParam|y|Relative Y location.}}
{{FuncParam|z |The Z axis}}
{{FuncParam|z|Relative Z location.}}
{{FuncParamOptional|rx|The RX axis}}
{{FuncParamOptional|rx|Relative pitch rotation.}}
{{FuncParamOptional|ry|The RY axis}}
{{FuncParamOptional|ry|Relative yaw rotation.}}
{{FuncParamOptional|rz|The RZ axis}}
{{FuncParamOptional|rz|Relative roll rotation.}}
{{FuncParamOptional|SocketName|The socket name}}
{{FuncParamOptional|SocketName|The socket name}}


Line 20: Line 20:


== 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}}
{{Text3DFunctions}}
{{Text3DFunctions}}

Revision as of 18:37, 27 May 2021

SetText3DAttached

Type: Function
Context: Server
Introduced: v1.0

Description

__EDIT_ME__

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