IsObjectBreakable: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Server client function}} This function checks if an object is breakable. ==Syntax== <syntaxhighlight lang="lua">object isObejectBreakable( object theObject )</syntaxhighlight> ===Required...")
 
(Remove obsolete Requirements section)
 
(17 intermediate revisions by 12 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Server client function}}
{{Shared function}}
This function checks if an object is breakable.
 
{{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 checks if an object / model ID is breakable.


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">object isObejectBreakable( object theObject )</syntaxhighlight>  
<syntaxhighlight lang="lua">bool isObjectBreakable ( object theObject / int modelId )</syntaxhighlight>  
 
{{OOP||[[object]]:isBreakable|breakable|setObjectBreakable}}
===Required Arguments===  
===Required Arguments===  
*'''object''' The Object that's being checked.
*'''theObject / modelId:''' The [[object]] / model ID that's being checked.
===Returns===
===Returns===
Returns true if the object is breakable, else false if the object is not breakable.
* ''true'' if the object is breakable.
* ''false'' if the object is not breakable.


==Example==  
==Example==
<section name="Client" class="client" show="true">
This example creates an object when the resource starts and checks if the object is breakable.
This example creates an object when the resource starts and checks if the object is breakable. (TESTED!)
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">addEventHandler("onClientResourceStart",resourceRoot,function()
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 isObjectBreakable(object) then
outputChatBox("Yes, the object is breakable.")
        outputChatBox("Yes, the object is breakable.")
else
    else
outputChatBox("No, the object is not breakable")
        outputChatBox("No, the object is not breakable")
end
    end
end)
end)
</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 checks if an object / model ID is breakable.

Syntax

bool isObjectBreakable ( object theObject / int modelId )

OOP Syntax Help! I don't understand this!

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


Required Arguments

  • theObject / modelId: The object / model ID 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)

See Also