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

Pandora Event

Bassam421

Lockout RPG/PVP Owner
Joined
Nov 8, 2008
Messages
359
Reaction score
7
Location
Sweden , Göteborg
Hello guys i need help with my script! I'm using TFS v5 and i have a mod that is called Pandora box

This is the mod:
Lua:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Pandora Box" version="1.2" author="Oskar" contact="[email protected]" enabled="yes">
<config name="pandoraBox_conf"><![CDATA[
dateToStart = {
                ['monday'] = false,
                ['tuesday'] = true,
                ['wednesday'] = false,
                ['thursday'] = false,
                ['friday'] = true,
                ['saturday'] = true,
                ['sunday'] = false
                }

eventDate = {}
for k, v in pairs(dateToStart) do
    if v then
        table.insert(eventDate, k)
    end
end

pandoraBox = {
            monstersPositions = {
                                leftTopCorner = {x=1386,y=1514,z=7},
                                rightBottomCorner = {x=1392,y=1520,z=7}
                                },
            pandoraBoxAccesToUseCommand = 4,
            --box config
            boxId = 9661,
            timeOnPutBox = 10, --in minutes
            chance = 100,
            pandoraBoxPosition = {x=1389,y=1517,z=7},
            
            --monsters config
            monstersName = {'slime',4,'dragon',25}, --'name', chance, 'name1', chance1
            monstersSpawnCount = {80,110}, --{from, to}
            
            --waves config
            wavesCount = {9,11}, --{from, to}
            timeBetweenWaves = 90, --in seconds
            
            timeOnKillAllMonsters = 13, --in minutes
            timeOnGetRewards = 20, --in seconds
            bossPositionToSamePandoraBox = true,
            bossName = 'Pandora',
            pandoraGuards = 'fallen island warlock',
            pandoraGuardsCount = 10,
            expRateValue = 0.25,
            }
 
pandoraBoxRewards = {
				  --[vocationId] = {itemid, count, itemid1, count1, ...}
					[1] = {2160, 50, 9969, 1, 9932, 1}, --sorc
					[2] = {2160, 50, 9969, 1, 9932, 1}, --druid
					[3] = {2160, 50, 9969, 1, 9932, 100}, --pall
					[4] = {2160, 50, 9969, 1, 9932, 1}, --knight
					[5] = {2160, 60, 9969, 1, 9932, 1}, --ms
					[6] = {2160, 60, 9969, 1, 9932, 1}, --ed
					[7] = {2160, 60, 9969, 1, 9932, 1}, --rp
					[8] = {2160, 60, 9969, 1, 9932, 1}, --ek
					}
 
function getArea(pandoraBox)
local LTCx, LTCy, LTCz = pandoraBox.monstersPositions.leftTopCorner.x, pandoraBox.monstersPositions.leftTopCorner.y, pandoraBox.monstersPositions.leftTopCorner.z
local RBCx, RBCy, RBCz = pandoraBox.monstersPositions.rightBottomCorner.x, pandoraBox.monstersPositions.rightBottomCorner.y, pandoraBox.monstersPositions.rightBottomCorner.z
local centerPos, rangex, rangey = {x=(LTCx+RBCx)/2,y=(LTCy+RBCy)/2,z=(LTCz+RBCz)/2}, math.abs(RBCx-LTCx), math.abs(RBCy-LTCy)
return centerPos, rangex, rangey
end
 
function isWalkable(pos, creature, proj, pz)
if getTileThingByPos({x=pos.x,y=pos.y,z=pos.z,stackpos=0}).itemid == 0 then return false end
if getTopCreature(pos).uid > 0 and creature then return false end
if getTileInfo(pos).protection and pz then return false, true end
local n = not proj and 3 or 2
for i = 0, 255 do
	pos.stackpos = i
	local tile = getTileThingByPos(pos)
	if tile.itemid ~= 0 and not isCreature(tile.uid) then
		if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
			return false
		end
	end
end
return true
end
 
function checkPositions(fromPos, toPos, nb)
local pos = {x=math.random(fromPos.x,toPos.x), y=math.random(fromPos.y,toPos.y), z=math.random(fromPos.z,toPos.z)}
if isWalkable(pos, true, true, true) then
	return pos
end
return (nb < 200 and checkPositions(fromPos, toPos, nb+1) or pos)
end
 
function setMonster(pandoraBox)
for i = 1, #pandoraBox.monstersName/2 do
	local pos = checkPositions(pandoraBox.monstersPositions.leftTopCorner, pandoraBox.monstersPositions.rightBottomCorner, 0)
	if pos and math.random(100000) <= pandoraBox.monstersName[i*2]*1000 then
		local mon = doCreateMonster(pandoraBox.monstersName[i*2-1], pos, false, false, false)
		return (isCreature(mon) and doCreatureSetStorage(mon, 1000, 1) or true)
	end
end
return setMonster(pandoraBox)
end
 
function setPandoraBoxMonsters(pandoraBox)
for j = 1, math.random(pandoraBox.wavesCount[1], pandoraBox.wavesCount[2]) do
	addEvent(function()
			doBroadcastMessage('Next wave is raid on the city! Beware mortals, death come for you!')
			for i = 1, math.random(pandoraBox.monstersSpawnCount[1], pandoraBox.monstersSpawnCount[2]) do
				setMonster(pandoraBox)
			end return true end,
			(j == 1 and 1000 or pandoraBox.timeBetweenWaves * 1000 * (j-1)),
			pandoraBox
			)
end
return true
end
 
function setPandoraBox(pandoraBox)
if getStorage(5000) ~= -1 then 
	return addEvent(setPandoraBox, pandoraBox.timeOnPutBox * 60 * 1000, pandoraBox) end
if math.random(100000) <= pandoraBox.chance*1000 then
	doSetStorage(5000, 0)
	local item = doCreateItem(pandoraBox.boxId, pandoraBox.pandoraBoxPosition)
	doItemSetAttribute(item, 'uid', 2000)
	doItemSetAttribute(item, 'name', 'Pandora Box')
	return doBroadcastMessage('Pandora Box is appeared somewhere in the city!')
end
return doSetStorage(5000, -1) and addEvent(setPandoraBox, pandoraBox.timeOnPutBox * 60 * 1000, pandoraBox)
end
 
function checkMonsters(pandoraBox, n)
local centerPos, rangex, rangey = getArea(pandoraBox)
if getSpectators(centerPos, rangex, rangey) then
	for _, v in ipairs(getSpectators(centerPos, rangex, rangey)) do
		if isMonster(v) and getCreatureStorage(v, 1000) == 1 then
			for _, k in ipairs(getPlayersOnline()) do
				if n == 0 then
					doBroadcastMessage('Experience rate is to decreased by '.. pandoraBox.expRateValue * 100 ..' percent and not grow, until the evil from Pandora Box walk on the city.')
					n = 60
				end
				doPlayerSetExperienceRate(k, pandoraBox.expRateValue)
			end
			return addEvent(checkMonsters, 5000, pandoraBox, n - 1)
		end
	end
end
doBroadcastMessage('Evil from Pandora Box is defeated! '..pandoraBox.bossName..' in his own person be came to the city for revenage!')
local pand = doCreateMonster(pandoraBox.bossName, (pandoraBox.bossPositionToSamePandoraBox and pandoraBox.pandoraBoxPosition or checkPositions(pandoraBox.monstersPositions.leftTopCorner, pandoraBox.monstersPositions.rightBottomCorner, 0)), false, false, false)
local pos = getThingPos(pand)
for i = 1, pandoraBox.pandoraGuardsCount do
	pos.x = pos.x + math.random(-4,4)
	pos.y = pos.y + math.random(-4,4)
	doCreateMonster(pandoraBox.pandoraGuards, pos, false, false, false)
end
return (isMonster(pand) and registerCreatureEvent(pand, 'pandoraDeath') or false)
end
]]></config>
 
