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

Creaturescript Error

Shockah

Member
Joined
Aug 31, 2010
Messages
625
Reaction score
17
Location
England
Not sure why this is happening, but when i try to kill a monster (any monster) it comes up with this error:
errorqj.png

But if I reload creaturescripts it stops happening for abit. Does anyone know why? I don't even know what script is causing this to happen.

Any help to the solution is appreciated,

Thanks.
 
Here you go:
XML:
<?xml version="1.0" encoding="UTF-8"?>

<creaturescripts>

	<event type="login" name="PlayerLogin" event="script" value="login.lua"/>


	<event type="joinchannel" name="GuildMotd" event="script" value="guildmotd.lua"/>

	<event type="receivemail" name="Mail" event="script" value="mail.lua"/>

	<event type="reportbug" name="SaveReportBug" script="reportbug.lua"/>

	<event type="advance" name="AdvanceSave" event="script" value="advancesave.lua"/>


	<event type="think" name="Idle" event="script" value="idle.lua"/>

	<event type="think" name="SkullCheck" event="script" value="skullcheck.lua"/>

	
	<!-- Amulet -->

	<event type="preparedeath" name="forever amulet" event="script" value="forever amulet.lua"/>

	<event type="preparedeath" name="charge amulet" event="script" value="charge amulet.lua"/>

	
	<!-- Inquisition Full Quest -->
	<event type="kill" name="inquisitionPortals" script="Inquisition.lua"/>

	
	<!-- Custom Scripts-->
    <event type="login" name="Welcome" script="welcome.lua"/>

	<event type="advance" name="reward" event="script" value="reward45.lua"/>

	<event type="death" name="PythiusTheRotten" event="script" value="PythiusTheRotten.lua"/>

	
	<!-- WoE -->

	<event type="death" name="empe_broken" event="script" value="empe_broken.lua"/>

	<event type="statschange" name="empe_dmg" event="script" value="empe_dmg.lua"/>

</creaturescripts>
 
I thought it might be that but I also thought that it would only effect the boss monsters from dieing. Here it is anyway:
Lua:
local config = {
        timeToRemove = 180, -- seconds
		message = "You now have 3 minutes to exit this room through the teleporter. It will bring you to the next room only during his time or the teleporter will disappear",
        teleportId = 9773,
        bosses = { -- Monster Name,  Teleport Position
                ["Ushuriel"] = {  pos={ x=33157, y=31725, z=11, stackpos=1 }, aid=1001 },
				["Zugurosh"] = {  pos={ x=33123, y=31689, z=11, stackpos=1 }, aid=1002},
				["Madareth"] = {  pos={ x=33194, y=31768, z=11, stackpos=1 }, aid=1003},
                ["Annihilon"] = {  pos={ x=33200, y=31704, z=11, stackpos=1 }, aid=1005},
                ["Hellgorak"] = {  pos={ x=33107, y=31735, z=11, stackpos=1 }, aid=1006}
				},
		brothers ={
        ["Golgordan"] = {pos={ x=33235, y=31734, z=11, stackpos=1 },aid=1004, brother = "Latrivan"},
        ["Latrivan"] = {pos={ x=33235, y=31734, z=11, stackpos=1 },aid=1004, brother = "Golgordan"},
        brothersArea ={
                fromPos = {x = 33224, y = 31722, z = 11},
                toPos = {x = 33240, y = 31734, z = 11}	}	}
}
local function removal(position)
	doRemoveThing(getTileItemById(position, config.teleportId).uid, 1)
    return TRUE
end

