Tokumei Posted April 21, 2022 Share Posted April 21, 2022 (edited) Is there currently a function to execute a script on kill? If not, is there another method I could use? For some context: - OT server (WAD) - I'm trying to make a script that functions as a looter by using corpses, but I've run into the problem of already looted corpse co-ordinates being added back to the table each time it runs as a persistent script. - I am aware that if the creature is skinnable, I can just skin the creature after looting and that would solve the issue. Unfortunately not all creatures are skinnable. - I would like to avoid just adding a longer period for the auto() funtion. -- Variables -- local corpseIds = {4286, 4062} -- Corpse ID's -- Functions -- function table.find(t, value) for k,v in pairs(t) do if v == value then return k end end end -- Conditions -- local tiles = g_map.getTiles() local corpses = {} for _, tile in pairs(tiles) do if tile:getPosition():getDistance(g_game.getLocalPlayer():getPosition()) <= 7 then local topItem = tile:getTopItem() if topItem and table.find(corpseIds, topItem:getId()) then table.insert(corpses, topItem) end end end if #corpses > 0 then for _, corpse in pairs(corpses) do setOption("Cavebot/Enabled", "false") g_game.stop() g_game.useMapItem(corpse:getPosition()) table.remove(corpses,1) sleep(2000) setOption("Cavebot/Enabled", "true") sleep(500) end end auto(100) EDIT: Sorry if I posted this in the wrong thread. ~ Tokumei Edited April 21, 2022 by Tokumei Unsure if I posted in the correct thread. Link to comment Share on other sites More sharing options...
Recommended Posts