APTGET
New Member
- Joined
- Dec 29, 2020
- Messages
- 37
- Reaction score
- 3
I'm trying to get players in one part to be able to share the same task. Even if it is via Target (if the player is in the target, it counts). I have tried something like:
- Creaturescript tasks.lua
I'm using the nostalrius 7.72 server for the tests. Below I am leaving Tusker.srv (npc) and gen-tasks.ndb (script) I tried to merge the original code with another one, but obviously I am VERY LOST. Can anyone help me with this?
I just need to be able to do group tasks.
----------------------------------------------------------------------------------------
Here is the script from which I got some parts:
Tusker.srv (npc) and gen-tasks.ndb (script)
- Creaturescript tasks.lua
Lua:
local config = {
["crocodile"] = {count = 100, storage = 1001, start = 1, plural = "crocodiles"},
["dwarf"] = {count = 200, storage = 1002, start = 1, plural = "dwarves"},
["dwarf soldier"] = {count = 200, storage = 1002, start = 1, plural = "dwarves"},
}
function onKill(player, target, lastHit, isParty)
local monster = config[target:getName():lower()]
local members = getPartyMembers(player)
local validTaskT = {}
if not monster or target:getMaster() then
if isPlayer(target) then return true end
return true
end
if not isSummon(target) then
if not members then
else
if lastHit then
checkPlayerOnScreen(player, members, validTaskT)
for i, validTaskMembers in ipairs(validTaskT) do
taskFunctions(validTaskMembers, target, true)
end
end
end
end
local storageValue = player:getStorageValue(monster.storage)
if storageValue >= monster.start then
if storageValue >= monster.count then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have already killed " .. monster.count .. " " .. monster.plural .. ". Report back to Tusker in Thais.")
else
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have killed [" .. storageValue .. "/" .. monster.count .. "] " .. monster.plural .. ".")
end
player:setStorageValue(monster.storage, storageValue + 1)
end
return true
end
function checkPlayerOnScreen(player, membersT, validTaskT)
local rangeX, rangeY = 7, 7
local spectators = getSpectators(getCreaturePosition(player), rangeX, rangeY, false)
if spectators then
for _, spectator in ipairs(spectators) do
if isPlayer(spectator) then
for __, member in ipairs(membersT) do
if member == spectator then
table.insert(validTaskT, member)
end
end
end
end
end
end
I'm using the nostalrius 7.72 server for the tests. Below I am leaving Tusker.srv (npc) and gen-tasks.ndb (script) I tried to merge the original code with another one, but obviously I am VERY LOST. Can anyone help me with this?
I just need to be able to do group tasks.
----------------------------------------------------------------------------------------
Here is the script from which I got some parts:
Code:
function onKill(cid, target, lastHit)
local members = getPartyMembers(cid)
local validTaskT = {}
if not isSummon(target) then
if not members then
taskFunctions(cid, target, false)
else
if lastHit then
checkPlayerOnScreen(cid, members, validTaskT)
for i, validTaskMembers in ipairs(validTaskT) do
taskFunctions(validTaskMembers, target, true)
end
end
end
end
return true
end
function taskFunctions(value, target, isParty)
local started = getPlayerStartedTasks(value)
if isPlayer(target) then return true end
if started and #started > 0 then
for _, id in ipairs(started) do
if isInArray(tasks[id].creatures, getCreatureName(target):lower()) then
if getPlayerStorageValue(value, KILLSSTORAGE_BASE + id) < 0 then
setPlayerStorageValue(value, KILLSSTORAGE_BASE + id, 0)
end
if getPlayerStorageValue(value, KILLSSTORAGE_BASE + id) < tasks[id].killsRequired then
setPlayerStorageValue(value, KILLSSTORAGE_BASE + id, getPlayerStorageValue(value, KILLSSTORAGE_BASE + id) + 1)
doPlayerSendTextMessage(value, MESSAGE_STATUS_CONSOLE_ORANGE, getPlayerStorageValue(value, KILLSSTORAGE_BASE + id) .. "/" .. tasks[id].killsRequired .. " " .. tasks[id].raceName .. " already killed.")
end
end
end
end
end
function checkPlayerOnScreen(cid, membersT, validTaskT)
local rangeX, rangeY = 7, 7
local spectators = getSpectators(getCreaturePosition(cid), rangeX, rangeY, false)
if spectators then
for _, spectator in ipairs(spectators) do
if isPlayer(spectator) then
for __, member in ipairs(membersT) do
if member == spectator then
table.insert(validTaskT, member)
end
end
end
end
end
end
Tusker.srv (npc) and gen-tasks.ndb (script)
Attachments
-
NPC script.zip5.1 KB · Views: 6 · VirusTotal