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

UpInSmoke

Supreme Ruler
Joined
Nov 16, 2008
Messages
303
Reaction score
21
So im trying to create a boss script.
Im having trouble identifying if the boss is dead or not.
heres the script:
Code:
local config = {
	temporaryArea = {
		{x = 1036, y = 1037, z = 7}, -- northwest corner of area where players must stand in order to join the event
		{x = 1048, y = 1047, z = 7} -- south east corner
	},
	arenaArea = {
		{x = 1045, y = 1012, z = 7}, -- nw corner of arena
		{x = 1060, y = 1025, z = 7}, -- se corner of arena
		{x = 1053, y = 1018, z = 7} -- center of arena
	},
	minPlayers = 1,
	prize = {2159}, -- rewards
	monster = "cat",
	monsterPos = {x = 1053, y = 1021, z = 7},
	temple = {x = 1017, y = 1044, z = 7}
}
 
function onThink(interval, lastExecution, thinkInterval)
	local players, arenaPlayers = {}, {}
	for x = (config.temporaryArea)[1].x, (config.temporaryArea)[2].x do
		for y = (config.temporaryArea)[1].y, (config.temporaryArea)[2].y do
			for z = (config.temporaryArea)[1].z, (config.temporaryArea)[2].z do
				if(isPlayer(getTopCreature({x = x, y = y, z = z}).uid)) then
					table.insert(players, getTopCreature({x = x, y = y, z = z}).uid)
				end
			end
		end
	end
	for x = (config.arenaArea)[1].x, (config.arenaArea)[2].x do
		for y = (config.arenaArea)[1].y, (config.arenaArea)[2].y do
			for z = (config.arenaArea)[1].z, (config.arenaArea)[2].z do
				if(isPlayer(getTopCreature({x = x, y = y, z = z}).uid)) then
					table.insert(arenaPlayers, getTopCreature({x = x, y = y, z = z}).uid)
				end
			end
		end
	end
		if(table.maxn(players) >= config.minPlayers) then
			for i = 1, #players do
				doTeleportThing(players[i], (config.arenaArea)[3])
				doSendMagicEffect((config.arenaArea)[3], CONST_ME_TELEPORT)
				doPlayerSendTextMessage(players[i], MESSAGE_STATUS_WARNING, "Kill the cat!")
				doCreateMonster(cid, config.monster, config.monsterPos)
					if getCreatureHealth(cid) <= 0 then
						for a = 1, #arenaPlayers do
							doTeleportThing(arenaPlayers[a], config.temple)
							doPlayerSendTextMessage(arenaPlayers[a], MESSAGE_STATUS_CONSOLE_BLUE, "You have slain the cat and recived your reward.")
							doPlayerAddItem(arenaPlayers[a], config.prize,5)
						end
					end
			end
		end
	return true
end
error:
Code:
[03/06/2013 01:52:43] [Error - GlobalEvent Interface] 
[03/06/2013 01:52:43] data/globalevents/scripts/bosses/catFight.lua:onThink
[03/06/2013 01:52:43] Description: 
[03/06/2013 01:52:43] (luaGetCreatureHealth) Creature not found

[03/06/2013 01:52:43] [Error - GlobalEvent Interface] 
[03/06/2013 01:52:43] data/globalevents/scripts/bosses/catFight.lua:onThink
[03/06/2013 01:52:43] Description: 
[03/06/2013 01:52:43] data/globalevents/scripts/bosses/catFight.lua:44: attempt to compare boolean with number
[03/06/2013 01:52:43] stack traceback:
[03/06/2013 01:52:43] 	data/globalevents/scripts/bosses/catFight.lua:44: in function <data/globalevents/scripts/bosses/catFight.lua:18>
[03/06/2013 01:52:43] [Error - GlobalEvents::think] Couldn't execute event: catfight
I know it has to do with the GetCreatureHealth .. but i dont know how i would identify the creature in the script.
help, rep++
 
Last edited:
You can't use cid in a globalevent, you can make on onKill script with storage to check if someone killed the cat.
 
okay so im not getting any errors but it doesnt seem to work:

creaturescripts
Code:
local config = {
{["name"] = "Cat", ["storage"] = 5560},
{["name"] = "Cobra", ["storage"] = 5561},
{["name"] = "Chicken", ["storage"] = 5562},
{["name"] = "Crab", ["storage"] = 5563},
}
function onKill(cid, target, lastHit)
		for i = 1, #config do
			if getCreatureName(target):lower() == config[i].name:lower() then
				if getPlayerStorageValue(cid, config[i].storage) == 1 then
					setPlayerStorageValue(cid, config[i].storage, 2)
				end
			end
		end
	return TRUE
end
globalevents
Code:
local t = {
{["item"] = 2159, ["icount"] = 2, ["storage"] = 5560},
{["item"] = 2159, ["icount"] = 3, ["storage"] = 5561},
{["item"] = 2159, ["icount"] = 4, ["storage"] = 5562},
{["item"] = 2159, ["icount"] = 5, ["storage"] = 5563},
}
function onThink(cid, item, fromPosition, toPosition)

	for _, name in ipairs(getOnlinePlayers()) do
		local player = getPlayerByName(name)
		for i = 1, #t do
			if getPlayerStorageValue(player,t[i].storage) == 2 then
                                doPlayerSendTextMessage(player,19,"Goodjob on slaying that boss! Youve been rewarded with "..t[i].icount.." EDC")
				doPlayerAddItem(player,t[i].item, t[i].icount)
			end
		end
	end
return true
end
movements
enterboss
Code:
local t = {
[7008] = {5560},
[7009] = {5561},
[7010] = {5562},
[7011] = {5563},
}
function onStepIn(cid, item, position, fromPosition)
local v = t[item.uid]
setPlayerStorageValue(cid, v[1], 1)
return true
end
leaveboss/die
Code:
local t = {
 [7013] = {5560,5561,5562,5563},
}
function onStepIn(cid, item, position, fromPosition)
local v = t[item.uid]
	for i = 1, #v do
		if getPlayerStorageValue(cid,v[i]) > 0 then
			setPlayerStorageValue(cid,v[i],0)
		end
	end
return true
end
i used the movements that way i can register who is left in the arena so all players left get the prize.
boss dies, nobody gets the prize, no errors.. any idea?
 
Last edited:
Back
Top