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

Errors from PVPscript made by talaturen

mikeware

New Member
Joined
Jul 17, 2007
Messages
338
Reaction score
0
Location
Brazil
Hi

Im trying to use the pvparena script made by talaturen for FS
first, here's the script:
Code:
local pvpArena =
{
	{
		fromPosition = {x=172, y=33, z=8},
		toPosition = {x=183, y=41, z=8},
		positionToTeleportToOnDeath = {x=178, y=45, z=8}
	},

	{
		fromPosition = {x=121, y=33, z=9},
		toPosition = {x=128, y=37, z=9},
		positionToTeleportToOnDeath = {x=125, y=31, z=9}
	}
}

function onPrepareDeath(cid, killer)
	for i = 0, table.maxn(pvpArena) do
		if isInPosition(getCreaturePosition(cid), pvpArena[i].fromPosition, pvpArena[i].toPosition) then
			doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
			doTeleportThing(cid, pvpArena[i].positionToTeleportToOnDeath, TRUE)
			break
		end
	end
end

Well, in the begginning i got some errors in the line 17:
Code:
for i = 0, table.maxn(pvpArena) do
here is the error:
Code:
CreatureScript Interface] 
data/creaturescripts/scripts/ffa-pvparena.lua:onPrepareDeath

data/creaturescripts/scripts/ffa-pvparena.lua:17: attempt to index field '?' (a nil value)

So I removed this line and the break thing, also the end from the line, and when the player died, the server crashed, so I made a test, removed the "doCreatureAddHealth(cid, getCreatureMaxHealth(cid))" and It worked, but obviously, he died but the corpse got teleported, then i changed "doCreatureAddHealth(cid, getCreatureMaxHealth(cid))" to "doCreatureAddHealth(cid, 1000)" and now it's worked, but if a monster too strong kill a player especialy if the player is a low lvl, the server still crash, so now I don't know how to fix the things.
 
Try this;
Code:
local pvpArena =
{
	-- PVP Arena #1:
	{
		fromPosition = {x = 10000, y = 10000, z = 7},
		toPosition = {x = 10020, y = 10020, z = 7},
		positionToTeleportToOnDeath = {x = 10025, y = 10025, z = 7}
	},

	-- PVP Arena #2:
	{
		fromPosition = {x = 20000, y = 20000, z = 4},
		toPosition = {x = 20020, y = 20023, z = 10},
		positionToTeleportToOnDeath = {x = 20025, y = 20025, z = 7}
	}
}

function onPrepareDeath(cid, killer)
	for i, v in ipairs(pvpArena) do
		if isInPosition(getCreaturePosition(cid), v.fromPosition, v.toPosition) then
			while getCreatureHealth(cid) < getCreatureMaxHealth(cid) do
				doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
			end
			doTeleportThing(cid, v.positionToTeleportToOnDeath, TRUE)
			break
		end
	end
end
 
tested and it's worked, BUT, in the first time I tested, i put 3 orc berserkers in the arena, second test, I made a demon and the server crashed and closed when he killed me, something with the doCreatureAddHealth I guess
 
I was testing that script for Talaturen, and had the same problems that you had.

I found out that if the hit that kills you in the arena is so strong that it could have removed all your hp once more, the server would crash.

Ex:

Player is level 1 and has 150 HP.
Demon first deals 140 HP damage. Player has 10 HP left.
Demon deals 170 HP damage. Player "die" and get teleported and get refilled 150 HP.
But (10+150) HP - 170 HP = -10 HP. This is what that crashes the server.

The problem is that the function doCreatureAddHealth(cid,amount) can't give more hp than the players maximum hp. Currently, we haven't found a way around this problem.

Cred to me for telling Tala about the ipairs(table) function and testing the script :)
 
look this error:

Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/ffa-pvparena.lua:eek:nPrepareDeath

data/creaturescripts/scripts/ffa-pvparena.lua:21: attempt to call global 'isInPosition' (a nil value)

Someone help?
 
look this error:

Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/ffa-pvparena.lua:eek:nPrepareDeath

data/creaturescripts/scripts/ffa-pvparena.lua:21: attempt to call global 'isInPosition' (a nil value)

Someone help?

post your ffa-pvparena script to me take a look and check if the function isIsPosition are in the global.lua in the data directory.
 
local pvpArena =
{
-- PVP Arena #1:
{
fromPosition = {x = 238, y = 80, z = 2},
toPosition = {x = 246, y = 83, z = 2},
positionToTeleportToOnDeath = {x = 234, y = 63, z = 7}
}
}

function onPrepareDeath(cid, killer)
for i, v in ipairs(pvpArena) do
if isInPosition(getCreaturePosition(cid), v.fromPosition, v.toPosition) then
while getCreatureHealth(cid) < getCreatureMaxHealth(cid) do
doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
end
doTeleportThing(cid, v.positionToTeleportToOnDeath, TRUE)
break
end
end
end

------------------------------------------------------------------------------------------------------------------


isIsPosition is not in global.lua


Someone have the isInPosition function ????
 
Last edited:
Back
Top