<event type="death" name="pandoraDeath" event="script"><![CDATA[
domodlib('pandoraBox_conf')
function onDeath(cid)
if getTileItemById(pandoraBox.pandoraBoxPosition, pandoraBox.boxId).uid == 2000 then
	item = getTileItemById(pandoraBox.pandoraBoxPosition, pandoraBox.boxId)
end
addEvent(function()
				doSetStorage(5000, -1)
				doBroadcastMessage('Pandora Box is disappeared from the world!')
				if getTileItemById(pandoraBox.pandoraBoxPosition, pandoraBox.boxId).uid == 2000 then
					return doRemoveItem(getTileItemById(pandoraBox.pandoraBoxPosition, pandoraBox.boxId).uid)
				end
				return true end,
				pandoraBox.timeOnGetRewards * 1000,
				pandoraBox
				)
return item and doItemSetAttribute(item.uid, 'pandoraBox', 1000) and doBroadcastMessage('The ancient evil has been defeated! The Pandora\'s Box are the reward for each, but only for '..timeOnGetRewards..' seconds!') or true
end
]]></event>
 
<action uniqueid="2000" event="script"><![CDATA[
domodlib('pandoraBox_conf')
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid == pandoraBox.boxId and getItemAttribute(item.uid, 'pandoraBox') == nil then
	doItemSetAttribute(item.uid, 'pandoraBox', 500)
	addEvent(checkMonsters, pandoraBox.timeOnKillAllMonsters * 1000 * 60, pandoraBox, 0)
	return setPandoraBoxMonsters(pandoraBox)
elseif item.itemid == pandoraBox.boxId and getItemAttribute(item.uid, 'pandoraBox') == 1000 then
	if getPlayerStorageValue(cid, 150) ~= -1 then
		return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It\'s empty.') end
	if pandoraBoxRewards[getPlayerVocation(cid)] then
		doPlayerSetStorageValue(cid, 150, 0)
		msg = 'You have found '
		for i = 1, #pandoraBoxRewards[getPlayerVocation(cid)]/2 do
			msg = msg .. getItemNameById(pandoraBoxRewards[getPlayerVocation(cid)][i*2-1]) .. (i < #pandoraBoxRewards[getPlayerVocation(cid)]/2-1 and ', ' or i == #pandoraBoxRewards[getPlayerVocation(cid)]/2-1 and ' and ' or '.')
			doPlayerAddItem(cid, pandoraBoxRewards[getPlayerVocation(cid)][i*2-1], pandoraBoxRewards[getPlayerVocation(cid)][i*2])
		end
		return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, msg)
	end
end
return false
end
]]></action>
 
