Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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)
- if(not npcHandler:isFocused(cid)) then
- return false
- end
- function getNumber(txt)
- x = string.gsub(txt,"%a","")
- x = tonumber(x)
- if x ~= nill and x > 0 then
- return x
- else
- return 0
- end
- end
- local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
- msg = string.lower(msg)
- sell = {[7] = 10, [15] = 20, [30] = 50}
- if (msgcontains(msg, 'premium'))then
- npcHandler:say("Eu vendo {7}, {15} e {30} dias de premium, qual o senhor deseja comprar?", cid)
- talkState[talkUser] = 1
- elseif talkState[talkUser] == 1 then
- if sell[getNumber(msg)] then
- days,p = getNumber(msg),sell[getNumber(msg)]
- selfSay('você quer comprar '..days..' dias de premium por '..p..' points? {yes}', cid)
- talkState[talkUser] = 2
- else
- npcHandler:say("escolha somente números, 7, 15 ou 30 dias.", cid)
- end
- elseif msgcontains(msg, "yes") and talkState[talkUser] == 2 then
- if getAccountPoints(cid) >= p then
- if getPlayerPremiumDays(cid) < 360 then
- doPlayerAddPremiumDays(cid, days)
- doAccountRemovePoints(cid, p)
- npcHandler:say("Obrigado, você comprou "..days.." dias de premium com sucesso, relogue completamente agora.", cid)
- talkState[talkUser] = 0
- else
- npcHandler:say("Você não pode ter mais que 360 dias de premium.", cid)
- end
- else
- npcHandler:say("Você precisa ter "..p.." points.", cid)
- end
- elseif msg == "no" and talkState[talkUser] >= 1 then
- selfSay("tudo bem então.", cid)
- talkState[talkUser] = 0
- npcHandler:releaseFocus(cid)
- end
- return TRUE
- end
- npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
- npcHandler:addModule(FocusModule:new())
Add Comment
Please, Sign In to add comment