mirror of
https://github.com/ErikasKontenis/SabrehavenServer.git
synced 2025-04-30 01:29:21 +02:00
not tested probably nothing is working
This commit is contained in:
parent
b65a56bc97
commit
7cdf6c1b3f
@ -84,6 +84,31 @@ local tasks = {
|
|||||||
['orc'] = {taskerStorage = 17652, progressStorage = 17651, killsRequired = 50},
|
['orc'] = {taskerStorage = 17652, progressStorage = 17651, killsRequired = 50},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local function randomSort(arr)
|
||||||
|
local sorted = {}
|
||||||
|
local rand2
|
||||||
|
local rand
|
||||||
|
local mem
|
||||||
|
for i=1,#arr do
|
||||||
|
sorted[i] = arr[i]
|
||||||
|
end
|
||||||
|
if (#arr <= 1) then
|
||||||
|
return sorted;
|
||||||
|
end
|
||||||
|
for i=1,(#arr)^2 do
|
||||||
|
repeat
|
||||||
|
rand = math.random(1,#sorted)
|
||||||
|
rand2 = math.random(1,#sorted)
|
||||||
|
until rand ~= rand2
|
||||||
|
mem = sorted[rand]
|
||||||
|
sorted[rand] = pgtss[rand2]
|
||||||
|
sorted[rand2] = mem
|
||||||
|
end
|
||||||
|
return sorted
|
||||||
|
end
|
||||||
|
|
||||||
|
local maxPlayersInPartyShare = 2
|
||||||
|
-- not tested probably nothing is working
|
||||||
function onKill(player, target)
|
function onKill(player, target)
|
||||||
if target:isPlayer() or target:getMaster() then
|
if target:isPlayer() or target:getMaster() then
|
||||||
return true
|
return true
|
||||||
@ -98,17 +123,24 @@ function onKill(player, target)
|
|||||||
if party ~= nil and party:isSharedExperienceEnabled() then
|
if party ~= nil and party:isSharedExperienceEnabled() then
|
||||||
players = party:getMembers() -- all members of the party
|
players = party:getMembers() -- all members of the party
|
||||||
players[#players + 1] = party:getLeader() -- don't forget the leader
|
players[#players + 1] = party:getLeader() -- don't forget the leader
|
||||||
|
|
||||||
|
if #players > maxPlayersInPartyShare then -- if more than 4 players are in party than shuffle the table and give task bonus only for the first 4 players
|
||||||
|
players = randomSort(players)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
players = { player } -- no party? then just the player
|
players = { player } -- no party? then just the player
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, member in ipairs(players) do
|
for i, member in ipairs(players) do
|
||||||
local inProgressQuest = member:getStorageValue(task.taskerStorage)
|
print(i)
|
||||||
if inProgressQuest == task.progressStorage then
|
if i < maxPlayersInPartyShare then
|
||||||
local playerQuestKills = member:getStorageValue(task.progressStorage)
|
local inProgressQuest = member:getStorageValue(task.taskerStorage)
|
||||||
if playerQuestKills < task.killsRequired then
|
if inProgressQuest == task.progressStorage then
|
||||||
member:setStorageValue(task.progressStorage, playerQuestKills + 1)
|
local playerQuestKills = member:getStorageValue(task.progressStorage)
|
||||||
member:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "[Task Tracker] You have killed " .. playerQuestKills + 1 .. "/" .. task.killsRequired .. " " .. targetName .. ".")
|
if playerQuestKills < task.killsRequired then
|
||||||
|
member:setStorageValue(task.progressStorage, playerQuestKills + 1)
|
||||||
|
member:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "[Task Tracker] You have killed " .. playerQuestKills + 1 .. "/" .. task.killsRequired .. " " .. targetName .. ".")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user