• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Log in temple

MadMOOK

Hoo
Joined
Apr 20, 2011
Messages
802
Reaction score
44
Is there a way to make it so if people log out in certain places, they are teleported to temple on loginso they dont log back in my event places?
 
Code:
-- above function onLogin(cid)
local configareas = {
    {from = {x = 800, y = 800, z = 7}, to = {x = 850, y = 850, z = 7}, teleport = {x = 1000, y = 1000, z = 7}}
}

-- below function onLogin(cid)
    local tmpPos = getThingPos(cid)
    for _, c in pairs(configareas) do
        if tmpPos.x >= c.from.x and tmpPos.x <= c.to.x and tmpPos.y >= c.from.y and tmpPos.y <= c.to.y and tmpPos.z >= c.from.z and tmpPos.z <= c.to.z then
            doTeleportThing(cid, c.teleport)
            break
        end
    end

from = is the top left corner of the area
to = is the bottom right corner of the area
teleport = is the position where the player gets teleported
 
Code:
local config = {
    loginMessage = getConfigValue('loginMessage'),
    useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}

function onLogin(cid)

if isPremium(cid) then
        doPlayerSetExperienceRate(cid, 1.5)
        doPlayerSetSkills(cid, 1.5)
        doPlayerSetMagicRate(cid, 1.5)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are premium, enjoy 50% extra experience, skills and magic level rates.")
    end
    local loss = getConfigValue('deathLostPercent')
    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
    end

    local accountManager = getPlayerAccountManager(cid)
    if(accountManager == MANAGER_NONE) then
        local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
        if(lastLogin > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
            str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
        else
            str = str .. " Please choose your outfit."
            doPlayerSendOutfitWindow(cid)
        end

        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
    elseif(accountManager == MANAGER_NAMELOCK) then
        addEvent(valid(doCreatureSay), 500, cid, "Hello, it appears that your character has been locked for name violating rules, what new name would you like to have?", TALKTYPE_PRIVATE_NP, true, cid)
    elseif(accountManager == MANAGER_ACCOUNT) then
        addEvent(valid(doCreatureSay), 500, cid, "Hello, type {account} to manage your account. If you would like to start over, type {cancel} anywhere.", TALKTYPE_PRIVATE_NP, true, cid)
    else
        addEvent(valid(doCreatureSay), 500, cid, "Hello, type {account} to create an account or {recover} to recover an account.", TALKTYPE_PRIVATE_NP, true, cid)
    end

    if(not isPlayerGhost(cid)) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    end

    registerCreatureEvent(cid, "Idle")
    registerCreatureEvent(cid, "Mail")
    if(getPlayerOperatingSystem(cid) >= CLIENTOS_OTCLIENT_LINUX) then
        registerCreatureEvent(cid, "ExtendedOpcode")
    end

    registerCreatureEvent(cid, "ReportBug")
    if(config.useFragHandler) then
        registerCreatureEvent(cid, "SkullCheck")
    end
    registerCreatureEvent(cid, "VipCheck")
    registerCreatureEvent(cid, "Killer")
    registerCreatureEvent(cid, "Killerz")
    registerCreatureEvent(cid, "GuildEvents")
    registerCreatureEvent(cid, "AdvanceSave")
    registerCreatureEvent(cid, "RebirthDescription")
    registerCreatureEvent(cid, "BlessCheck")
    registerCreatureEvent(cid, "level8")
    registerCreatureEvent(cid, "ZombieAttack")
    registerCreatureEvent(cid, "KillingInTheNameOf")
    registerCreatureEvent(cid, "ItemInMonster")
    registerCreatureEvent (cid, "PointSystem")
    return true
end
 
Back
Top