• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua onKill players on party sharing xp to get task counted

Stellow

C++/C#/PHP/LUA
Joined
Oct 23, 2008
Messages
1,106
Reaction score
214
Location
Germany
GitHub
eubrunomiguel
Hello, on my task scripts, only the player who deal the last hit get the monster counted, is anyone has a solution for both players in party get it counted?

following my killtask creaturescripts:
function onKill(cid, target, lastHit)
local started = getPlayerStartedTasks(cid)

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(cid, KILLSSTORAGE_BASE + id) < 0 then
setPlayerStorageValue(cid, KILLSSTORAGE_BASE + id, 0)
end
if getPlayerStorageValue(cid, KILLSSTORAGE_BASE + id) < tasks[id].killsRequired then
setPlayerStorageValue(cid, KILLSSTORAGE_BASE + id, getPlayerStorageValue(cid, KILLSSTORAGE_BASE + id) + 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, getPlayerStorageValue(cid, KILLSSTORAGE_BASE + id) .. "/" .. tasks[id].killsRequired .. " " .. tasks[id].raceName .. " already killed.")
end
end
end
end
return true
end
 
As stated by ~LordFire, you should iterate over members in the party if it exists.
This code only works on TFS 1.X

Lua:
local players
local party = player:getParty()
if party ~= nil then
    players = party:getMembers() -- all members of the party
    players[#players + 1] = party:getLeader() -- don't forget the leader
else
    players = { player } -- no party? then just the player
end

for _, member in ipairs(players) do
    ... your task related code ...
end
 
Back
Top