shakal1994
Member
- Joined
- Nov 20, 2020
- Messages
- 79
- Reaction score
- 15
I'm using this creativescripts, I wanted you to tell everyone who attacks the monster, can you help me??
I got a creaturescripts that counts the party, the problem is that it counts the one that deals the most damage and the last hit, so it counts 2 times for the one that deals the most damage and the last hit
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
if isInArray(tasks[taskId].creatures, targetName) then
local killAmount = player:getStorageValue(KILLSSTORAGE_BASE + taskId)
if killAmount < tasks[taskId].killsRequired then
player:setStorageValue(KILLSSTORAGE_BASE + taskId, killAmount + 1)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE,'You kill: ' .. killAmount + 1 .. "/" .. tasks[taskId].killsRequired .. " " ..tasks[taskId].raceName)
else
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE,'You complete task of ' ..tasks[taskId].raceName)
end
end
end
return true
end
--MESSAGE_STATUS_DEFAULT
Post automatically merged:
I got a creaturescripts that counts the party, the problem is that it counts the one that deals the most damage and the last hit, so it counts 2 times for the one that deals the most damage and the last hit
function onKill(player, target)
if target:isPlayer() or target:getMaster() then
return true
end
local party = player:getParty()
print("Killer: " .. player:getName())
print("Target: " .. target:getName())
local players = {}
if party then
print("There was a party")
players = party:getMembers()
leader = party:getLeader()
print("Party leader:" .. leader:getName())
table.insert(players, leader)
else
print("Solo")
players = {player}
end
print("Number of players in party: " .. #players)
for p = 1, #players do
local partyMember = players[p]
print("Processing kill for player " .. partyMember:getName())
local targetName, startedTasks, taskId = target:getName():lower(), partyMember:getStartedTasks()
for i = 1, #startedTasks do
taskId = startedTasks
if isInArray(tasks[taskId].creatures, targetName) then
local killAmount = partyMember:getStorageValue(KILLSSTORAGE_BASE + taskId)
if killAmount < tasks[taskId].killsRequired then
partyMember:setStorageValue(KILLSSTORAGE_BASE + taskId, killAmount + 1)
partyMember:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE,'You kill: ' .. killAmount + 1 .. "/" .. tasks[taskId].killsRequired .. " " ..tasks[taskId].raceName)
else
partyMember:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE,'You complete task of ' ..tasks[taskId].raceName)
end
end
end
end
return true
end
--MESSAGE_STATUS_DEFAULT
Last edited: