NPC:
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 talkState = {}
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
local price = 1000000
local days = 30
local daysvalue = days * 24 * 60 * 60
local storageplayer = getPlayerStorageValue(cid, 13540)
local timenow = os.time()
if getPlayerStorageValue(cid, 13540) - os.time() <= 0 then
time = timenow + daysvalue
else
time = storageplayer + daysvalue
end
if msgcontains(msg, "vip") then
selfSay("you buy " .. days .. " vip for " .. price .. " Are you sure?", cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, "yes") and talkState[talkUser] == 1)then
if doPlayerRemoveMoney(cid, price) == TRUE then
selfSay('From now, you are vip!', cid)
setPlayerStorageValue(cid, 13540, time)
talkState[talkUser] = 0
npcHandler:releaseFocus(cid)
else
selfSay('You don\'t have '.. price ..'', cid)
talkState[talkUser] = 0
npcHandler:releaseFocus(cid)
end
elseif msg == "no" and talkState[talkUser] == 1 then
selfSay("Then not", cid)
talkState[talkUser] = 0
npcHandler:releaseFocus(cid)
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
chão só para vips passar:
vipe.lua
function onStepIn(cid, item, position, fromPosition)
local config = {
msgDenied = "Vc nao e vip , compre com o NPC.",
msgWelcome = "Seja Bem Vindo a Area vip."
}
if getPlayerStorageValue(cid, 13540) - os.time() <= 0 then
doTeleportThing(cid, fromPosition, true)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, config.msgDenied)
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
return TRUE
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, config.msgWelcome)
return TRUE
end
<movevent type="StepIn" uniqueid="13700" event="script" value="vipe.lua"/>