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

Solved creature.lua <eof> error [SOLVED]

elkingahmed

New Member
Joined
May 31, 2012
Messages
116
Reaction score
2
TFS 1.1
why do i get this error ?
ERROR
[Warning - Events::load] Can not load script: creature.lua
data/events/scripts/creature.lua:33: '<eof>' expected near 'end'

Script
LUA:
function Creature:onChangeOutfit(outfit)
    return true
end

function Creature:onAreaCombat(tile, isAggressive)
    return true
end

function Creature:onTargetCombat(target)
       return stat_onTargetCombat(self, target)
end
   
    if PARTY_PROTECTION ~= 0 then
        if self:isPlayer() and target:isPlayer() then
            local party = self:getParty()
            if party then
                local targetParty = target:getParty()
                if targetParty and targetParty == party then
                    return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
                end
            end
        end
    end
   
    if ADVANCED_SECURE_MODE ~= 0 then
        if self:isPlayer() and target:isPlayer() then
            if self:hasSecureMode() then
                return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
            end
        end
    end
    return true
end
 
Solution
LUA:
function Creature:onChangeOutfit(outfit)
    return true
end

function Creature:onAreaCombat(tile, isAggressive)
    return true
end

function Creature:onTargetCombat(target)
    if self then
        if PARTY_PROTECTION ~= 0 then
            if self:isPlayer() and target:isPlayer() then
                local party = self:getParty()
                if party then
                    local targetParty = target:getParty()
                    if targetParty and targetParty == party then
                        return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
                    end
                end
            end
        end
       
        if ADVANCED_SECURE_MODE ~= 0 then
            if self:isPlayer() and target:isPlayer() then...
LUA:
function Creature:onChangeOutfit(outfit)
    return true
end

function Creature:onAreaCombat(tile, isAggressive)
    return true
end

function Creature:onTargetCombat(target)
    if PARTY_PROTECTION ~= 0 then
        if self:isPlayer() and target:isPlayer() then
            local party = self:getParty()
            if party then
                local targetParty = target:getParty()
                if targetParty and targetParty == party then
                    return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
                end
            end
        end
    end
   
    if ADVANCED_SECURE_MODE ~= 0 then
        if self:isPlayer() and target:isPlayer() then
            if self:hasSecureMode() then
                return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
            end
        end
    end
    return stat_onTargetCombat(self, target)
end
 
LUA:
function Creature:onChangeOutfit(outfit)
    return true
end

function Creature:onAreaCombat(tile, isAggressive)
    return true
end

function Creature:onTargetCombat(target)
    if PARTY_PROTECTION ~= 0 then
        if self:isPlayer() and target:isPlayer() then
            local party = self:getParty()
            if party then
                local targetParty = target:getParty()
                if targetParty and targetParty == party then
                    return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
                end
            end
        end
    end
  
    if ADVANCED_SECURE_MODE ~= 0 then
        if self:isPlayer() and target:isPlayer() then
            if self:hasSecureMode() then
                return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
            end
        end
    end
    return stat_onTargetCombat(self, target)
end
lul removeing these 2 lines caused error after killing a monster
data/events/scripts/creature.lua:Creature@onTargetCombat
data/events/scripts/creature.lua:11: attempt to index local 'self' (a nil value)
stack traceback:
[C]: in function '__index'
data/events/scripts/creature.lua:11: in function <data/events/scripts/creature.lua:9>
 
LUA:
function Creature:onChangeOutfit(outfit)
    return true
end

function Creature:onAreaCombat(tile, isAggressive)
    return true
end

function Creature:onTargetCombat(target)
    if self then
        if PARTY_PROTECTION ~= 0 then
            if self:isPlayer() and target:isPlayer() then
                local party = self:getParty()
                if party then
                    local targetParty = target:getParty()
                    if targetParty and targetParty == party then
                        return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
                    end
                end
            end
        end
       
        if ADVANCED_SECURE_MODE ~= 0 then
            if self:isPlayer() and target:isPlayer() then
                if self:hasSecureMode() then
                    return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
                end
            end
        end
    end
    return stat_onTargetCombat(self, target)
end
 
Solution
LUA:
function Creature:onChangeOutfit(outfit)
    return true
end

function Creature:onAreaCombat(tile, isAggressive)
    return true
end

function Creature:onTargetCombat(target)
    if self then
        if PARTY_PROTECTION ~= 0 then
            if self:isPlayer() and target:isPlayer() then
                local party = self:getParty()
                if party then
                    local targetParty = target:getParty()
                    if targetParty and targetParty == party then
                        return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
                    end
                end
            end
        end
      
        if ADVANCED_SECURE_MODE ~= 0 then
            if self:isPlayer() and target:isPlayer() then
                if self:hasSecureMode() then
                    return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
                end
            end
        end
    end
    return stat_onTargetCombat(self, target)
end
ty working now
 
Back
Top