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

Movevent doesnt work as intended

lico69

New Member
Joined
Mar 11, 2011
Messages
38
Reaction score
1
Hey guys! I tried but none solution till the moment.

If the event is CLOSED it runs fine (return your guild is not the owner of the castle, you are not in a guild and the event is closed only castle owners have access) but if the event START the (you are not in a guild) get ignored and it calls registerToCastle(). Who can save me? Thanks :D

Lua:
function onStepIn(creature, item, pos, fromPosition)
    if Game.getStorageValue(37895) == nil then Game.setStorageValue(37895, 0) end
    if (creature:isPlayer()) then
        if (getCastleEventStatus() <= EVENT_CLOSED) then
            if (castleOwner > 0) then
                local guild = creature:getGuild()
                if (guild) then
                    if (guild:getId() ~= castleOwner) then
                        creature:teleportTo(fromPosition)
                        creature:sendCancelMessage('Your guild is not the owner of the Castle.')
                    end
                else
                    creature:teleportTo(fromPosition)
                    creature:sendCancelMessage('You are not in a guild.')
                end
            else
                creature:teleportTo(fromPosition)
                creature:sendCancelMessage('The event is closed. Only castle owners have access.')
            end
        else
            creature:registerToCastle()
        end
    end
    return true
end
 
Solution
Lua:
function onStepIn(creature, item, pos, fromPosition)
    if Game.getStorageValue(37895) == nil then Game.setStorageValue(37895, 0) end
    if (creature:isPlayer()) then
    local guild = creature:getGuild()
        if guild == nil then
            creature:teleportTo(fromPosition)
            creature:sendCancelMessage('You are not in a guild.')
            return true
        end
    
        if (getCastleEventStatus() <= EVENT_CLOSED) then
            if (castleOwner > 0) then
                if (guild) then
                    if (guild:getId() ~= castleOwner) then
                        creature:teleportTo(fromPosition)
                        creature:sendCancelMessage('Your guild is not the owner of the Castle.')...
Give us getCastleEventStatus().
Lua:
function getCastleEventStatus()
    local st = Game.getStorageValue(EVENTO_CASTELO_STOR)
    local ret
    if (st <= 0) then
        ret = EVENT_CLOSED
    elseif (st == 1) then
        ret = EVENT_WAIT
    elseif (st == 2) then
        ret = EVENT_STARTED
    end

    return ret
end
 
Well, looks like its works as it's supposed to.
If event opens you are able to claim a castle, otherwise only owner guild can enter.
Or am i missing sth?
 
Well, looks like its works as it's supposed to.
If event opens you are able to claim a castle, otherwise only owner guild can enter.
Or am i missing sth?
If the event opens it should only registerToCastle() who have guild > 0
 
So you have to be in any guild at all before stepping in?
Looks about right.
Lua:
function onStepIn(creature, item, pos, fromPosition)
    if Game.getStorageValue(37895) == nil then Game.setStorageValue(37895, 0) end
    if (creature:isPlayer()) then
    local guild = creature:getGuild()
        if guild:getId() <= 0 then
            creature:teleportTo(fromPosition)
            creature:sendCancelMessage('You are not in a guild.')
            return true
        end
       
        if (getCastleEventStatus() <= EVENT_CLOSED) then
            if (castleOwner > 0) then
                if (guild) then
                    if (guild:getId() ~= castleOwner) then
                        creature:teleportTo(fromPosition)
                        creature:sendCancelMessage('Your guild is not the owner of the Castle.')
                    end
            else
                creature:teleportTo(fromPosition)
                creature:sendCancelMessage('The event is closed. Only castle owners have access.')
            end
        else
            creature:registerToCastle()
        end
    end
    return true
end
 
So you have to be in any guild at all before stepping in?
Looks about right.
Lua:
function onStepIn(creature, item, pos, fromPosition)
    if Game.getStorageValue(37895) == nil then Game.setStorageValue(37895, 0) end
    if (creature:isPlayer()) then
    local guild = creature:getGuild()
        if guild:getId() <= 0 then
            creature:teleportTo(fromPosition)
            creature:sendCancelMessage('You are not in a guild.')
            return true
        end
      
        if (getCastleEventStatus() <= EVENT_CLOSED) then
            if (castleOwner > 0) then
                if (guild) then
                    if (guild:getId() ~= castleOwner) then
                        creature:teleportTo(fromPosition)
                        creature:sendCancelMessage('Your guild is not the owner of the Castle.')
                    end
            else
                creature:teleportTo(fromPosition)
                creature:sendCancelMessage('The event is closed. Only castle owners have access.')
            end
        else
            creature:registerToCastle()
        end
    end
    return true
end

Yes, the player need a guild to enter the castle. After trying this it gave me

Code:
[Warning - Event::checkScript] Can not load script: scripts/castleEvent/entradaCastelo.lua
data/movements/scripts/castleEvent/entradaCastelo.lua:27: 'end' expected (to close 'function' at line 1) near <eof>

So I have put an end in the 26 line and now it returns

Code:
Lua Script Error: [MoveEvents Interface]
data/movements/scripts/castleEvent/entradaCastelo.lua:onStepIn
data/movements/scripts/castleEvent/entradaCastelo.lua:5: attempt to index a nil value (local 'guild')
 
Lua:
function onStepIn(creature, item, pos, fromPosition)
    if Game.getStorageValue(37895) == nil then Game.setStorageValue(37895, 0) end
    if (creature:isPlayer()) then
    local guild = creature:getGuild()
        if guild == nil then
            creature:teleportTo(fromPosition)
            creature:sendCancelMessage('You are not in a guild.')
            return true
        end
    
        if (getCastleEventStatus() <= EVENT_CLOSED) then
            if (castleOwner > 0) then
                if (guild) then
                    if (guild:getId() ~= castleOwner) then
                        creature:teleportTo(fromPosition)
                        creature:sendCancelMessage('Your guild is not the owner of the Castle.')
                    end
                end
            else
                creature:teleportTo(fromPosition)
                creature:sendCancelMessage('The event is closed. Only castle owners have access.')
            end
        else
            creature:registerToCastle()
        end
    end
    return true
end
 
Last edited:
Solution
Lua:
function onStepIn(creature, item, pos, fromPosition)
    if Game.getStorageValue(37895) == nil then Game.setStorageValue(37895, 0) end
    if (creature:isPlayer()) then
    local guild = creature:getGuild()
        if guild and guild:getId() <= 0 then
            creature:teleportTo(fromPosition)
            creature:sendCancelMessage('You are not in a guild.')
            return true
        end
    
        if (getCastleEventStatus() <= EVENT_CLOSED) then
            if (castleOwner > 0) then
                if (guild) then
                    if (guild:getId() ~= castleOwner) then
                        creature:teleportTo(fromPosition)
                        creature:sendCancelMessage('Your guild is not the owner of the Castle.')
                    end
                end
            else
                creature:teleportTo(fromPosition)
                creature:sendCancelMessage('The event is closed. Only castle owners have access.')
            end
        else
            creature:registerToCastle()
        end
    end
    return true
end
None errors script errors, but the player without guild is passing.
 
Back
Top