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

Solved error in a END

lopez65

Member
Joined
May 10, 2012
Messages
289
Solutions
1
Reaction score
14
Location
Barcelona
Hello friends
someone who knows lúa could have a look at this script, it gives me error when you started the server requires an "END" on line 147 I think. Your help is appreciated.
thanks and regards.


Code:
function Player:onBrowseField(position)
    return true
end

function Player:onLook(thing, position, distance)
    local description = 'You see ' .. thing:getDescription(distance)
    if self:getGroup():getAccess() then
        if thing:isItem() then
            description = string.format('%s\nItemID: [%d]', description, thing:getId())

            local actionId = thing:getActionId()
            if actionId ~= 0 then
                description = string.format('%s, ActionID: [%d]', description, actionId)
            end

            local uniqueId = thing:getAttribute(ITEM_ATTRIBUTE_UNIQUEID)
            if uniqueId > 0 and uniqueId < 65536 then
                description = string.format('%s, UniqueId: [%d]', description, uniqueId)
            end

            description = description .. '.'
            local itemType = thing:getType()

            local transformEquipId = itemType:getTransformEquipId()
            local transformDeEquipId = itemType:getTransformDeEquipId()
            if transformEquipId ~= 0 then
                description = string.format('%s\nTransformTo: [%d] (onEquip).', description, transformEquipId)
            elseif transformDeEquipId ~= 0 then
                description = string.format('%s\nTransformTo: [%d] (onDeEquip).', description, transformDeEquipId)
            end

            local decayId = itemType:getDecayId()
            if decayId ~= -1 then
                description = string.format('%s\nDecayTo: [%d]', description, decayId)
            end
        elseif thing:isCreature() then
            local str = '%s\nHealth: [%d / %d]'
            if thing:getMaxMana() > 0 then
                str = string.format('%s, Mana: [%d / %d]', str, thing:getMana(), thing:getMaxMana())
            end
            description = string.format(str, description, thing:getHealth(), thing:getMaxHealth()) .. '.'
        end

        local position = thing:getPosition()
        description = string.format(
            '%s\nPosition: [X: %d] [Y: %d] [Z: %d].',
            description, position.x, position.y, position.z
        )

        if thing:isCreature() and thing:isPlayer() then
            description = string.format('%s\nIP: [%s].', description, Game.convertIpToString(thing:getIp()))
        end
    end
    self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end

function Player:onLookInBattleList(creature, distance)
    local description = 'You see ' .. creature:getDescription(distance)
    if self:getGroup():getAccess() then
        local str = '%s\nHealth: [%d / %d]'
        if creature:getMaxMana() > 0 then
            str = string.format('%s, Mana: [%d / %d]', str, creature:getMana(), creature:getMaxMana())
        end
        description = string.format(str, description, creature:getHealth(), creature:getMaxHealth()) .. '.'

        local position = creature:getPosition()
        description = string.format(
            '%s\nPosition: [X: %d] [Y: %d] [Z: %d].',
            description, position.x, position.y, position.z
        )

        if creature:isPlayer() then
            description = string.format('%s\nIP: [%s].', description, Game.convertIpToString(creature:getIp()))
        end
    end
    self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end

function Player:onLookInTrade(partner, item, distance)
    self:sendTextMessage(MESSAGE_INFO_DESCR, 'You see ' .. item:getDescription(distance))
end

function Player:onLookInShop(itemType, count)
    return true
end

function Player:onMoveItem(item, count, fromPosition, toPosition)
  function isHousetile(position)
   local t = Tile(position)
   if t == nil then
   return false
   end
   return t:hasFlag(TILESTATE_HOUSE)
   end
   if isHousetile(item:getPosition()) then   -- yup, it's a housetile
     if self:getAccountType() == ACCOUNT_TYPE_GOD and self:getGroup():getAccess() then -- is server admin
       return true
     end
     if Tile(item:getPosition()):getHouse():getOwnerGuid() == self:getGuid() then -- is house owner
       return true
     end
     if isHousetile(self:getPosition()) then -- is inside a house
       return true
     end
     -- random player
     self:sendCancelMessage("Sorry, not possible.")
     return false
   end
return true
end

function Player:onTradeRequest(target, item)
   if isHousetile(item:getPosition()) then   -- is this a house
     if self:getAccountType() == ACCOUNT_TYPE_GOD and self:getGroup():getAccess() then -- is server admin
       return true
     end
     if Tile(item:getPosition()):getHouse():getOwnerGuid() == self:getGuid() then -- is house owner
       return true
     end
     if isHousetile(self:getPosition()) then -- is inside a house
       return true
     end
     -- random player
     self:sendCancelMessage("This item doesn't belong to you.")
     return false
   end
