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

TFS 1.2 Standing in specific tile/pos saying specific word triggers NPC Spawn

froy

Active Member
Joined
Sep 30, 2009
Messages
151
Solutions
3
Reaction score
36
Wondering if this is possible?
If so, how would it look like?

Standing in x:32045 y:35034 z:7
Saying for example: apple
Docreatenpc: James
Possibly remove npc after x amount of time so other players need to follow quest path.
 
Solution
Wondering if this is possible?
If so, how would it look like?

Standing in x:32045 y:35034 z:7
Saying for example: apple
Docreatenpc: James
Possibly remove npc after x amount of time so other players need to follow quest path.
talkactions/talkactions.xml
XML:
<talkaction words="apple" script="hidden_npc.lua" />
talkactions/scripts/hidden_npc.lua
Lua:
local config = {
    npc_name = "Alice",
    npc_pos = Position(1000, 1001, 7),
    required_pos = Position(1000, 1000, 7),
    duration = 1 -- in minutes
}

function onSay(player, words, param)
    if player:getPosition() == config.required_pos and not Npc(config.npc_name) then
        if Game.createNpc(config.npc_name, config.npc_pos, true, true) then...
Wondering if this is possible?
If so, how would it look like?

Standing in x:32045 y:35034 z:7
Saying for example: apple
Docreatenpc: James
Possibly remove npc after x amount of time so other players need to follow quest path.
talkactions/talkactions.xml
XML:
<talkaction words="apple" script="hidden_npc.lua" />
talkactions/scripts/hidden_npc.lua
Lua:
local config = {
    npc_name = "Alice",
    npc_pos = Position(1000, 1001, 7),
    required_pos = Position(1000, 1000, 7),
    duration = 1 -- in minutes
}

function onSay(player, words, param)
    if player:getPosition() == config.required_pos and not Npc(config.npc_name) then
        if Game.createNpc(config.npc_name, config.npc_pos, true, true) then
            addEvent(function(name)
                local npc = Npc(name)
                if npc then
                    npc:getPosition():sendMagicEffect(CONST_ME_POFF)
                    npc:remove()
                end
            end, config.duration * 60 * 1000, config.npc_name)
        end
    end
    return true
end
 
Solution
Back
Top