• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Kill counts in this area

Discovery

Developing myself
Joined
Apr 16, 2010
Messages
562
Solutions
11
Reaction score
261
Location
Neverland
Hello everyone!

I have a doubt about the function inRange. I tried now put a limit in the party area based in leader, but I fail.
The idea is adapt to the player counts +1 in the task if him there in this specific range.

How I can use the range based in the party leader?


This is my code now:
Code:
domodlib('task_func')
function onKill(cid, target, lastHit)
    if(isMonster(target) == true) then
        local n = string.lower(getCreatureName(target))
        for race, mob in pairs(tasktabble) do
            if getPlayerParty(cid) then
                    membersList = getPartyMembers(cid)
                    if membersList ~= FALSE then
                        for i, _cid in pairs(membersList) do
                            if getPlayerStorageValue(_cid,mob .storage_start) >= 1 then
                                for i = 1,#mob.monster_race do
                                    if n == mob.monster_race[i] then
                                        local contagem = getPlayerStorageValue(_cid, mob.storage)

                                        if (contagem == -1) then contagem = 1 end
                                        if not tonumber(contagem) then return true end
                                        if contagem > mob.count then return true end
                                        if contagem > mob.count then return true end
                                        setPlayerStorageValue(_cid, mob.storage, contagem+1)

                                        doPlayerSendTextMessage(_cid, MESSAGE_STATUS_CONSOLE_ORANGE,""..(contagem == mob.count and "Congratulations! You finished the task of "..race.."." or "defeated. Total [" .. contagem .. "/" .. mob.count .. "] " .. race .. ".").."")
                                    end
                                end
                            end
                        end
                    end
            else
                if getPlayerStorageValue(cid,mob .storage_start) >= 1 then
                    for i = 1,#mob.monster_race do
                        if n == mob.monster_race[i] then
                            local contagem = getPlayerStorageValue(cid, mob.storage)

                            if (contagem == -1) then contagem = 1 end
                            if not tonumber(contagem) then return true end
                            if contagem > mob.count then return true end
                            if contagem > mob.count then return true end
                            setPlayerStorageValue(cid, mob.storage, contagem+1)

                            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,""..(contagem == mob.count and "Congratulations! You finished the task of "..race.."." or "defeated. Total [" .. contagem .. "/" .. mob.count .. "] " .. race .. ".").."")
                        end
                    end
                end
            end
        end
    end
    return true
end

Anyone can help me update this code with X area range limit?

Thanks in advance!
:)
 
I made it myself and works good!

If somebody need it too:
That's here:

OTX 7.4 - DISTRO

Code:
domodlib('task_func')
function onKill(cid, target, lastHit)
    local leaderpt=nil
    local contagem=nil
    if(isMonster(target) == true) then
        local n = string.lower(getCreatureName(target))
        for race, mob in pairs(tasktabble) do
            if getPlayerParty(cid) then
                    leaderpt=getPlayerPosition(cid)
                    membersList = getPartyMembers(cid)
                    if membersList ~= FALSE then
                        for i, _cid in pairs(membersList) do
                            if getPlayerStorageValue(_cid,mob .storage_start) >= 1 then
                                for i = 1,#mob.monster_race do
                                    if n == mob.monster_race[i] then
                                        distdiff=getDistanceBetween(leaderpt, getPlayerPosition(_cid))
                                        if(distdiff<=15) then
                                            contagem = getPlayerStorageValue(_cid, mob.storage)

                                            if (contagem == -1) then contagem = 1 end
                                            if not tonumber(contagem) then return true end
                                            if contagem > mob.count then return true end
                                            if contagem > mob.count then return true end
                                            setPlayerStorageValue(_cid, mob.storage, contagem+1)

                                            doPlayerSendTextMessage(_cid, MESSAGE_STATUS_CONSOLE_ORANGE,""..(contagem == mob.count and "Congratulations! You finished the task of "..race.."." or "defeated. Total [" .. contagem .. "/" .. mob.count .. "] " .. race .. ".").."")
                                        end
                                    end
                                end
                            end
                        end
                    end
            else
                if getPlayerStorageValue(cid,mob .storage_start) >= 1 then
                    for i = 1,#mob.monster_race do
                        if n == mob.monster_race[i] then
                            contagem = getPlayerStorageValue(cid, mob.storage)

                            if (contagem == -1) then contagem = 1 end
                            if not tonumber(contagem) then return true end
                            if contagem > mob.count then return true end
                            if contagem > mob.count then return true end
                            setPlayerStorageValue(cid, mob.storage, contagem+1)

                            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,""..(contagem == mob.count and "Congratulations! You finished the task of "..race.."." or "defeated. Total [" .. contagem .. "/" .. mob.count .. "] " .. race .. ".").."")
                        end
                    end
                end
            end
        end
    end
    return true
end
 
Last edited:
Back
Top