Opatulek
New Member
- Joined
- Apr 25, 2021
- Messages
- 22
- Reaction score
- 2
local config = {
interval = 5000,
texts = {
{ pos = Position(3191, 1810, 7), text = "Temple!", effects = { CONST_ME_TELEPORT, CONST_ME_DRAWBLOOD } },
{ pos = Position(3188, 1811, 7), text = "Depots!", effects = { CONST_ME_ICEAREA, CONST_ME_ENERGYHIT } },
{ pos = Position(3191, 1814, 7), text = "Skills!", effects = { CONST_ME_ENERGYAREA, CONST_ME_FERUMBRAS } }
}
}
local textOnMap = GlobalEvent("TextOnMap")
function textOnMap.onThink(interval)
local player = Game.getPlayers()[1]
if not player then
return true
end
for k, info in pairs(config.texts) do
player:say(info.text, TALKTYPE_MONSTER_SAY...
local fields = {
{x = 553, y = 446, z = 7, text = "Exp Room", eff = 21},
{x = 553, y = 446, z = 7, text = "", eff = 18},
{x = 281, y = 254, z = 8, text = "TP Room"}, -- text only
{x = 307, y = 254, z = 15, text = "Event", eff = CONST_ME_GROUNDSHAKER},
}
function onThink(interval)
for i = 1, #fields do
local pos = fields
[I] local people = getSpectators(pos, 7, 5, false, true)
if people then
if pos.text then
doCreatureSay(people[1], pos.text, TALKTYPE_MONSTER_SAY, true, 0, pos)
end
if pos.eff then
doSendMagicEffect(pos, pos.eff)
end
end
end
return true
There is someting wrong, I add this script in data\scripts\globalevents\customs trying data\scripts\globalevents too, maybee this is bad location cause I don't see any error, script don't working, no effect on my floor (I changed x y z)Try this
local fields = { {x = 553, y = 446, z = 7, text = "Exp Room", eff = 21}, {x = 553, y = 446, z = 7, text = "", eff = 18}, {x = 281, y = 254, z = 8, text = "TP Room"}, -- text only {x = 307, y = 254, z = 15, text = "Event", eff = CONST_ME_GROUNDSHAKER}, } function onThink(interval) for i = 1, #fields do local pos = fields [I] local people = getSpectators(pos, 7, 5, false, true) if people then if pos.text then doCreatureSay(people[1], pos.text, TALKTYPE_MONSTER_SAY, true, 0, pos) end if pos.eff then doSendMagicEffect(pos, pos.eff) end end end return true[/I]
local config = {
positions = {
{pos = {x = 970, y = 1072, z = 7}, text = "Hello Sir! How are you?", effects = {CONST_ME_MAGIC_BLUE}},
{pos = {x = 855, y = 972, z = 7}, text = "How are you?"}
},
effects = {CONST_ME_POFF, CONST_ME_TELEPORT, CONST_ME_MAGIC_RED}
}
function onThink(interval)
local people = getPlayersOnline()
if #people == 0 then
return true
end
for _, info in pairs(config.positions) do
doPlayerSay(people[1], info.text, TALKTYPE_MONSTER_SAY, false, 0, info.pos)
if info.effects and #info.effects > 0 then
doSendMagicEffect(info.pos, info.effects[math.random(#info.effects)])
elseif config.effects and #config.effects > 0 then
doSendMagicEffect(info.pos, config.effects[math.random(#config.effects)])
end
end
return true
end
teleport:register()
[2021-10-05 19:07:03.945] [error] Lua script error: C:\vcpkg\otservbr-global\data\scripts\globalevents\teleport.lua
...g\otservbr-global\data\scripts\globalevents\teleport.lua:25: attempt to index global 'teleport' (a nil value)
stack traceback:
[C]: in function '__index'
...g\otservbr-global\data\scripts\globalevents\teleport.lua:25: in main chunk
local config = {
positions = {
{pos = {x = 970, y = 1072, z = 7}, text = "Hello Sir! How are you?", effects = {CONST_ME_MAGIC_BLUE}},
{pos = {x = 855, y = 972, z = 7}, text = "How are you?"}
},
effects = {CONST_ME_POFF, CONST_ME_TELEPORT, CONST_ME_MAGIC_RED}
}
local teleport = GlobalEvent("teleport")
function teleport.onThink(interval)
local people = getPlayersOnline()
if #people == 0 then
return true
end
for _, info in pairs(config.positions) do
doPlayerSay(people[1], info.text, TALKTYPE_MONSTER_SAY, false, 0, info.pos)
if info.effects and #info.effects > 0 then
doSendMagicEffect(info.pos, info.effects[math.random(#info.effects)])
elseif config.effects and #config.effects > 0 then
doSendMagicEffect(info.pos, config.effects[math.random(#config.effects)])
end
end
return true
end
teleport:interval(5000)
teleport:register()
[2021-11-05 22:20:22.546] [error] [GlobalEvents::think] - Failed to execute event: teleport
[2021-11-05 22:20:27.535] [error] Lua script error: C:\vcpkg\otservbr-global\data\scripts\teleport.lua:callback
C:\vcpkg\otservbr-global\data\scripts\teleport.lua:12: attempt to call global 'getPlayersOnline' (a nil value)
stack traceback:
[C]: in function 'getPlayersOnline'
C:\vcpkg\otservbr-global\data\scripts\teleport.lua:12: in function <C:\vcpkg\otservbr-global\data\scripts\teleport.lua:11>
local config = {
interval = 5000,
texts = {
{ pos = Position(3191, 1810, 7), text = "Temple!", effects = { CONST_ME_TELEPORT, CONST_ME_DRAWBLOOD } },
{ pos = Position(3188, 1811, 7), text = "Depots!", effects = { CONST_ME_ICEAREA, CONST_ME_ENERGYHIT } },
{ pos = Position(3191, 1814, 7), text = "Skills!", effects = { CONST_ME_ENERGYAREA, CONST_ME_FERUMBRAS } }
}
}
local textOnMap = GlobalEvent("TextOnMap")
function textOnMap.onThink(interval)
local player = Game.getPlayers()[1]
if not player then
return true
end
for k, info in pairs(config.texts) do
player:say(info.text, TALKTYPE_MONSTER_SAY, false, nil, info.pos)
info.pos:sendMagicEffect(info.effects[math.random(1, #info.effects)])
end
return true
end
textOnMap:interval(config.interval)
textOnMap:register()
Solved, it is working, huge thanks!Here is a example TFS 1.3
data/scripts/texteffects.lua
Lua:local config = { interval = 5000, texts = { { pos = Position(3191, 1810, 7), text = "Temple!", effects = { CONST_ME_TELEPORT, CONST_ME_DRAWBLOOD } }, { pos = Position(3188, 1811, 7), text = "Depots!", effects = { CONST_ME_ICEAREA, CONST_ME_ENERGYHIT } }, { pos = Position(3191, 1814, 7), text = "Skills!", effects = { CONST_ME_ENERGYAREA, CONST_ME_FERUMBRAS } } } } local textOnMap = GlobalEvent("TextOnMap") function textOnMap.onThink(interval) local player = Game.getPlayers()[1] if not player then return true end for k, info in pairs(config.texts) do player:say(info.text, TALKTYPE_MONSTER_SAY, false, nil, info.pos) info.pos:sendMagicEffect(info.effects[math.random(1, #info.effects)]) end return true end textOnMap:interval(config.interval) textOnMap:register()
thanks <3Here is a example TFS 1.3
data/scripts/texteffects.lua
Lua:local config = { interval = 5000, texts = { { pos = Position(3191, 1810, 7), text = "Temple!", effects = { CONST_ME_TELEPORT, CONST_ME_DRAWBLOOD } }, { pos = Position(3188, 1811, 7), text = "Depots!", effects = { CONST_ME_ICEAREA, CONST_ME_ENERGYHIT } }, { pos = Position(3191, 1814, 7), text = "Skills!", effects = { CONST_ME_ENERGYAREA, CONST_ME_FERUMBRAS } } } } local textOnMap = GlobalEvent("TextOnMap") function textOnMap.onThink(interval) local player = Game.getPlayers()[1] if not player then return true end for k, info in pairs(config.texts) do player:say(info.text, TALKTYPE_MONSTER_SAY, false, nil, info.pos) info.pos:sendMagicEffect(info.effects[math.random(1, #info.effects)]) end return true end textOnMap:interval(config.interval) textOnMap:register()