setElementID | Multi Theft Auto: Wiki Skip to content

setElementID

Client-side
Server-side
Shared

Pair: getElementID

This page is incomplete! Help wanted!

Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.


This function sets the ID of an element to a string. This can be anything from an identifying number, to a name. You can only change the ID of an element clientside if that element has been created clientside as well.

Syntax

setElementID ( )

Code Examples

server
local players = getElementsByType( "player" )
for i=1,#players do
setElementID( players[i], "player" .. i ) -- Change element IDs to 'player1', 'players2', 'players3'...
outputDebugString( "Player[" .. i .. "] = " .. getElementID( players[i] ) ) -- Output all the new element IDs
end
-- Could also be --
for i=1,#players do
setElementID( players[i], getPlayerName( players[i] ) ) -- Change the element ID to the players name.
outputDebugString( "Player[" .. i .. "] = " .. getElementID( players[i] ) )
end

See Also

Element Functions