• 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.X+ NPC says first time

leeebux

Awsome
Premium User
Joined
May 18, 2009
Messages
104
Reaction score
5
Location
Sweden
Hello!

Im making npc. the first time you say greet him i want him to say something he only says the first time
the same npc are going to be used with mission
 
Solution
Hello!

Im making npc. the first time you say greet him i want him to say something he only says the first time
the same npc are going to be used with mission
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)            npcHandler:onCreatureAppear(cid)             end
function onCreatureDisappear(cid)         npcHandler:onCreatureDisappear(cid)         end
function onCreatureSay(cid, type, msg)     npcHandler:onCreatureSay(cid, type, msg)     end
function onThink()                         npcHandler:onThink()                         end

local storage_id = 9000

local function onGreet_Callback(cid)
    local...
Hello!

Im making npc. the first time you say greet him i want him to say something he only says the first time
the same npc are going to be used with mission
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)            npcHandler:onCreatureAppear(cid)             end
function onCreatureDisappear(cid)         npcHandler:onCreatureDisappear(cid)         end
function onCreatureSay(cid, type, msg)     npcHandler:onCreatureSay(cid, type, msg)     end
function onThink()                         npcHandler:onThink()                         end

local storage_id = 9000

local function onGreet_Callback(cid)
    local player = Player(cid)
    local storage = player:getStorageValue(storage_id)
    if storage < 1 then
        npcHandler:setMessage(MESSAGE_GREET, "Will only say this the first time.")
        player:setStorageValue(storage_id, 1)
    else
        npcHandler:setMessage(MESSAGE_GREET, "Will say ever time after the first time.")
    end
    return true
end

npcHandler:setCallback(CALLBACK_GREET, onGreet_Callback)
npcHandler:addModule(FocusModule:new())

If you will use the npc as a mission, it may be a good idea to use the same storage key you plan to use for the rest of the mission.
 
Last edited:
Solution
Back
Top