isElement | Multi Theft Auto: Wiki Skip to content

isElement

Client-side
Server-side
Shared

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 checks if a value is an element or not.

Note

This function is not reliable as element ids are eventually recycled. Always make sure you nil variables containing an element after calling destroyElement or handle onElementDestroy for players and elements that might be destroyed by another resource

Syntax

isElement ( )

Code Examples

server

This serverside function kills a player when it's passed his name or his element.

function killPlayer2 ( argument )
-- if the argument is an element, and also a player,
if isElement( argument ) and getElementType( argument ) == "player" then
-- kill him
killPed ( argument )
-- if it isn't an element, but a string, it could be a name
elseif type ( argument ) == "string" then
-- retrieve the player with that name
local playerElement = getPlayerFromName( argument )
-- if a player with such a name exists,
if playerElement then
-- kill him
killPed ( playerElement )
end
end
end

See Also

Element Functions