Apoccalypse
New Member
- Joined
- Apr 15, 2017
- Messages
- 114
- Solutions
- 2
- Reaction score
- 4
Hello guys,
I have the following script and it works perfectly:
(I am using tfs 0.3.6, client 8.6)
I wanted to remake it to works when the defined boss is inside area instead of x player online.
But the console returns an error:
@The solution:
I have the following script and it works perfectly:
(I am using tfs 0.3.6, client 8.6)
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local onePerQuest = "yes"
local npos = {x=329, y=278, z=11}
local areaPosition =
{
{x=330, y=270, z=11, stackpos = 255},
{x=344, y=286, z=11, stackpos = 255}
}
if item.uid == 9413 then
if onePerQuest == "yes" then
local players = getPlayersOnline()
for _, pid in ipairs(players) do
if isInArea(getCreaturePosition(pid), areaPosition[1], areaPosition[2]) then
doPlayerSendCancel(cid, "Wait until " .. getCreatureName(pid) .. " finish the quest.")
return true
end
end
end
doTeleportThing(cid, npos)
doSendMagicEffect(npos,29)
doPlayerSendTextMessage(cid, 21,"Congratulation! Don't forget to take a piece from the tomb!")
return true
end
end
I wanted to remake it to works when the defined boss is inside area instead of x player online.
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local npos = {x=329, y=278, z=11}
local areaPosition =
{
{x=330, y=270, z=11, stackpos = 255},
{x=344, y=286, z=11, stackpos = 255}
}
local boss1 = {
"Rahemos"
}
if item.uid == 9413 then
for _, pid in ipairs(boss1) do
if isInArea(getCreaturePosition(pid), areaPosition[1], areaPosition[2]) then
doPlayerSendCancel(cid, "You have to kill Rahemos to eneter the tomb!")
return true
end
end
doTeleportThing(cid, npos)
doSendMagicEffect(npos,29)
doPlayerSendTextMessage(cid, 21,"Congratulation! Don't forget to take a piece from the tomb!")
return true
end
end
But the console returns an error:
Code:
[16:29:00.491] [Error - Action Interface]
[16:29:00.491] data/actions/scripts/Ancient Quest/AncientArea.lua:onUse
[16:29:00.491] Description:
[16:29:00.491] (luaGetThingPosition) Thing not found
[16:29:00.507] [Error - Action Interface]
[16:29:00.507] data/actions/scripts/Ancient Quest/AncientArea.lua:onUse
[16:29:00.507] Description:
[16:29:00.507] data/lib/032-position.lua:2: attempt to index local 'position' (a boolean value)
[16:29:00.507] stack traceback:
[16:29:00.522] data/lib/032-position.lua:2: in function 'isInArea'
[16:29:00.522] data/actions/scripts/Ancient Quest/AncientArea.lua:20: in function <data/actions/scripts/Ancient Quest/AncientArea.lua:1>
@The solution:
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local config = {
item_uid = 9413,
monster_name = "Rahemos",
position = {x = 329, y = 278, z = 11},
center_pos = {x = 330, y = 270, z = 11},
effect = CONST_ANI_EARTH,
cancel_message = "You have to kill Rahemos to enter the tomb!",
congrat_message = "Congratulation! Don't forget to take a piece from the tomb!",
rangeX = 10,
rangeY = 10
}
if item.uid == config.item_uid then
if getSpectators(config.center_pos, config.rangeX, config.rangeY) then
for _, m in ipairs(getSpectators(config.center_pos, config.rangeX, config.rangeY)) do
if isMonster(m) and string.lower(getCreatureName(m)) == string.lower(config.monster_name) then
doPlayerSendCancel(cid, config.cancel_message)
return true
end
end
doTeleportThing(cid, config.position)
doSendMagicEffect(config.position, config.effect)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, config.congrat_message)
end
end
return true
end
Last edited: