Postado Outubro 6, 2023 1 ano Quero criar um NPC que verifica o storage ou vocation do player, se tiver a storage abre a loja A, do contrario abre a B. Onde está o erro do código? 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 if getPlayerStorageValue(cid, 10036) == 1 then local shopModule = ShopModule:new() npcHandler:addModule(shopModule) shopModule:addBuyableItem({'spellbook'}, 2175, 150, 'spellbook') shopModule:addBuyableItem({'magic lightwand'}, 2163, 100, 'magic lightwand') else local shopModule = ShopModule:new() npcHandler:addModule(shopModule) shopModule:addBuyableItem({'small health'}, 8704, 20, 1, 'small health potion') shopModule:addBuyableItem({'health potion'}, 7618, 45, 1, 'health potion') end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Postado Outubro 10, 2023 1 ano local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) 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 shopModule = ShopModule:new() local function greetCallback(cid) if (not npcHandler:isFocused(cid)) then return false end if getPlayerStorageValue(cid, 10036) == 1 then shopModule:addBuyableItem({'spellbook'}, 2175, 150, 'spellbook') shopModule:addBuyableItem({'magic lightwand'}, 2163, 100, 'magic lightwand') else shopModule:addBuyableItem({'small health'}, 8704, 20, 1, 'small health potion') shopModule:addBuyableItem({'health potion'}, 7618, 45, 1, 'health potion') end return true end npcHandler:addModule(shopModule) npcHandler:setCallback(CALLBACK_GREET, greetCallback) npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Não sei o que você teria errado, apenas coloquei como greetCallback Editado Outubro 10, 2023 1 ano por Fabi Marzan (veja o histórico de edições)
Postado Outubro 11, 2023 1 ano Autor Em 09/10/2023 em 23:05, Fabi Marzan disse: local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) 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 shopModule = ShopModule:new() local function greetCallback(cid) if (not npcHandler:isFocused(cid)) then return false end if getPlayerStorageValue(cid, 10036) == 1 then shopModule:addBuyableItem({'spellbook'}, 2175, 150, 'spellbook') shopModule:addBuyableItem({'magic lightwand'}, 2163, 100, 'magic lightwand') else shopModule:addBuyableItem({'small health'}, 8704, 20, 1, 'small health potion') shopModule:addBuyableItem({'health potion'}, 7618, 45, 1, 'health potion') end return true end npcHandler:addModule(shopModule) npcHandler:setCallback(CALLBACK_GREET, greetCallback) npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Não sei o que você teria errado, apenas coloquei como greetCallback Puts pior que não deu. O NPC nao respondeu ao Hi agora.
Postado Outubro 25, 2023 1 ano 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 if getPlayerStorageValue(cid, 10036) == 1 then local shopModule = ShopModule:new() npcHandler:addModule(shopModule) shopModule:addBuyableItem({'spellbook'}, 2175, 150, 10, 'spellbook') shopModule:addBuyableItem({'magic lightwand'}, 2163, 100, 10, 'magic lightwand') else local shopModule = ShopModule:new() npcHandler:addModule(shopModule) shopModule:addBuyableItem({'small health'}, 8704, 20, 100, 'small health potion') shopModule:addBuyableItem({'health potion'}, 7618, 45, 100, 'health potion') end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) tentar.
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.