Postado Fevereiro 18, 2016 9 anos Por isso que odeio npcs da versão 0.4 local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} local k = { item = 9970 } 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 function getCount(s) local b, e = s:find('%d+') return b and e and math.min(4294967295, tonumber(s:sub(b, e))) or -1 end function creatureSayCallback(cid, type, msg) local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid if not npcHandler:isFocused(cid) then return false elseif msgcontains(msg, 'transfer') then npcHandler:say('Please tell me the amount that you want change.', cid) talkState[talkUser] = 1 if talkState[talkUser] == 1 then if getCount(msg) == -1 then npcHandler:say('Please tell me the amount that you want change.', cid) talkState[talkUser] = nil else count[cid] = getCount(msg) npcHandler:say('Do you want change ' .. count[cid] .. ' '.. getItemNameById(k.item) ..' for ' .. count[cid] .. ' premium points in the website?', cid) talkState[talkUser] = 2 end end elseif talkState[talkUser] == 2 and msgcontains(msg, 'yes') then if doPlayerRemoveItem(cid, k.item, count[cid]) then local p = "UPDATE `accounts` SET `premium_points` = `premium_points` + ".. count[cid] .." where id="..getPlayerAccountId(cid) db.executeQuery(p) npcHandler:say('Very well. You have transfered ' .. count[cid] .. ' '.. getItemNameById(k.item) ..' for ' .. count[cid] .. '.', cid) talkState[talkUser] = nil else npcHandler:say('You do not have the items.', cid) talkState[talkUser] = nil end elseif talkState[talkUser] == 2 and msgcontains(msg, 'no') then npcHandler:say('Ok then.', cid) talkState[talkUser] = nil end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Discord: vankk #7765 Precisando de ajuda? Entre em contato comigo via Discord. Muitos vêm seus muitos dias de glória, mas poucos vêm seus muitos dias de luta.
Postado Fevereiro 18, 2016 9 anos Autor Desculpa foi erro meu, esqueci de falar que é 0.4.. vou testar esse agora.
Postado Fevereiro 18, 2016 9 anos Não foi seu, foi meu mesmo, eu esqueço sempre de configurar o talkState mesmo. Testa e veja o que da. Discord: vankk #7765 Precisando de ajuda? Entre em contato comigo via Discord. Muitos vêm seus muitos dias de glória, mas poucos vêm seus muitos dias de luta.
Postado Fevereiro 18, 2016 9 anos Autor @vankk Agora quando eu falo hi > transfer acontece o seguinte: 19:29 Transferir Pontos: Please tell me the amount that you want change. 19:29 Transferir Pontos: Please tell me the amount that you want change. 19:29 GM Vy'n [661]: 100 Ele manda a mensagem duas vezes ai eu mando a quantidade ele não fala mais nada, e não da nenhum erro na distro. Editado Fevereiro 18, 2016 9 anos por One Punch Man (veja o histórico de edições)
Postado Fevereiro 18, 2016 9 anos local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} local k = { item = 9970 } 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 function getCount(s) local b, e = s:find('%d+') return b and e and math.min(4294967295, tonumber(s:sub(b, e))) or -1 end function creatureSayCallback(cid, type, msg) local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid if not npcHandler:isFocused(cid) then return false elseif msgcontains(msg, 'transfer') then npcHandler:say('Please tell me the amount that you want change.', cid) talkState[talkUser] = 1 if talkState[talkUser] == 1 then if getCount(msg) == -1 then count[cid] = getCount(msg) npcHandler:say('Do you want change ' .. count[cid] .. ' '.. getItemNameById(k.item) ..' for ' .. count[cid] .. ' premium points in the website?', cid) talkState[talkUser] = 2 end end elseif talkState[talkUser] == 2 and msgcontains(msg, 'yes') then if doPlayerRemoveItem(cid, k.item, count[cid]) then local p = "UPDATE `accounts` SET `premium_points` = `premium_points` + ".. count[cid] .." where id="..getPlayerAccountId(cid) db.executeQuery(p) npcHandler:say('Very well. You have transfered ' .. count[cid] .. ' '.. getItemNameById(k.item) ..' for ' .. count[cid] .. '.', cid) talkState[talkUser] = nil else npcHandler:say('You do not have the items.', cid) talkState[talkUser] = nil end elseif talkState[talkUser] == 2 and msgcontains(msg, 'no') then npcHandler:say('Ok then.', cid) talkState[talkUser] = nil end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Discord: vankk #7765 Precisando de ajuda? Entre em contato comigo via Discord. Muitos vêm seus muitos dias de glória, mas poucos vêm seus muitos dias de luta.
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.