RespawnObject: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__{{Needs Example}}
__NOTOC__
{{client function}}
{{Shared function}}
This function respawns a specific object.
This function respawns a specific object.
{{New feature/item|3.0161|1.6.0|22708|This function is now also available on the server side.}}


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">bool respawnObject ( object theObject )</syntaxhighlight>  
<syntaxhighlight lang="lua">bool respawnObject ( object theObject )</syntaxhighlight>  
 
{{OOP||[[object]]:respawn}}
===Required Arguments===  
===Required Arguments===  
*'''theObject:''' An [[object]] element
*'''theObject:''' an [[object]] element


===Returns===
===Returns===
Returns ''true'' if the object was sucessfully respawned. ''false'' if the object is not breakable, or a wrong object was given.
* ''true'' if the object was sucessfully respawned.
* ''false'' if the object is not breakable, or a wrong object was given.


==Example==
==Example==
<section class="client" name="Client" show="true">
This example prevents objects from despawning. When an object breaks, it gets respawned right away.
This example prevents objects from despawning. When an object breaks, it gets respawned right away.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Line 21: Line 22:
     end
     end
)</syntaxhighlight>
)</syntaxhighlight>
</section>


==See Also==
==See Also==
{{Client_object_functions}}
{{Shared_object_functions}}

Latest revision as of 12:10, 4 September 2024

This function respawns a specific object.

ADDED/UPDATED IN VERSION 1.6.0 r22708:
This function is now also available on the server side.

Syntax

bool respawnObject ( object theObject )

OOP Syntax Help! I don't understand this!

Method: object:respawn(...)


Required Arguments

Returns

  • true if the object was sucessfully respawned.
  • false if the object is not breakable, or a wrong object was given.

Example

This example prevents objects from despawning. When an object breaks, it gets respawned right away.

addEventHandler ( "onClientObjectBreak", getRootElement(),
    function ()
        respawnObject ( source )
    end
)

See Also