SetObjectBreakable: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Server client function}} This function sets an object to be breakable/unbreakable. ==Syntax== <syntaxhighlight lang="lua">bool setObejectBreakable ( object theObject, bool breaka...")
 
(Remove obsolete Requirements section)
 
(15 intermediate revisions by 10 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Server client function}}
{{Shared function}}
 
{{New feature/item|3.0161|1.6.0|21765|Added also as a server-side function. Previously only available as a client-side function.}}
 
This function sets an object to be breakable/unbreakable.
This function sets an object to be breakable/unbreakable.


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">bool setObejectBreakable ( object theObject, bool breakable )</syntaxhighlight>  
<syntaxhighlight lang="lua">bool setObjectBreakable ( object theObject, bool breakable )</syntaxhighlight>  
{{OOP||[[object]]:setBreakable|breakable|isObjectBreakable}}
===Required Arguments===
*'''object''' the [[object]] that's being set.
*'''breakable''' a boolean whether the object is breakable (true) or unbreakable (false).


===Required Arguments===
*'''object''' The Object that's being checked.
*'''breakable''' A boolean whether the object is breakable(true) or unbreakable (false).
===Returns===
===Returns===
Returns true if the object is now breakable, else false if it can't or if invalid arguments are passed.  
* ''true'' if the object is now breakable.
* ''false'' if it can't or if invalid arguments are passed.  


==Example==  
==Example==  
<section name="Client" class="client" show="true">
This example creates an object when the resource starts and sets it to be breakable.
This example creates an object when the resource starts and sets it to be breakable. (TESTED!)
<syntaxhighlight lang="lua">function toggleObjectVulnerability()
<syntaxhighlight lang="lua">addEventHandler("onClientResourceStart",resourceRoot,function()
local object = createObject(1337, 5540.6654, 1020.55122, 1240.545)
local object = createObject ( 1337, 5540.6654, 1020.55122, 1240.545 )
if isObjectBreakable(object) then
if setObjectBreakable(object,true) 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>
</section>
 
==See Also==
==See Also==
{{Object functions}}
{{Client_object_functions}}

Latest revision as of 17:03, 7 November 2024

ADDED/UPDATED IN VERSION 1.6.0 r21765:
Added also as a server-side function. Previously only available as a client-side function.

This function sets an object to be breakable/unbreakable.

Syntax

bool setObjectBreakable ( object theObject, bool breakable )

OOP Syntax Help! I don't understand this!

Method: object:setBreakable(...)
Variable: .breakable
Counterpart: isObjectBreakable


Required Arguments

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

Returns

  • true if the object is now breakable.
  • 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.

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)

See Also