User Tools

Site Tools


script:world_event:despawncreature

despawnCreature

This method functions identically to despawnActor

How to use

 World:despawnCreature(objid) 

Where:

  • objid number: The id of the creature that will be despawned.

And returns:

  • ErrorCode.Ok number: 0 if execution was succesful and 1001 if the execution failed.

Use example

When a bee spawns, it will be despawned after 10 seconds.

local beeId = 3418
local delayseconds = 10
 
ScriptSupportEvent:registerEvent([=[Actor.Create]=], function(e) 
 
    local eventcreature = e['eventobjid']
    local eventcreatureid = e['actorid']
 
    if eventcreatureid == beeId then 
 
        threadpool:wait(delayseconds)
        World:despawnCreature(eventcreature)
 
    end
end)
script/world_event/despawncreature.txt · Last modified: 2024/07/01 18:37 by notsopro