SetObjectBreakable: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
m (Script doesn't work; Do not add "TESTED" in the description; Script not meeting the Wiki standards)
Line 15: Line 15:
==Example==  
==Example==  
This example creates an object when the resource starts and sets it to be breakable. (TESTED!)
This example creates an object when the resource starts and sets it to be breakable. (TESTED!)
<syntaxhighlight lang="lua">addEventHandler("onClientResourceStart",resourceRoot,function()
<syntaxhighlight lang="lua">function toggleObjectVulnerability()
local object = createObject ( 1337, 5540.6654, 1020.55122, 1240.545 )
local object = createObject(1337, 5540.6654, 1020.55122, 1240.545)
if setObjectBreakable(object,true) then
if isObjectBreakable(object) then
setObjectBreakable(object, false)
outputChatBox("The object is now not breakable.")
else
setObjectBreakable(object, true)
outputChatBox("The object is now breakable.")
outputChatBox("The object is now breakable.")
else
outputChatBox("The object can't be breakable")
end
end
end)
end
addEventHandler("onClientResourceStart", resourceRoot, toggleObjectVulnerability)
</syntaxhighlight>
</syntaxhighlight>
==Requirements==
==Requirements==

Revision as of 14:34, 13 November 2012

This function sets an object to be breakable/unbreakable.

Syntax

bool setObjectBreakable ( object theObject, bool breakable )

Required Arguments

  • object The Object that's being set.
  • breakable A boolean whether the object is breakable(true) or unbreakable (false).

Returns

Returns true if the object is now breakable, else false if it can't or if invalid arguments are passed.

Example

This example creates an object when the resource starts and sets it to be breakable. (TESTED!)

function toggleObjectVulnerability()
	local object = createObject(1337, 5540.6654, 1020.55122, 1240.545)
	if isObjectBreakable(object) then
		setObjectBreakable(object, false)
		outputChatBox("The object is now not breakable.")
	else
		setObjectBreakable(object, true)
		outputChatBox("The object is now breakable.")
	end
end
addEventHandler("onClientResourceStart", resourceRoot, toggleObjectVulnerability)

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