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

RevScripts if step on x/y/z give text in motd

Lbtg

Advanced OT User
Joined
Nov 22, 2008
Messages
2,394
Reaction score
162
Tfs ,1.4+ Revscript

hey i want to ask for help to make such script:


if player step on x/y/z give him motd with text 'bla bla bla'' and only button 'OK' with just turns of motd. in config also i would like to be aible to setup if always if step on x/y/z give or just first time for player, also would be nice if i can have multiple config lines with different texts for different places.


the main purpose to give info about the game while player play, explore, enter some mistery spot etc...

i think everyone would love this also :)
 
Solution
LUA:
local config = {
    {
        position = Position(2500, 2510, 7),
        motd = "Welcome to the room.",
        storageKey = 1234 -- optional
    },
    {
        position = Position(2600, 2520, 7),
        motd = "Welcome to the room 2."
    }
}
local motdByPos = {}
for _, entry in ipairs(config) do
    local pos = entry.position
    local key = string.format("%d:%d:%d", pos.x, pos.y, pos.z)
    motdByPos[key] = {motd = entry.motd, storageKey = entry.storageKey}
end
local moveEvent = MoveEvent()
function moveEvent.onStepIn(creature, item, pos, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return true
    end
    local key = string.format("%d:%d:%d", pos.x, pos.y, pos.z)
    local info =...
LUA:
local config = {
    {
        position = Position(2500, 2510, 7),
        motd = "Welcome to the room.",
        storageKey = 1234 -- optional
    },
    {
        position = Position(2600, 2520, 7),
        motd = "Welcome to the room 2."
    }
}
local motdByPos = {}
for _, entry in ipairs(config) do
    local pos = entry.position
    local key = string.format("%d:%d:%d", pos.x, pos.y, pos.z)
    motdByPos[key] = {motd = entry.motd, storageKey = entry.storageKey}
end
local moveEvent = MoveEvent()
function moveEvent.onStepIn(creature, item, pos, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return true
    end
    local key = string.format("%d:%d:%d", pos.x, pos.y, pos.z)
    local info = motdByPos[key]
    if not info then
        return true
    end
    if info.storageKey then
        local storageValue = tonumber(player:getStorageValue(info.storageKey)) or -1
        if storageValue == -1 then
            player:popupFYI(info.motd)
            player:setStorageValue(info.storageKey, 1)
        end
    else
        player:popupFYI(info.motd)
    end
    return true
end
for _, entry in pairs(config) do
    moveEvent:position(entry.position)
end
moveEvent:register()
 
Solution
LUA:
local config = {
    {
        position = Position(2500, 2510, 7),
        motd = "Welcome to the room.",
        storageKey = 1234 -- optional
    },
    {
        position = Position(2600, 2520, 7),
        motd = "Welcome to the room 2."
    }
}
local motdByPos = {}
for _, entry in ipairs(config) do
    local pos = entry.position
    local key = string.format("%d:%d:%d", pos.x, pos.y, pos.z)
    motdByPos[key] = {motd = entry.motd, storageKey = entry.storageKey}
end
local moveEvent = MoveEvent()
function moveEvent.onStepIn(creature, item, pos, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return true
    end
    local key = string.format("%d:%d:%d", pos.x, pos.y, pos.z)
    local info = motdByPos[key]
    if not info then
        return true
    end
    if info.storageKey then
        local storageValue = tonumber(player:getStorageValue(info.storageKey)) or -1
        if storageValue == -1 then
            player:popupFYI(info.motd)
            player:setStorageValue(info.storageKey, 1)
        end
    else
        player:popupFYI(info.motd)
    end
    return true
end
for _, entry in pairs(config) do
    moveEvent:position(entry.position)
end
moveEvent:register()
works perfect, thanks alot! :)))
 
Back
Top