Galera, to com um npc que vende bless, promotion e premium scroll.
Tá tudo funcionando bem, exceto por um único detalhe, ele vende a bless mesmo que o player já tenha.
Queria que ele só vendesse quando o player estivesse sem bless.
Segue o LUA dele
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 local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid if(msgcontains(msg, 'premium')) then selfSay('You must pay 30000 gps for a premium scroll. Is it ok for you?', cid) talkState[talkUser] = 1 elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then if(doPlayerRemoveMoney(cid, 30000) == TRUE) then doPlayerAddItem(cid, 16101) selfSay('Enjoy it!', cid) else selfSay('Sorry, you dont have enough money.', cid) end talkState[talkUser] = 0 elseif(msgcontains(msg, 'bless')) then selfSay('I can give you all blessings for an amount of 150000 gps. Is it ok for you?', cid) talkState[talkUser] = 2 elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then if(getPlayerPremiumDays(cid) >= 1) then if(doPlayerRemoveMoney(cid, 150000) == TRUE) then doPlayerAddBlessing(cid, 1) doPlayerAddBlessing(cid, 2) doPlayerAddBlessing(cid, 3) doPlayerAddBlessing(cid, 4) doPlayerAddBlessing(cid, 5) selfSay('You are now blessed!', cid) doSendMagicEffect(getPlayerPosition(cid), 49) else selfSay('Sorry, you dont have enough money.', cid) end else selfSay('Sorry, you need to be premium.', cid) end talkState[talkUser] = 0 elseif(msgcontains(msg, 'promot')) then selfSay('You need to pay 20000 to be promoted. Is it ok for you?', cid) talkState[talkUser] = 3 elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 3) then if(getPlayerPremiumDays(cid) >= 1) then if getPlayerPromotionLevel(cid) < 1 then if(doPlayerRemoveMoney(cid, 20000) == TRUE) then setPlayerPromotionLevel(cid, 1) doSendMagicEffect(getPlayerPosition(cid), 49) selfSay('Congratulations! You are now promoted.', cid) else selfSay('Sorry, you dont have enough money.', cid) end else selfSay('You alredy have a promotion.', cid) end else selfSay('Sorry, you need to be premium.', cid) end talkState[talkUser] = 0 elseif(msgcontains(msg, 'no') and isInArray({1,2,3}, talkState[talkUser]) == TRUE) then talkState[talkUser] = 0 selfSay('Ok then.', cid) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Acredito que a solução seja trivial, bastando usar um "getPlayerBless", mas qual seria o comando certo? Digo, esse "getPlayerBless" não existe, então como posso verificar se o player já tem as bless?