Postado Agosto 23, 2014 10 anos Teste assim: 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 msg = string.lower(msg) local need = {2145, 25} -- id, quantidade local pokemon = "Moltres" -- nome do poke if msgcontains(msg, 'yes') and talkState[talkUser] == 2 then if getPlayerItemCount(cid, need[1]) < need[2] then selfSay('Voce precisa de '..need[2]..' '..getItemNameById(need[1])..' para compra um Pokemon mega evoluido!', cid) talkState[talkUser] = 0 return true if not addPokeToPlayer(cid, pokemon, 0, -1, "normal", true) then selfSay('Voce este com 6 pokemons e não pode fazer a compra do mega Pokemon!', cid) talkState[talkUser] = 0 return true end else doPlayerRemoveItem(cid, need[1], need[2]) addPokeToPlayer(cid, pokemon, 0, 1, 'normal', true) selfSay('Nossa muito bom, obrigado e faça bom proveito do seu novo pokémon!', cid) talkState[talkUser] = 0 end end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Boa sorte. Editado Agosto 24, 2014 10 anos por Adriano SwaTT (veja o histórico de edições)
Postado Agosto 23, 2014 10 anos Autor Irei testar o do adriano. Esse npc vai vende o pokemon moltres por 25 diamonds ID 2145, ele vai executar com a função addPokeToPlayer mais eu não sei porque está dando esse erro, irei testar o do adriano
Postado Agosto 23, 2014 10 anos Teste assim: 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 msg = string.lower(msg) local need = {2145, 25} -- id, quantidade local pokemon = "Moltres" -- nome do poke if msgcontains(msg, 'yes') and talkState[talkUser] == 2 then if getPlayerItemCount(cid, need[1]) < need[2] then selfSay('Voce precisa de '..need[2]..' '..need[1]..' para compra um Pokemon mega evoluido!', cid) talkState[talkUser] = 0 return true if not addPokeToPlayer(cid, pokemon, 0, -1, "normal", true) then selfSay("Voce este com 6 pokemons e não pode fazer a compra do mega Pokemon!", cid) talkState[talkUser] = 0 return true end else doPlayerRemoveItem(cid, need[1], need[2]) addPokeToPlayer(cid, pokemon, 0, 1, 'normal', true) selfSay("Nossa muito bom, obrigado e faça bom proveito do seu novo pokémon!", cid) talkState[talkUser] = 0 end end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Boa sorte. Adriano cadê o id da pokebola? aí só tem o do diamante.
Postado Agosto 23, 2014 10 anos Não precisa do id da pokeball porque já está fixa no script ata, eu só perguntei porquê quero entender mais de script.
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.