script:world_event:despawnitembyobjid
despawnItemByObjid
- Parameters and types:
- objid: numberobject objID
- Return value and type:
- code: numberSuccess (ErrorCode.OK) ErrorCode
- The main purpose of this method: Remove props (by ID)
- The specific use cases are as follows:
--Whenever a player makes an animated expression, remove a certain drop within 10 blocks around the host --Execute this function when the player makes an animated expression local function Player_PlayAction(event) --Get the coordinates of the host local result,x,y,z=Player:getPosition(0) --Get the number and list of drops within 10 blocks around the host local result2,num,list=World:getActorsByBox(3,x-10,y-10,z-10,x+10,y+10,z+10) if num>0 then--If there is a drop --Remove the first group of items World:despawnItemByObjid(list[1]) --Display in chat box Chat:sendSystemMsg("Dropped items found in the nearby 10 grids, one group has been removed") else--If there is no drop --Display in chat box Chat:sendSystemMsg("No dropped items found in the nearby 10 grids!") end end --Register animation expression listener, execute the above function when the player makes an animation expression ScriptSupportEvent:registerEvent([=[Player.PlayAction]=],Player_PlayAction)
script/world_event/despawnitembyobjid.txt · Last modified: 2024/06/09 07:51 by don