Postado Agosto 31, 2014 10 anos Oque eu quero : Um npc chamado "Vendedor de Small Coins" Oque ele vai fazer : Ele vai trocar 100 TD (notas azuis) por 5 Small Coins. Oque o player vai falar : Quando o player dizer : Hi Npc vai dizer : Olá, eu vendo Small Coins, quer comprar? vai te custar 100 TD. Se o player dizer : Yes O NPC vai falar: Você comprou 5 small coins. Se o player dizer: No o NPC vai falar : Ok, deicha para a próxima! Quando o player dizer : Bye o NPC vai falar : Obrigado pela atenção! Boa sorte. Id dos items Small Coins - 2159 TD - 2160 Quantidade que o npc vai trocar O Npc vai pegar 100 TD do usúario e dar 5 Small Coins Aguardando resposta Factur~~
Postado Agosto 31, 2014 10 anos Não testei: <?xml version="1.0" encoding="UTF-8"?> <npc name="Vendedor de Small Coins" script="smallcoin.lua" walkinterval="2000" floorchange="0"> <health now="150" max="150" /> <look type="134" head="57" body="59" legs="40" feet="76" corpse="2212" /> <parameters> <parameter key="message_greet" value="Olá |PLAYERNAME|, eu vendo Small Coins, quer comprar? vai te custar 100 TD." /> <parameter key="message_farewell" value="Obrigado pela atenção! Boa sorte!" /> </parameters> </npc> 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 local items = { item1 = {2160, 2159} } local counts = { count1 = {100, 5} } 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, 'yes') then if getPlayerItemCount(cid, items.item1[1]) >= counts.count1[1] then doPlayerRemoveItem(cid, items.item1[1], counts.count1[1]) doPlayerAddItem(cid, items.item1[2], counts.count1[2]) selfSay('Você comprou 5 small coins.', cid) else selfSay('Você não tem TD suficiente.', cid) end elseif msgcontains(msg, 'no') then selfSay('Ok, deixa para a próxima!', cid) end return TRUE end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Postado Agosto 31, 2014 10 anos Gostei do Script, vou até usar, mas como eu poderia adicionar mais items? Tipo, trocar o TD por mais de 1 item que o player poderá escolher.
Postado Agosto 31, 2014 10 anos Autor Não testei: <?xml version="1.0" encoding="UTF-8"?> <npc name="Vendedor de Small Coins" script="smallcoin.lua" walkinterval="2000" floorchange="0"> <health now="150" max="150" /> <look type="134" head="57" body="59" legs="40" feet="76" corpse="2212" /> <parameters> <parameter key="message_greet" value="Olá |PLAYERNAME|, eu vendo Small Coins, quer comprar? vai te custar 100 TD." /> <parameter key="message_farewell" value="Obrigado pela atenção! Boa sorte!" /> </parameters> </npc> 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 local items = { item1 = {2160, 2159} } local counts = { count1 = {100, 5} } 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, 'yes') then if getPlayerItemCount(cid, items.item1[1]) >= counts.count1[1] then doPlayerRemoveItem(cid, items.item1[1], counts.count1[1]) doPlayerAddItem(cid, items.item1[2], counts.count1[2]) selfSay('Você comprou 5 small coins.', cid) else selfSay('Você não tem TD suficiente.', cid) end elseif msgcontains(msg, 'no') then selfSay('Ok, deixa para a próxima!', cid) end return TRUE end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Infuncional, da esse erro
Postado Agosto 31, 2014 10 anos Tente assim então: <?xml version="1.0" encoding="UTF-8"?> <npc name="Vendedor de Small Coins" script="smallcoin.lua" walkinterval="2000" floorchange="0"> <health now="150" max="150" /> <look type="134" head="57" body="59" legs="40" feet="76" corpse="2212" /> <parameters> <parameter key="message_greet" value="Ola, eu vendo Small Coins, quer comprar? vai te custar 100 TD." /> <parameter key="message_farewell" value="Obrigado pela atençao! Boa sorte!" /> </parameters> </npc> Editado Agosto 31, 2014 10 anos por Rusherzin (veja o histórico de edições)
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.