• 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 Task kills.lua creaturescript

paweleq2000

New Member
Joined
Feb 18, 2011
Messages
161
Reaction score
4
Hello, I want to make in this bellow script message which inform us about how much monster we have killed.

Lua:
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[i]
        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)
            end
        end
    end
    return true
end

Something like this(but it isn't work):
Lua:
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, getCreatureStorage(cid, KILLSSTORAGE_BASE + id) .. "/" .. tasks[taskId].killsRequired .. " " .. tasks[taskId].raceName .. " already killed.")
end
 
try this

Lua:
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[i]
        if isInArray(tasks[taskId].creatures, targetName) then
            local killAmount = player:getStorageValue(KILLSSTORAGE_BASE + taskId)
            if killAmount < tasks[taskId].killsRequired then
                local newAmount = KILLSSTORAGE_BASE + taskId
                player:setStorageValue(newAmount, killAmount + 1)
                player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "You have killed " .. player:getStorageValue(newAmount) .. " out of " .. tasks[taskId].killsRequired .. " " .. tasks[taskId].raceName)
            end
        end
    end
    return true
end
 
Back
Top