IsObjectBreakable: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Undo revision 50126 by Marcin778 (talk))
Line 21: Line 21:
outputChatBox("No, the object is not breakable")
outputChatBox("No, the object is not breakable")
end
end
end)
</syntaxhighlight>
This example is the same as before, but with some advanced logic using ternary operation.
<syntaxhighlight lang="lua">addEventHandler("onClientResourceStart",resourceRoot,function()
addEventHandler("onClientResourceStart",resourceRoot,function()
local object = createObject ( 1337, 5540.6654, 1020.55122, 1240.545 )
        outputChatBox((isObjectBreakable(object) and "Yes, the object is breakable.") or ("No, the object is not breakable"))
end)
end)
end)
</syntaxhighlight>
</syntaxhighlight>

Revision as of 10:22, 4 August 2018

This function checks if an object is breakable.

Syntax

bool isObjectBreakable ( object theObject )

OOP Syntax Help! I don't understand this!

Method: object:isBreakable(...)
Variable: .breakable
Counterpart: setObjectBreakable


Required Arguments

  • object the object that's being checked.

Returns

  • true if the object is breakable.
  • false if the object is not breakable.

Example

This example creates an object when the resource starts and checks if the object is breakable.

addEventHandler("onClientResourceStart",resourceRoot,function()
	local object = createObject ( 1337, 5540.6654, 1020.55122, 1240.545 )
	if isObjectBreakable(object) then
		outputChatBox("Yes, the object is breakable.")
	else
		outputChatBox("No, the object is not breakable")
	end
end)

This example is the same as before, but with some advanced logic using ternary operation.

addEventHandler("onClientResourceStart",resourceRoot,function()
	addEventHandler("onClientResourceStart",resourceRoot,function()
	local object = createObject ( 1337, 5540.6654, 1020.55122, 1240.545 )
        outputChatBox((isObjectBreakable(object) and "Yes, the object is breakable.") or ("No, the object is not breakable"))
end)
end)

Requirements

Minimum server version n/a
Minimum client version 1.3.0-9.03783

Note: Using this feature requires the resource to have the above minimum version declared in the meta.xml <min_mta_version> section. e.g. <min_mta_version client="1.3.0-9.03783" />

See Also