adrenyslopez
Member
- Joined
- Dec 22, 2015
- Messages
- 201
- Reaction score
- 15
hello, this can work that you can only say the command when the target is attacked?
If the command is executed without any target, this error appears
And that the box lasted a little longer at least 10, 15 seconds
script.lua
i used otbr tfs 1.3
If the command is executed without any target, this error appears
Lua:
Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/talkactions/player/target.lua:callback
...rgottenserver/data/scripts/talkactions/player/target.lua:23: attempt to index local 'creature' (a nil value)
stack traceback:
[C]: in function '__index'
...rgottenserver/data/scripts/talkactions/player/target.lua:23: in function <...rgottenserver/data/scripts/talkactions/player/target.lua:2>
And that the box lasted a little longer at least 10, 15 seconds
script.lua
Lua:
local guildTarget = TalkAction("!target")
function guildTarget.onSay(player, words, param)
local color = 210
local pGuild = player:getGuild()
if pGuild == nil then return false end -- no guild
local pGuildRank = player:getGuildLevel()
if pGuildRank and pGuildRank < 2 then return false end -- not vice or leader
local spectators = Game.getSpectators(player:getPosition(), false, true, 7, 7, 5, 5) -- get all players on screen
local creature = player:getTarget()
local guildlst = {}
for _, targetPlayer in ipairs(spectators) do
if not targetPlayer:getGroup():getAccess() then
sGuild = targetPlayer:getGuild()
if sGuild and sGuild == pGuild then
table.insert(guildlst, targetPlayer) -- check if in same guild as player
end
end
end
for _, guildPlayer in ipairs(guildlst) do
guildPlayer:sendCreatureSquare(creature, color)
guildPlayer:say(creature:getName() .. " - Test", TALKTYPE_MONSTER_SAY)
end
return false
end
guildTarget:register()
i used otbr tfs 1.3