GetAllElementData: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(New page: __NOTOC__ {{Server function}} Returns a table of all element data of an element. ==Syntax== <syntaxhighlight lang="lua"> table getAllElementData ( element theElement ) </syntaxhighlight> ===Required Arguments=== *...)
 
No edit summary
Line 14: Line 14:
===Returns===
===Returns===
If successful, returns a table with as keys the names of the element data and as values the corresponding element data values. Returns ''false'' in case of failure.
If successful, returns a table with as keys the names of the element data and as values the corresponding element data values. Returns ''false'' in case of failure.
==Example==
This example script creates a new console command that displays all element data that is currently set on the player who enters the command.
<syntaxhighlight lang="lua">
function getMyData ( thePlayer, command )
    local data = getAllElementData ( thePlayer )    -- get all the element data of the player who entered the command
    for k, v in pairs ( data ) do                    -- loop through the table that was returned
        outputConsole ( k .. ": " .. v )            -- print the name (k) and value (v) of each element data
    end
end
addCommandHandler ( "elemdata", getMyData )
</syntaxhighlight>


==See Also==
==See Also==
{{Element functions}}
{{Element functions}}

Revision as of 12:15, 28 March 2008

Returns a table of all element data of an element.

Syntax

table getAllElementData ( element theElement )

Required Arguments

  • theElement: the element you want to get the element data of.

Returns

If successful, returns a table with as keys the names of the element data and as values the corresponding element data values. Returns false in case of failure.

Example

This example script creates a new console command that displays all element data that is currently set on the player who enters the command.

function getMyData ( thePlayer, command )
    local data = getAllElementData ( thePlayer )     -- get all the element data of the player who entered the command
    for k, v in pairs ( data ) do                    -- loop through the table that was returned
        outputConsole ( k .. ": " .. v )             -- print the name (k) and value (v) of each element data
    end
end
addCommandHandler ( "elemdata", getMyData )

See Also