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

Second Promotion NPC

Coldimus

New Member
Joined
Apr 1, 2021
Messages
7
Reaction score
1
Location
Albania
Hey, folks!

I'd like to know how to implement a GUI that appears when talking to the NPC that would provide a list of requirements needed to make a successful promotion transaction, but if the player does not have what it takes to meet the requirements, it should deny the offer until the player has what it require.

Server Information:
》TFS Version: 0.4
》Client: 8.60

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

function creatureSayCallback(cid, type, msg)
    if(msgcontains(msg, 'second promotion'))then
        npcHandler:say('Second promotion costs 10 cc. Do you want to buy second promotion?', cid)
        talkState = 1
    elseif(talkState == 1 and msgcontains(msg, 'yes'))then
        if(doPlayerRemoveMoney(cid, 100000) == TRUE)then
            npcHandler:say('Congratulations, you have second promotion.', cid)
            doPlayerAddPremiumDays(cid, 7)
        else
            npcHandler:say('Here you are!', cid)
        end
        talkState = 0
    end
    return TRUE
end

local node1 = keywordHandler:addKeyword({'promotion'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'The second promotion promotion costs 10cc. Do you want to buy second promotion?'})
node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 150000, level = 5, promotion = 1, text = 'Congratulations, you have second promotion.'})
node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Return back, when you are ready!', reset = true})
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)   
npcHandler:addModule(FocusModule:new())
 
Back
Top