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

Lua Pet System {free} - Getting an in function 'ipairs' error on Pet_kill (Rep+)

Extrodus

|| Blazera.net ||
Premium User
Joined
Dec 22, 2008
Messages
2,740
Solutions
7
Reaction score
541
Location
Canada
So I found this pet system, and everything works up until the pet kills the monster. They battle eachother, and when the pet wins; the monster he kills does not turn into a corpse, instead the name disapears; and in the console this this error pops up every time the pet hits the monster your targeting. (your still attacking the monster even though its name + health is gone)


Code:
[6:23:44.480] [Error - CreatureScript Interface]
[6:23:44.482] mods/scripts/pet_kill.lua:onKill
[6:23:44.484] Description:
[6:23:44.485] data/lib/050-function.lua:10: bad argument #1 to 'ipairs' (table e
xpected, got number)
[6:23:44.490] stack traceback:
[6:23:44.492]   [C]: in function 'ipairs'
[6:23:44.493]   data/lib/050-function.lua:10: in function 'isInArray'
[6:23:44.497]   data/lib/APS_lib.lua:118: in function 'getLvlStage'
[6:23:44.500]   mods/scripts/pet_kill.lua:52: in function <mods/scripts/pet_kill
.lua:5>

050-function.lua - line 10 =
Code:
for _, _value in ipairs(array) do


APS_lib.lua - line 118 -
Code:
if(isInArray(e, lvl) == true) then

pet_kill.lua - line 52 -
Code:
addPetExp(cid, getMonsterInfo(getCreatureName(target)).experience / 2 * getLvlStage(getPetLvl(cid)))

Source of Pet System: Pet System [free] - Open Tibia - x1zy's code

Kinda' wish it would just work, so if anyone out there can help me get this baby 100% working I'll pay you over paypal (a small fee) for your time. :) Thank you!
 
Last edited:
Replace:
Lua:
			for e = aps_tools.stages[i].minlevel, aps_tools.stages[i].maxlevel do
				if(isInArray(e, lvl) == true) then
					ret = aps_tools.stages[i].multiplier
				end
			end

with:

Lua:
			if lvl >= aps_tools.stages[i].minlevel and lvl < aps_tools.stages[i].maxlevel then
				ret = aps_tools.stages[i].multiplier
			end
I guess it should work.
 
Replace:
Lua:
			for e = aps_tools.stages[i].minlevel, aps_tools.stages[i].maxlevel do
				if(isInArray(e, lvl) == true) then
					ret = aps_tools.stages[i].multiplier
				end
			end

with:

Lua:
			if lvl >= aps_tools.stages[i].minlevel and lvl < aps_tools.stages[i].maxlevel then
				ret = aps_tools.stages[i].multiplier
			end
I guess it should work.

Already solved it via Skype. All he needed to change was this:

Code:
if(isInArray(e, lvl) == true) then

to

Code:
if(isInArray([COLOR="#FF0000"]{[/COLOR]e[COLOR="#FF0000"]}[/COLOR], lvl)) then
Stupid typo's all over the scripts... ^_^
 
Back
Top