toggleObjectRespawn | Multi Theft Auto: Wiki Skip to content

toggleObjectRespawn

Client-side
Server-side
Shared

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


This function is used to toggle if an object should respawn after it got destroyed

Note

The object will be respawned when it is streamed

OOP Syntax Help! I don't understand this!

  • Method:object:toggleRespawn(...)

Syntax

bool toggleObjectRespawn ( object theObject, bool respawn )
Required Arguments
  • theObject: the object you want to toggle the respawn from
  • respawn: a bool denoting whether we want to enable ( true ) or disable ( false ) respawning

Returns

  • bool: value

This example adds command tos that toggles respawn of all the objects.

Code Examples

shared

This example adds commandtosthat toggles respawn of all the objects.

local respawn = false
addCommandHandler("tos",
function ()
for i, object in pairs(getElementsByType("object")) do
toggleObjectRespawn(object, not respawn)
end
outputChatBox("Object respawning " .. (respawn and "disabled" or "enabled"))
respawn = not respawn
end)