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

Distance effect help...

Marko999x

999x era
Premium User
Joined
Dec 14, 2017
Messages
2,826
Solutions
82
Reaction score
1,947
Location
Germany
Can someone help me to make the distance effect working?

my script:
Lua:
        local text = {
        --X pos,Y pos, Z pos, text
    

[1] = {pos = {2000,2000,7}, text = {"WELCOME!"}},
[2] = {pos = {4994,4999,7}, text = {"Monsters!"}},
 
[3] = {pos = {4994,5000,7}, text = {"Quests!"}},

[4] = {pos = {989,989,7}, text = {"Arena!"}},
[5] = {pos = {4994,5001,7}, text = {"Trainers!"}},
 
[6] = {pos = {989,991,7}, text = {"Items!"}},
[7] = {pos = {5006,4999,7}, text = {"Events!"}},
[8] = {pos = {5006,4998,7}, text = {"City 1!"}},
[9] = {pos = {5006,4997,7}, text = {"City 2!"}},
[10] = {pos = {5006,5000,7}, text = {"RL City!"}},
[11] = {pos = {5006,5001,7}, text = {"Items!"}},
[12] = {pos = {4994,4997,7}, text = {"Don Shop!"}},
        }

        local effects = {
        --X pos,Y pos, Z pos, text
       [1] = {pos = {2000,2000,7}, effect = {37}},
       [2] = {pos = {4994,5000,7}, effect = {37}},
       [3] = {pos = {4994,4999,7}, effect = {37}},
       [4] = {pos = {4994,4998,7}, effect = {37}},
       [5] = {pos = {4994,4997,7}, effect = {37}},
       [6] = {pos = {5006,4997,7}, effect = {37}},
       [7] = {pos = {5006,4998,7}, effect = {37}},
       [8] = {pos = {5006,4999,7}, effect = {37}},
       [9] = {pos = {5006,5000,7}, effect = {37}},
       [10] = {pos = {5006,5001,7}, effect = {37}},
        }

function onThink(interval, lastExecution)
        for _, area in pairs(text) do
                doSendAnimatedText({x=area.pos[1],y=area.pos[2],z=area.pos[3]},area.text[1], math.random(210,210))
        end
        for _, area in pairs(effects) do
                doSendMagicEffect({x=area.pos[1],y=area.pos[2],z=area.pos[3]},area.effect[1])
        end
        local pos = getThingPos(cid)
                    doSendDistanceShoot({x=pos.x+2,y=pos.y+2,z=pos.z},pos, CONST_ANI_HOLY)
                    doSendDistanceShoot({x=pos.x+2,y=pos.y-2,z=pos.z},pos, CONST_ANI_HOLY)
                    doSendDistanceShoot({x=pos.x-2,y=pos.y-2,z=pos.z},pos, CONST_ANI_HOLY)
                    doSendDistanceShoot({x=pos.x-2,y=pos.y+2,z=pos.z},pos, CONST_ANI_HOLY)
        return true
end

thats the error im getting...

Code:
[23:33:42.985] [Error - GlobalEvent Interface]
[23:33:42.987] data/globalevents/scripts/effects.lua:onThink
[23:33:42.988] Description:
[23:33:42.990] data/globalevents/scripts/effects.lua:51: attempt to index local 'pos' (a boolean value)
[23:33:42.991] stack traceback:
[23:33:42.992]  data/globalevents/scripts/effects.lua:51: in function <data/globalevents/scripts/effects.lua:43>
[23:33:42.993] [Error - GlobalEvents::think] Couldn't execute event: effects

TFS 0.4
 
Solution
Lua:
local text = {
    -- position, text
    {pos = {x = 2000, y = 2000, z = 7}, text = "WELCOME!"},
    {pos = {x = 4994, y = 4999, z = 7}, text = "Monsters!"},
    {pos = {x = 4994, y = 5000, z = 7}, text = "Quests!"},
    {pos = {x = 989, y = 989, z = 7}, text = "Arena!"},
    {pos = {x = 4994, y = 5001, z = 7}, text = "Trainers!"},  
    {pos = {x = 989, y = 991, z = 7}, text = "Items!"},
    {pos = {x = 5006, y = 4999, z = 7}, text = "Events!"},
    {pos = {x = 5006, y = 4998, z = 7}, text = "City 1!"},
    {pos = {x = 5006, y = 4997, z = 7}, text = "City 2!"},
    {pos = {x = 5006, y = 5000, z = 7}, text = "RL City!"},
    {pos = {x = 5006, y = 5001, z = 7}, text = "Items!"},
    {pos = {x = 4994, y = 4997, z = 7}, text = "Don...
cid isn't defined for onThink globalevent, are you trying to make the player send a distance effect to a position?
 
Lua:
local text = {
    -- position, text
    {pos = {x = 2000, y = 2000, z = 7}, text = "WELCOME!"},
    {pos = {x = 4994, y = 4999, z = 7}, text = "Monsters!"},
    {pos = {x = 4994, y = 5000, z = 7}, text = "Quests!"},
    {pos = {x = 989, y = 989, z = 7}, text = "Arena!"},
    {pos = {x = 4994, y = 5001, z = 7}, text = "Trainers!"},  
    {pos = {x = 989, y = 991, z = 7}, text = "Items!"},
    {pos = {x = 5006, y = 4999, z = 7}, text = "Events!"},
    {pos = {x = 5006, y = 4998, z = 7}, text = "City 1!"},
    {pos = {x = 5006, y = 4997, z = 7}, text = "City 2!"},
    {pos = {x = 5006, y = 5000, z = 7}, text = "RL City!"},
    {pos = {x = 5006, y = 5001, z = 7}, text = "Items!"},
    {pos = {x = 4994, y = 4997, z = 7}, text = "Don Shop!"},
}

local effects = {
    -- position, effect
    {pos = {x = 2000, y = 2000, z = 7}, effect = 37},
    {pos = {x = 4994, y = 5000, z = 7}, effect = 37},
    {pos = {x = 4994, y = 4999, z = 7}, effect = 37},
    {pos = {x = 4994, y = 4998, z = 7}, effect = 37},
    {pos = {x = 4994, y = 4997, z = 7}, effect = 37},
    {pos = {x = 5006, y = 4997, z = 7}, effect = 37},
    {pos = {x = 5006, y = 4998, z = 7}, effect = 37},
    {pos = {x = 5006, y = 4999, z = 7}, effect = 37},
    {pos = {x = 5006, y = 5000, z = 7}, effect = 37},
    {pos = {x = 5006, y = 5001, z = 7}, effect = 37},
}

local centerpos = {x = 1000, y = 1000, z = 1000}

function onThink(interval, lastExecution)
    for _, area in pairs(text) do
        doSendAnimatedText(area.pos, area.text, math.random(210,210))
    end
    for _, area in pairs(effects) do
        doSendMagicEffect(area.pos, area.effect)
    end
    doSendDistanceShoot({x=centerpos.x+2,y=centerpos.y+2,z=centerpos.z},centerpos, CONST_ANI_HOLY)
    doSendDistanceShoot({x=centerpos.x+2,y=centerpos.y-2,z=centerpos.z},centerpos, CONST_ANI_HOLY)
    doSendDistanceShoot({x=centerpos.x-2,y=centerpos.y-2,z=centerpos.z},centerpos, CONST_ANI_HOLY)
    doSendDistanceShoot({x=centerpos.x-2,y=centerpos.y+2,z=centerpos.z},centerpos, CONST_ANI_HOLY)
    return true
end
fixed up the code so it's properly indented and uses a proper setup
fix up the real position of centerpos and it'll work
 
Solution
Back
Top