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

Lua Npc npc that responds to premium account tfs 1.5

bpm91

Intermediate OT User
Joined
May 23, 2019
Messages
931
Solutions
7
Reaction score
128
Location
Brazil
YouTube
caruniawikibr
hello guys, does anyone have an example of this type of function to help me? tfs 1.5
npc only responds and sells items to premium account. if it's free, he says that only premium can access his store.
 
Solution
Try and configure it your way

You can add a shop parameters in npc.xml

Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
 
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


function creatureSayCallback(cid, type, msg)
    local player = Player(cid)
    local talkUser = NPCHANDLER_CONVBEHAVIOR ==...
Try and configure it your way

You can add a shop parameters in npc.xml

Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
 
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


function creatureSayCallback(cid, type, msg)
    local player = Player(cid)
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_PRIVATE and 0 or cid
    if msgcontains(msg, "hi") or msgcontains(msg, "hello") and not npcHandler:isFocused(cid) then
        if player:isPremium() then
            npcHandler:say("Hello, "..getCreatureName(cid).."!", cid)
            npcHandler:addFocus(cid)
            talkState[talkUser] = 0
        else
            npcHandler:say("Only premium players can talk to me...", cid)
            npcHandler:releaseFocus(cid)
            npcHandler:resetNpc(cid)
        end
            return true
    end
    
    if(not npcHandler:isFocused(cid)) then
        return false
    end
        
    if msgcontains(msg, "bye") or msgcontains(msg, "farewell") then
        npcHandler:say("Goodbye!", cid, TRUE)
        npcHandler:releaseFocus(cid)
        npcHandler:resetNpc(cid)
    end
        
    return true
end
 
npcHandler:setMessage(MESSAGE_FAREWELL, "Goodbye!")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
 
Solution
Back
Top