return true
end

    if isInArray({1738, 1740, 1747, 1748, 1749}, item:getId()) and item:getActionId() > 0 then
        self:sendCancelMessage('You cannot move this object.')
        return false
    elseif item:getId() == 7466 then
        self:sendCancelMessage('You cannot move this object.')
        return false
    end

    if fromPosition.x == 65535 and toPosition.x == 65535
            and item:getId() == 8710 and self:getItemCount(8710) == 2 and self:getStorageValue(Storage.RookgaardTutorialIsland.cockroachLegsMsgStorage) ~= 1 then
        self:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Well done, you have enough cockroach legs! You should head back to Santiago with them. Climb the ladder to the north to exit.')
        self:setStorageValue(Storage.RookgaardTutorialIsland.cockroachLegsMsgStorage, 1)
        self:setStorageValue(Storage.RookgaardTutorialIsland.SantiagoNpcGreetStorage, 6)
    end
    return true
end      <-------  this is line 147

function Player:onMoveCreature(creature, fromPosition, toPosition)
    return true
end

function Player:onTurn(direction)
    return true
end

function Player:onTradeRequest(target, item)
    if isInArray({1738, 1740, 1747, 1748, 1749, 8766}, item:getId()) and item:getActionId() > 0 then
        self:sendCancelMessage('Sorry, not possible.')
        return false
    end
    return true
end

function Player:onTradeAccept(target, item, targetItem)
    return true
end

function Player:onGainExperience(source, exp, rawExp)
    return exp
end

function Player:onLoseExperience(exp)
    return exp
end
[RESOLVED]
 
Last edited:
Remove
Code:
return true
end
On line 109-110

Then remove
Code:
function Player:onTradeRequest(target, item)
  if isHousetile(item:getPosition()) then  -- is this a house
  if self:getAccountType() == ACCOUNT_TYPE_GOD and self:getGroup():getAccess() then -- is server admin
  return true
  end
  if Tile(item:getPosition()):getHouse():getOwnerGuid() == self:getGuid() then -- is house owner
  return true
  end
  if isHousetile(self:getPosition()) then -- is inside a house
  return true
  end
  -- random player
  self:sendCancelMessage("This item doesn't belong to you.")
  return false
  end
return true
end

And add this part
Code:
  if isHousetile(item:getPosition()) then  -- is this a house
       if self:getAccountType() == ACCOUNT_TYPE_GOD and self:getGroup():getAccess() then -- is server admin
           return true
       end
       if Tile(item:getPosition()):getHouse():getOwnerGuid() == self:getGuid() then -- is house owner
           return true
       end
       if isHousetile(self:getPosition()) then -- is inside a house
           return true
       end
       -- random player
       self:sendCancelMessage("This item doesn't belong to you.")
       return false
   end
Under function Player: onTradeRequest(target, item) on line 155
 
Last edited:
Remove
Code:
return true
end
On line 109-110

Then remove
Code:
function Player:onTradeRequest(target, item)
  if isHousetile(item:getPosition()) then  -- is this a house
  if self:getAccountType() == ACCOUNT_TYPE_GOD and self:getGroup():getAccess() then -- is server admin
  return true
  end
  if Tile(item:getPosition()):getHouse():getOwnerGuid() == self:getGuid() then -- is house owner
  return true
  end
  if isHousetile(self:getPosition()) then -- is inside a house
  return true
  end
  -- random player
  self:sendCancelMessage("This item doesn't belong to you.")
  return false
  end
return true
end

And add this part
Code:
  if isHousetile(item:getPosition()) then  -- is this a house
       if self:getAccountType() == ACCOUNT_TYPE_GOD and self:getGroup():getAccess() then -- is server admin
           return true
       end
       if Tile(item:getPosition()):getHouse():getOwnerGuid() == self:getGuid() then -- is house owner
           return true
       end
       if isHousetile(self:getPosition()) then -- is inside a house
           return true
       end
       -- random player
       self:sendCancelMessage("This item doesn't belong to you.")
       return false
   end
Under function Player: onTradeRequest(target, item) on line 155

Uhh now get a new error: S

Lua Script Error: [Action Interface]
data/actions/scripts/house_shop.lua:eek:nUse
data/actions/scripts/house_shop.lua:464: attempt to call global 'isHousetile' (a
nil value)
stack traceback:
[C]: in function 'isHousetile'
data/actions/scripts/house_shop.lua:464: in function <data/actions/scrip
ts/house_shop.lua:463>
 
You can add the function isHousetile to that aswell or in global.lua.
Code:
function isHousetile(position)
     local t = Tile(position)
     if t == nil then
         return false
     end
     return t:hasFlag(TILESTATE_HOUSE)
end
 
Back
Top