• 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!

Remove monster [Revscript]

tomaszek123

Member
Joined
May 29, 2014
Messages
71
Solutions
1
Reaction score
18
Hello,

I am a total newbie into scripting i can just do basics , I am trying for 2 hours adding function that removes monster if player has left room or died with no success.

if anyone can help TIA!

Lua:
local testAction = Action()

function areaHasPlayer(center, radiusX, radiusY)
    return #Game.getSpectators(center, false, true, radiusX, radiusX, radiusY, radiusY) > 0
end


local roomCenter = Position(1025, 1434, 8)
local radius = {15, 15}

local config = {
    storage = 1001,
    time = 120,
    destination = {x=1025, y=1434, z=8},
    price = 20 * 10000,
}

function testAction.onUse(cid, player, item, fromPosition, target, toPosition, isHotkey)
    if getPlayerStorageValue(cid, config.storage) - os.time() > 1 then
        doPlayerSendTextMessage(cid, 22, "You must wait "..config.time.." minutes before using this obelisk again.")
        return false
    end
    if areaHasPlayer(roomCenter, unpack(radius)) then
        cid:sendTextMessage(MESSAGE_INFO_DESCR, "Someone is already doing this obelisk.")

        return true
    end

    if not cid:removeMoney(config.price) then
        cid:sendCancelMessage(string.format("You don't have enough money, you need %s crystal coins.", config.price / 10000))
        return true
    end
    if getCreatureCondition(cid, CONDITION_INFIGHT) == false then
        setPlayerStorageValue(cid, config.storage, os.time() + config.time * 60)
        doTeleportThing(cid, config.destination) 
        Game.createMonster("Fallen Omen", Position(1021, 1424, 8))
        cid:sendTextMessage(MESSAGE_STATUS_WARNING, "Stay alive or die.")
    else
        doPlayerSendTextMessage(cid, 22, "You cant teleport while in battle.")
    end
    return true
end

testAction:aid(9355)
testAction:register()
 
you should give a look here:
 
Back
Top