Fiz aqui bem corrido.
Para testar, utilize essa query que eu fiz
UPDATE `accounts` SET `p_points` = 5;
Ela fará que todos fiquem com 5 p_points.
Depois para testar
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
local removePoint = 5
local itemId = 2160
if msgcontains(msg, 'test') or msgcontains (msg, 'test1') then
if getPoints(cid) >= removePoint then
selfSay("Você quer comprar um item por "..removePoint.." points?", cid)
talkState[talkUser] = 1
else
selfSay("Desculpe, voce nao tem pontos suficiente para trocar", cid)
end
elseif talkState[talkUser] == 1 then
if msgcontains(msg, 'yes') then
selfSay('Parabéns, obrigado pela troca.', cid)
doPlayerAddItem(cid,itemId)
doPlayerRemovePoints(cid,removePoint)
doSendMagicEffect(getCreaturePosition(cid),17)
talkState[talkUser] = 0
else
selfSay('You don\'t have nothing!', cid)
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Ta bem simples, mas só pra ter uma noção
Testei e ta certinho ;D