• 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 onStepIn to Onuse

adrenyslopez

Member
Joined
Dec 22, 2015
Messages
173
Reaction score
13
someone help me to pass this scripts to onUse? let it be by clicking please



Lua:
local config = {
    [10804] = {position = Position(33686, 31599, 14)}
}

local MaliceTimer = MoveEvent()

function MaliceTimer.onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return false
    end

    for index, value in pairs(config) do
        if item.actionid == index then
            if(item.actionid == 10804)then
                if(player:getStorageValue(69805) > os.time())then
                    creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have faced this boss in the last 20 hours.\nNext time date:  " .. os.date("%d/%b/%Y - %X", creature:getStorageValue(69805))..".")
                    player:teleportTo(fromPosition, true)
                    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
                    return false
                end
            end
            doSendMagicEffect(player:getPosition(), CONST_ME_TELEPORT)
            player:teleportTo(value.position)
            doSendMagicEffect(value.position, CONST_ME_TELEPORT)       
        end
    end
end

MaliceTimer:type("stepin")

for index, value in pairs(config) do
    MaliceTimer:aid(index)
end

MaliceTimer:register()




 







function mathtime(table)
    local unit = {"sec", "min", "hour", "day"}
    for i, v in pairs(unit) do
        if v == table[2] then
            return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
        end
    end
    return error("Bad declaration in mathtime function.")
end
 
Solution
someone help me to pass this scripts to onUse? let it be by clicking please



Lua:
local config = {
    [10804] = {position = Position(33686, 31599, 14)}
}

local MaliceTimer = MoveEvent()

function MaliceTimer.onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return false
    end

    for index, value in pairs(config) do
        if item.actionid == index then
            if(item.actionid == 10804)then
                if(player:getStorageValue(69805) > os.time())then
                    creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have faced this boss in the last 20 hours.\nNext time date:  " .. os.date("%d/%b/%Y - %X", creature:getStorageValue(69805))..".")...

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,678
Solutions
406
Reaction score
3,789
someone help me to pass this scripts to onUse? let it be by clicking please



Lua:
local config = {
    [10804] = {position = Position(33686, 31599, 14)}
}

local MaliceTimer = MoveEvent()

function MaliceTimer.onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return false
    end

    for index, value in pairs(config) do
        if item.actionid == index then
            if(item.actionid == 10804)then
                if(player:getStorageValue(69805) > os.time())then
                    creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have faced this boss in the last 20 hours.\nNext time date:  " .. os.date("%d/%b/%Y - %X", creature:getStorageValue(69805))..".")
                    player:teleportTo(fromPosition, true)
                    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
                    return false
                end
            end
            doSendMagicEffect(player:getPosition(), CONST_ME_TELEPORT)
            player:teleportTo(value.position)
            doSendMagicEffect(value.position, CONST_ME_TELEPORT)   
        end
    end
end

MaliceTimer:type("stepin")

for index, value in pairs(config) do
    MaliceTimer:aid(index)
end

MaliceTimer:register()












function mathtime(table)
    local unit = {"sec", "min", "hour", "day"}
    for i, v in pairs(unit) do
        if v == table[2] then
            return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
        end
    end
    return error("Bad declaration in mathtime function.")
end
change
Lua:
local MaliceTimer = MoveEvent()
to
Lua:
local MaliceTimer = Action()
--
change
Lua:
function MaliceTimer.onStepIn(creature, item, position, fromPosition)
to
Lua:
function MaliceTimer.onUse(player, item, fromPosition, target, toPosition, isHotkey)
---
remove
Lua:
    local player = creature:getPlayer()
    if not player then
        return false
    end
---
change
Lua:
creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have faced this boss in the last 20 hours.\nNext time date:  " .. os.date("%d/%b/%Y - %X", creature:getStorageValue(69805))..".")
to
Lua:
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have faced this boss in the last 20 hours.\nNext time date:  " .. os.date("%d/%b/%Y - %X", creature:getStorageValue(69805))..".")
---
remove
Lua:
MaliceTimer:type("stepin")
 
Solution
OP
OP
A

adrenyslopez

