Tfs 1.4.2
I've tried to get this to count properly for a while now, when i kill a creature alone i get 1 count per kill
but when theres 2 or more players it goes wild, i can get everything from 1 to 6 count for each kill. Can anyone explain why this could happen?
I've tried to get this to count properly for a while now, when i kill a creature alone i get 1 count per kill
but when theres 2 or more players it goes wild, i can get everything from 1 to 6 count for each kill. Can anyone explain why this could happen?
Lua:
local config = {
['nomad'] = {amount = 250, storage = 21900, startstorage = 45023, startvalue = 1, endstorage = 56010},
['lightning wizard'] = {amount = 400, storage = 21901, startstorage = 45023, startvalue = 2, endstorage = 56011},
['forsaken mage'] = {amount = 250, storage = 21902, startstorage = 45023, startvalue = 3, endstorage = 56012},
['midnight vampire'] = {amount = 300, storage = 21903, startstorage = 45023, startvalue = 4, endstorage = 56013},
['horrifying treeling'] = {amount = 350, storage = 21904, startstorage = 45023, startvalue = 5, endstorage = 56014},
['were worm'] = {amount = 350, storage = 21905, startstorage = 45023, startvalue = 6, endstorage = 56015},
}
local missionsLogin = CreatureEvent("missionsLogin")
function missionsLogin.onLogin(player)
player:registerEvent("missionsKill")
return true
end
missionsLogin:type("login")
missionsLogin:register()
local missionsKill = CreatureEvent("missionsKill")
function missionsKill.onKill(creature, target)
local monsterName = target:getName():lower()
local monster = config[monsterName]
local player = Player(creature)
if not player or target:isPlayer() or not monster or target:getMaster() then
return true
end
if not config[monsterName] then
return true
end
for creatureId, _ in pairs(target:getDamageMap()) do
local attackPlayer = Player(creatureId)
if attackPlayer then
if attackPlayer:getStorageValue(monster.startstorage) >= monster.startvalue then
local stor = math.max(0, attackPlayer:getStorageValue(monster.storage))
stor = stor + 1
attackPlayer:setStorageValue(monster.storage, stor)
attackPlayer:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, '[Task]: ' .. stor .. ' of ' .. monster.amount .. ' ' .. target:getName() .. 's killed.')
if stor == monster.amount and attackPlayer:getStorageValue(monster.endstorage) < 1 then
attackPlayer:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Congratulations, you have killed ' .. stor .. ' ' .. target:getName() .. 's and completed the ' .. target:getName() .. 's mission.')
attackPlayer:setStorageValue(monster.endstorage, 1)
end
end
end
end
return true
end
missionsKill:type("kill")
missionsKill:register()