Gubailovo
Well-Known Member
- Joined
- Dec 19, 2013
- Messages
- 407
- Solutions
- 2
- Reaction score
- 62
I have a script pointing to a certain coordinate on the map. (and it works correctly). When you add a visual effect in the form of arrows, it stops working. what am I doing wrong?
error in console
Lua:
function getDistance(diffPos)
-- определ¤ем дистанцию
text = ""
dist = math.sqrt(diffPos.x * diffPos.x + diffPos.y * diffPos.y + diffPos.z * diffPos.z);
if dist <= 2 then
text = "здесь "
elseif dist <= 4 then
text = "близко "
elseif dist <= 100 then
text = ""
elseif dist <= 274 then
text = "далеко "
else
text = "очень далеко "
end
return text
end
function getDirection(diffPos)
text = ""
-- определим направление
if diffPos.x >= 5 and math.abs(diffPos.y) < 5 then
doSendMagicEffect(topos,NM_ME_VL)
text = "на востоке"
elseif diffPos.x <= -5 and math.abs(diffPos.y) < 5 then
doSendMagicEffect(topos,NM_ME_V)
text = "на западе"
elseif diffPos.y >= 5 and math.abs(diffPos.x) < 5 then
doSendMagicEffect(topos,NM_ME_NL)
text = "на юге"
elseif diffPos.y <= -5 and math.abs(diffPos.x) < 5 then
doSendMagicEffect(topos,NM_ME_NP)
text = "на севере"
elseif diffPos.x >= 5 and diffPos.y >= 5 then
doSendMagicEffect(topos,NM_ME_L)
text = "на юго-востоке"
elseif diffPos.x <= -5 and diffPos.y >= 5 then
doSendMagicEffect(topos,NM_ME_P)
text = "на юго-западе"
elseif diffPos.x <= -5 and diffPos.y <= -5 then
doSendMagicEffect(topos,NM_ME_VP)
text = "на северо-западе"
elseif diffPos.x >= 5 and diffPos.y <= -5 then
doSendMagicEffect(topos,NM_ME_N)
text = "на северо-востоке"
else
text = ""
end
return text
end
function onUse(cid, item, frompos, item2, topos)
dest = getItemAddHP(item.uid)
pcall(function () dx = treasure_x[dest] end)
pcall(function () dy = treasure_y[dest] end)
pcall(function () dz = treasure_z[dest] end)
targetPos = {x=dx, y=dy, z=dz}
plrpos = getPlayerPosition(cid)
centerpos = {x=plrpos.x, y=plrpos.y, z=plrpos.z}
diffPos = {x=(1643 - centerpos.x), y=(1613 - centerpos.y), z=(7 - centerpos.z)}
doPlayerSendTextMessage(cid, 22, "Синекожий гоблин находитс¤ " .. getDistance(diffPos) .. getDirection(diffPos))
return 1
end
Lua:
Lua error 1: 1
Lua error 2: attempt to index a nil value