• 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 Catapult Problem

Critico

Sexy
Joined
Mar 25, 2010
Messages
370
Reaction score
176
I need to increase the sqm of this script, over 14 bugs...

Code:
local config = {
    catapults = {
        [6801] = "sul",
        [6802] = "norte",
    },
    distance = 14, -- max 14 sqm's
    directions = {
        ["norte"] = 0,
        ["leste"] = 1,
        ["sul"] = 2,
        ["oeste"] = 3,
    },
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if config.distance % 2 ~= 0 then
        return doPlayerSendCancel(cid, "Sorry, the catapult isn't available right now.") and print("Trade catapult distance for a odd number.")
    elseif not config.catapults[item.actionid] then
        return doPlayerSendCancel(cid, "Sorry, this catapult isn't available right now.") and print("Catapult without actionid or it isn't configured in table.")
    end
    local direction = config.directions[config.catapults[item.actionid]]
    for i = 1, config.distance do
        addEvent(function()
            if getPlayerLookDir(cid) ~= direction then
                doCreatureSetLookDirection(cid, direction)
            end
            local newPos = getPosByDir(i ~= 1 and getThingPos(cid) or toPosition, direction)
            newPos.z = i <= config.distance / 2 and newPos.z - 1 or newPos.z + 1
            if i < config.distance then
                doAreaCombatHealth(0, 0, newPos, 0, 0, 0, 255)
                doCreateItem(460, 1, newPos)
            end
            doTeleportThing(cid, newPos)
        end, i * 120)
    end
    return true
end
 
Back
Top