deadsmelly
New Member
- Joined
- Apr 5, 2009
- Messages
- 8
- Reaction score
- 4
Hello all, I'm running a TFS 1.3 10.98 server.
I was trying to figure out how to get onkill task credit to players in a party and found this thread where Sarah Wesker solved the problem.
Using Sarah Wesker's script I was able to configure party task credit sharing for my killing in the name of kill.lua script, but now I have the opposite problem. I can't seem to get credit if a player is not in a party, or if they are in a party and multiple players don't attack. Sarah says in her post that it should work for solo players or party so I know I am doing something wrong but I just can't figure out what it is.
Any help would be greatly appreciated. I am a lua noob and have been learning as I go.
I was trying to figure out how to get onkill task credit to players in a party and found this thread where Sarah Wesker solved the problem.
Using Sarah Wesker's script I was able to configure party task credit sharing for my killing in the name of kill.lua script, but now I have the opposite problem. I can't seem to get credit if a player is not in a party, or if they are in a party and multiple players don't attack. Sarah says in her post that it should work for solo players or party so I know I am doing something wrong but I just can't figure out what it is.
Any help would be greatly appreciated. I am a lua noob and have been learning as I go.
Lua:
local function getKillers(creature, party)
local killers = {}
local timeNow = os.mtime()
local inFightTicks = configManager.getNumber(configKeys.PZ_LOCKED)
for uid, cb in pairs(creature:getDamageMap()) do
local attacker = Player(uid)
if (attacker and attacker ~= creature and timeNow - cb.ticks <= inFightTicks) then
local p = attacker:getParty()
if p and p == party then
killers[#killers +1] = attacker
end
end
end
return killers
end
function onKill(player, target)
if target:isPlayer() or target:getMaster() then
return true
end
local targetName, startedTasks, taskId = target:getName():lower(), player:getStartedTasks()
for i = 1, #startedTasks do
taskId = startedTasks[i]
if isInArray(tasks[taskId].creatures, targetName) then
local killers = getKillers(target, player:getParty())
for k, member in pairs(killers) do
local killAmount = member:getStorageValue(KILLSSTORAGE_BASE + taskId)
if killAmount < tasks[taskId].killsRequired then
-- Set max kills to adm
--if (player:getAccountType() >= ACCOUNT_TYPE_GOD) then
--player:setStorageValue(KILLSSTORAGE_BASE + taskId, tasks[taskId].killsRequired)
--return true
--end
member:setStorageValue(KILLSSTORAGE_BASE + taskId, killAmount + 1)
if member:getStorageValue(KILLSSTORAGE_BASE + taskId, killAmount) == tasks[taskId].killsRequired then -- if player has completed kill amount
member:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have culled the required amount of" .. targetName .. ". Report back to Grizzly Adams.")
elseif member:getStorageValue(KILLSSTORAGE_BASE + taskId, killAmount) < tasks[taskId].killsRequired then -- is on quest, killed a creature, report how many
member:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed " .. member:getStorageValue(KILLSSTORAGE_BASE + taskId, killAmount) .. " out of " .. tasks[taskId].killsRequired .. " " .. targetName .. ".")
end
end
end
end
if(isMonster(target)) then
local killAmount = player:getStorageValue(Storage.KillingInTheNameOf.LugriNecromancerCount)
if(string.lower(getCreatureName(target)) == "necromancer") and killAmount < 4000 and player:getStorageValue(Storage.KillingInTheNameOf.LugriNecromancers) == 1 then
player:setStorageValue(Storage.KillingInTheNameOf.LugriNecromancerCount, killAmount + 1)
elseif(string.lower(getCreatureName(target)) == "priestess") and killAmount < 4000 and player:getStorageValue(Storage.KillingInTheNameOf.LugriNecromancers) == 1 then
player:setStorageValue(Storage.KillingInTheNameOf.LugriNecromancerCount, killAmount + 1)
elseif(string.lower(getCreatureName(target)) == "blood priest") and killAmount < 4000 and player:getStorageValue(Storage.KillingInTheNameOf.LugriNecromancers) == 1 then
player:setStorageValue(Storage.KillingInTheNameOf.LugriNecromancerCount, killAmount + 1)
elseif(string.lower(getCreatureName(target)) == "blood hand") and killAmount < 4000 and player:getStorageValue(Storage.KillingInTheNameOf.LugriNecromancers) == 1 then
player:setStorageValue(Storage.KillingInTheNameOf.LugriNecromancerCount, killAmount + 1)
elseif(string.lower(getCreatureName(target)) == "shadow pupil") and killAmount < 4000 and player:getStorageValue(Storage.KillingInTheNameOf.LugriNecromancers) == 1 then
player:setStorageValue(Storage.KillingInTheNameOf.LugriNecromancerCount, killAmount + 1)
end
end
return true
end
end