Member
Joined
Dec 22, 2015
Messages
173
Reaction score
13
change
Lua:
local MaliceTimer = MoveEvent()
to
Lua:
local MaliceTimer = Action()
--
change
Lua:
function MaliceTimer.onStepIn(creature, item, position, fromPosition)
to
Lua:
function MaliceTimer.onUse(player, item, fromPosition, target, toPosition, isHotkey)
---
remove
Lua:
    local player = creature:getPlayer()
    if not player then
        return false
    end
---
change
Lua:
creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have faced this boss in the last 20 hours.\nNext time date:  " .. os.date("%d/%b/%Y - %X", creature:getStorageValue(69805))..".")
to
Lua:
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have faced this boss in the last 20 hours.\nNext time date:  " .. os.date("%d/%b/%Y - %X", creature:getStorageValue(69805))..".")
---
remove
Lua:
MaliceTimer:type("stepin")
Lua:
Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/actions/quests/soulwar/Hatred_tiempo.lua:callback
...er/data/scripts/actions/quests/soulwar/Hatred_tiempo.lua:13: attempt to index global 'creature' (a nil value)
stack traceback:
        [C]: in function '__index'
        ...er/data/scripts/actions/quests/soulwar/Hatred_tiempo.lua:13: in function <...er/data/scripts/actions/quests/soulwar/Hatred_tiempo.lua:7>



myscripts
Code:
local config = {
    [10804] = {position = Position(33781, 31601, 14)}
}

local MaliceTimer = Action()

function MaliceTimer.onUse(player, item, fromPosition, target, toPosition, isHotkey)

    for index, value in pairs(config) do
        if item.actionid == index then
            if(item.actionid == 10804)then
                if(player:getStorageValue(69805) > os.time())then
                    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have faced this boss in the last 20 hours.\nNext time date:  " .. os.date("%d/%b/%Y - %X", creature:getStorageValue(69805))..".")
                    player:teleportTo(fromPosition, true)
                    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
                    return false
                end
            end
            doSendMagicEffect(player:getPosition(), CONST_ME_TELEPORT)
            player:teleportTo(value.position)
            doSendMagicEffect(value.position, CONST_ME_TELEPORT)       
        end
    end
end


for index, value in pairs(config) do
    MaliceTimer:aid(index)
end

MaliceTimer:register()




 







function mathtime(table)
    local unit = {"sec", "min", "hour", "day"}
    for i, v in pairs(unit) do
        if v == table[2] then
            return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
        end
    end
    return error("Bad declaration in mathtime function.")
end
 

kamilcioo

Veteran OT User
Joined
Jul 25, 2008
Messages
951
Solutions
1
Reaction score
276
Lua:
Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/actions/quests/soulwar/Hatred_tiempo.lua:callback
...er/data/scripts/actions/quests/soulwar/Hatred_tiempo.lua:13: attempt to index global 'creature' (a nil value)
stack traceback:
        [C]: in function '__index'
        ...er/data/scripts/actions/quests/soulwar/Hatred_tiempo.lua:13: in function <...er/data/scripts/actions/quests/soulwar/Hatred_tiempo.lua:7>



myscripts
Code:
local config = {
    [10804] = {position = Position(33781, 31601, 14)}
}

local MaliceTimer = Action()

function MaliceTimer.onUse(player, item, fromPosition, target, toPosition, isHotkey)

    for index, value in pairs(config) do
        if item.actionid == index then
            if(item.actionid == 10804)then
                if(player:getStorageValue(69805) > os.time())then
                    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have faced this boss in the last 20 hours.\nNext time date:  " .. os.date("%d/%b/%Y - %X", creature:getStorageValue(69805))..".")
                    player:teleportTo(fromPosition, true)
                    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
                    return false
                end
            end
            doSendMagicEffect(player:getPosition(), CONST_ME_TELEPORT)
            player:teleportTo(value.position)
            doSendMagicEffect(value.position, CONST_ME_TELEPORT)      
        end
    end
end


for index, value in pairs(config) do
    MaliceTimer:aid(index)
end

MaliceTimer:register()












function mathtime(table)
    local unit = {"sec", "min", "hour", "day"}
    for i, v in pairs(unit) do
        if v == table[2] then
            return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
        end
    end
    return error("Bad declaration in mathtime function.")
end
creature:getStorageValue(69805) to player:getStorageValue(69805)
 
Top