Apoccalypse
New Member
- Joined
- Apr 15, 2017
- Messages
- 114
- Solutions
- 2
- Reaction score
- 4
Hi quys,
I have the following script:
It works great for me but I am just wondering is it possible to make the boss to respawn at one of three declared places.Let's call them:
local pos1 ={x=x1 ,y=y1 ,z=z1}
local pos2 ={x=x2 ,y=y2 ,z=z2}
local pos3 ={x=x3 ,y=y3 ,z=z3}
The final result which I want to receive is that the boss would have the chance 33.33% to respawn at one of these places.
I tried to do something like this:
But I get this error:
If anyone would help that would be great
I have the following script:
LUA:
local config = {
bosspos = {x = 246, y = 969, z = 4},
bossspawnstorage = 70400
}
local monster = {'Ferumbras'}
local function respawn()
doCreateMonster('Ferumbras', config.bosspos)
doBroadcastMessage('There are rumors that Ferumbras walks around his chamber...', 21)
setGlobalStorageValue(config.bossspawnstorage, 0)
end
function onKill(cid, target, damage, flags)
local minspawn = 86400 --1d
local maxspawn = 259200 -- 3d
local random = math.random(minspawn, maxspawn)
if isMonster(target) then
local targetName = getCreatureName(target)
local playerName = getCreatureName(cid)
if isInArray(monster, targetName) and getGlobalStorageValue(config.bossspawnstorage) ~= 1 then
local message = ("%s has just killed the evil mage %s. Congratulation!"):format(playerName, targetName)
doBroadcastMessage(message, 21)
setGlobalStorageValue(config.bossspawnstorage, 1)
addEvent(respawn, random * 1000)
end
end
return true
end
It works great for me but I am just wondering is it possible to make the boss to respawn at one of three declared places.Let's call them:
local pos1 ={x=x1 ,y=y1 ,z=z1}
local pos2 ={x=x2 ,y=y2 ,z=z2}
local pos3 ={x=x3 ,y=y3 ,z=z3}
The final result which I want to receive is that the boss would have the chance 33.33% to respawn at one of these places.
I tried to do something like this:
LUA:
local config = {
bossspawnstorage = 70401
}
local monster = {'Evil Mastermind'}
local function respawn()
local bosspos1 = {x = 435, y = 505, z = 7}
local bosspos2 = {x = 437, y = 499, z = 7}
local bosspos3 = {x = 442, y = 506, z = 7}
local Posrandom = random(bosspos1, bosspos2, bosspos3)
doCreateMonster('Evil Mastermind', Posrandom)
doBroadcastMessage('There are rumors that Evil Mastermind walks around his chamber...', 21)
setGlobalStorageValue(config.bossspawnstorage, 0)
end
function onKill(cid, target, damage, flags)
local minspawn = 1 --1d
local maxspawn = 5 -- 3d
local random = math.random(minspawn, maxspawn)
if isMonster(target) then
local targetName = getCreatureName(target)
local playerName = getCreatureName(cid)
if isInArray(monster, targetName) and getGlobalStorageValue(config.bossspawnstorage) ~= 1 then
local message = ("%s has just killed the evil mage %s. Congratulation!"):format(playerName, targetName)
doBroadcastMessage(message, 21)
setGlobalStorageValue(bossspawnstorage, 1)
addEvent(respawn, random * 1000)
end
end
return true
end
But I get this error:
Code:
[19:44:19.182] [Error - CreatureScript Interface]
[19:44:19.182] In a timer event called from:
[19:44:19.182] data/creaturescripts/scripts/RespawnEvilMastermind.lua:onKill
[19:44:19.182] Description:
[19:44:19.182] ...ta/creaturescripts/scripts/RespawnEvilMastermind.lua:13: attempt to call global 'random' (a nil value)
[19:44:19.182] stack traceback:
[19:44:19.182] ...ta/creaturescripts/scripts/RespawnEvilMastermind.lua:13: in function <...ta/creaturescripts/scripts/RespawnEvilMastermind.lua:9>
If anyone would help that would be great