<globalevent name="pandoraTime" time="05:34" event="script"><![CDATA[
domodlib("pandoraBox_conf")
function onTimer()
return doSetStorage(5000, -1) and setPandoraBox(pandoraBox)
end
]]></globalevent>
 
<talkaction words="!pandoraBox" event="script"><![CDATA[
domodlib('pandoraBox_conf')
function onSay(cid, words, param, channel)
return getPlayerAccess(cid) >= pandoraBox.pandoraBoxAccesToUseCommand and doSetStorage(5000, -1) and setPandoraBox(pandoraBox) or true 
end
]]></talkaction>
</mod>

And the problem is that when i right click on the box, broadcast appears and everything. But my real problem is that the monsters dosent spawn...

- - - Updated - - -

Move this to problem! my bad!
 
1. have you set the positions right?

pandoraBox = {
monstersPositions = {
leftTopCorner = {x=1386,y=1514,z=7},
rightBottomCorner = {x=1392,y=1520,z=7}
},
pandoraBoxAccesToUseCommand = 4,
--box config
boxId = 9661,
timeOnPutBox = 10, --in minutes
chance = 100,
pandoraBoxPosition = {x=1389,y=1517,z=7},

2.
pandoraBoxAccesToUseCommand = 4, <- try to change that

3.
do you have a boss named pandora?

4.
if not working, does it shows any problems in the panel?
 
Well i dont have any errors , the locations is right it's my locations, i dont have pandora monster, and i dont get any errors in console

- - - Updated - - -

bump
 
Last edited:
Back
Top