function onKill(cid, target, lastHit)
    if(config.bosses[getCreatureName(target)]) then
		local t = config.bosses[getCreatureName(target)]
	    local teleport = doCreateItem(config.teleportId, t.pos)
		local position = t.pos
		doItemSetAttribute(teleport, "aid", t.aid)
        doCreatureSay(cid, config.message, TALKTYPE_ORANGE_1)
		addEvent(removal, config.timeToRemove * 1000, position)
	elseif(config.brothers[getCreatureName(target)]) then
		local t = config.brothers[getCreatureName(target)]
        local brother = getCreatureByName(t.brother)
		if(isMonster(brother) == true) then
            if(isInRange(getCreaturePosition(brother), config.brothers.brothersArea.fromPos, config.brothers.brothersArea.toPos) == true) then
                return TRUE
			end
        else
			local teleport = doCreateItem(config.teleportId, t.pos)
			local position = t.pos
			doItemSetAttribute(teleport, "aid", t.aid)
			doCreatureSay(cid, config.message, TALKTYPE_ORANGE_1)
			addEvent(removal, config.timeToRemove * 1000, position)
		end
	end
	return TRUE
end
 
honestly i didn't get any bug when i tested the script, what distro are you using? (i tested it in tfs 0.3.6pl1)
try adding
Lua:
local config = {
        timeToRemove = 180, -- seconds
		message = "You now have 3 minutes to exit this room through the teleporter. It will bring you to the next room only during his time or the teleporter will disappear",
        teleportId = 2160,
        bosses = { -- Monster Name,  Teleport Position
                ["Ushuriel"] = {  pos={ x=33157, y=31725, z=11, stackpos=1 }, aid=1001 },
		["Zugurosh"] = {  pos={ x=33123, y=31689, z=11, stackpos=1 }, aid=1002},
		["Madareth"] = {  pos={ x=33194, y=31768, z=11, stackpos=1 }, aid=1003},
                ["Annihilon"] = {  pos={ x=33200, y=31704, z=11, stackpos=1 }, aid=1005},
                ["Hellgorak"] = {  pos={ x=33107, y=31735, z=11, stackpos=1 }, aid=1006}
				},
		brothers ={
        ["Golgordan"] = {pos={ x=33235, y=31734, z=11, stackpos=1 },aid=1004, brother = "Latrivan"},
        ["Latrivan"] = {pos={ x=33235, y=31734, z=11, stackpos=1 },aid=1004, brother = "Golgordan"},
        brothersArea ={
                fromPos = {x = 33224, y = 31722, z = 11},
                toPos = {x = 33240, y = 31734, z = 11} } }
}
local function removal(position)
	doRemoveThing(getTileItemById(position, config.teleportId).uid, 1)
    return TRUE
end
 
function onKill(cid, target, lastHit)
    if(config.bosses[getCreatureName(target)]) then
		local t = config.bosses[getCreatureName(target)]
	    local teleport = doCreateItem(config.teleportId, t.pos)
		local position = t.pos
		doItemSetAttribute(teleport, "aid", t.aid)
        doCreatureSay(cid, config.message, TALKTYPE_SAY)
		addEvent(removal, config.timeToRemove * 1000, position)
	elseif(config.brothers[getCreatureName(target)]) then
		local t = config.brothers[getCreatureName(target)]
        local brother = getCreatureByName(t.brother)
		if(isMonster(brother) == true) then
            if(isInRange(getCreaturePosition(brother), config.brothers.brothersArea.fromPos, config.brothers.brothersArea.toPos) == true) then
                return TRUE
			end
        else
			local teleport = doCreateItem(config.teleportId, t.pos)
			local position = t.pos
			doItemSetAttribute(teleport, "aid", t.aid)
			doCreatureSay(cid, config.message, TALKTYPE_ORANGE_1)
			addEvent(removal, config.timeToRemove * 1000, position)
		end
	else
		return true 
	end
	return TRUE
end
i just added the "else return true" 'cause that scripts compares the creature name with the name registered in two tables, that else assumes that if the creaturename isn't equal than the names of the tables makes all normal, i'm not sure if it will work, i guess you are using tfs 0.4, this script uses 0.3.6 pl1 functions, so that's could be the problem.
 
Yeah I'm using 0.4, so your probably right then. In the error it says: attempt to index field 'bosses' <a nil value>. So does that mean in the script config at the top, it can't recognise the bosses table or w/e it's called or something? I have no clue about LUA, lmao. Thanks for the help though.
 
Back
Top Bottom