Il Knight
Veteran OT User
Hi community,
today i am triying to add this script to mi Tfs 1.2 (10.76-10.77) (latest tfs source)
its a creatureevent OnKill
function autoGP(cid, pos, corpseId)
local player = Player(cid)
if not player then
return
end
local corpse = Tile(pos):getItemById(corpseId)
if corpse then
local container = Container(corpse:getUniqueId())
if container then
local gold = 0
for i = 1, container:getSize() do
local item = container:getItem(i)
if item then
local id = item:getId()
local count = item:getCount()
local goldAdded = id == 2148 and count or id == 2152 and count * 100 or id == 2160 and count * 10000 or 0
if goldAdded > 0 then
gold = gold + goldAdded
item:remove(count)
end
else
break
end
end
player:addMoney(gold)
end
end
end
function onKill(creature, target)
if target:isPlayer() then
return true
end
local monsterType = MonsterType(target:getName())
addEvent(autoGP, 1, creature:getId(), target:getPosition(), monsterType:getCorpseId())
return true
end
its dont work and dont show errors,
i need it to AUTO loot the gold, platinum and crystal coins from the creatures when you kill it
if someone can help me! thanks in advance
today i am triying to add this script to mi Tfs 1.2 (10.76-10.77) (latest tfs source)
its a creatureevent OnKill
function autoGP(cid, pos, corpseId)
local player = Player(cid)
if not player then
return
end
local corpse = Tile(pos):getItemById(corpseId)
if corpse then
local container = Container(corpse:getUniqueId())
if container then
local gold = 0
for i = 1, container:getSize() do
local item = container:getItem(i)
if item then
local id = item:getId()
local count = item:getCount()
local goldAdded = id == 2148 and count or id == 2152 and count * 100 or id == 2160 and count * 10000 or 0
if goldAdded > 0 then
gold = gold + goldAdded
item:remove(count)
end
else
break
end
end
player:addMoney(gold)
end
end
end
function onKill(creature, target)
if target:isPlayer() then
return true
end
local monsterType = MonsterType(target:getName())
addEvent(autoGP, 1, creature:getId(), target:getPosition(), monsterType:getCorpseId())
return true
end
its dont work and dont show errors,
i need it to AUTO loot the gold, platinum and crystal coins from the creatures when you kill it
if someone can help me! thanks in advance