Ir para conteúdo

Script Ajuda Ae(Poketibia)


marcotril

Posts Recomendados

olá,bem eu queria um npc Mark que tpw,qndo comprar algum item ganhar 1 outro,

ex:

compro 10small Pot ganho 1 Great Pot,compro 10Pokeball Ganho 1Greatball...

 

 

espero que ajudem ae,Uso Pokemon Flash!

Link para o comentário
Compartilhar em outros sites

NPC.xml

 

Copie e cole qualquer qualquer arquivo e dentro coloque isso:

 

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Mark Bonus" script="bonus.lua" walkinterval="1000" floorchange="0">
<health now="150" max="150"/>
<look type="263" head="119" body="88" legs="119" feet="0" corpse="2212"/>
   <parameters>
       <parameter key="module_travel" value="1"/>
	<parameter key="message_greet" value="Hello PLAYERNAME. Eu vendo |poke balls| e |potions| com uma surpresa. Vale a pena conferir."/>
   </parameters>
</npc>

 

Dentro da pasta scripts copie e cole qualquer arquivo renomeie para bonus.lua e adicione

 

 

 

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

function getPlayerMoney(cid) 
gold = getPlayerItemCount(cid,2148) 
plat = getPlayerItemCount(cid,2152) 
crys = getPlayerItemCount(cid,2160)*10000 
thou = getPlayerItemCount(cid,2387)*10000 
money = gold + plat + crys + thou
return money 
end  

if getPlayerMoney(cid) >= 50000 then         
       doPlayerRemoveMoney(cid, 50000)      
       talk_start = 0
       focus = 0
    else 
        selfSay('Sorry, you don\'t have enough money.') 
    end 
    end
    talk_start = 0   
if msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 and talk_start >= 1 then 
  selfSay('Good bye, ' .. getPlayerName(cid) .. '!') 
  focus = 0 
  talk_start = 0 
  tempo = 0
end 
end 
   if (msgcontains(msg, 'poke ball') or msgcontains(msg, 'poke balls')) and talkState[cid] == 1 then
       selfSay("Are you sure you want to buy 10 Poke Balls + 1 Great Ball (bonus)?", cid)
       talkState[cid] = 4
   elseif (msgcontains(msg, 'nao') or msgcontains(msg, 'no')) and talkState[cid] == 4 then
       selfSay("Well, How may I help you?", cid)
       talkState[cid] = 1
   elseif (msgcontains(msg, 'sim') or msgcontains(msg, 'yes')) and talkState[cid] == 4 then 
   if getPlayerMoney(cid) >= 100 then        
       doPlayerRemoveMoney(cid, 100)      
       talk_start = 0
       focus = 0
    else 
        selfSay('Sorry, you don\'t have enough money.') 
    end 
    end
    talk_start = 0 
      selfSay("Here it is your bonus pack", cid)
      local bags = getPlayerSlotItem(cid, 3)
      local ball = 2147 
      local ball2 = 11437         
     doAddContainerItem(bags.uid, ball , 10)
     doAddContainerItem(bags.uid, ball2 , 1)           
       talkState[cid] = 0  
   end

    if (msgcontains(msg, 'potion') or msgcontains(msg, 'potions')) and talkState[cid] == 1 then
       selfSay("Are you sure you want to buy 10 Small potions + 1 Great Potion (bonus)?", cid)
       talkState[cid] = 4
   elseif (msgcontains(msg, 'nao') or msgcontains(msg, 'no')) and talkState[cid] == 4 then
       selfSay("Well, How may I help you?", cid)
       talkState[cid] = 1
   elseif (msgcontains(msg, 'sim') or msgcontains(msg, 'yes')) and talkState[cid] == 4 then 
   if getPlayerMoney(cid) >= 150 then      
       doPlayerRemoveMoney(cid, 150)      
       talk_start = 0
       focus = 0
    else 
        selfSay('Sorry, you don\'t have enough money.') 
    end 
    end
    talk_start = 0 
      selfSay("Here it is your bonus pack", cid)
      local bags = getPlayerSlotItem(cid, 3)
      local potion = 2272 
      local potion2 = 2275
     doAddContainerItem(bags.uid, potion , 10)
     doAddContainerItem(bags.uid, potion2 , 1)           
       talkState[cid] = 0  
   end

end    
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

 

 

NPC não é o meu forte, espero que de certo, estou viajando e não pude testar qualquer erro poste aqui, para eu ou outro usuário podermos corrigir.

 

Abraço.

Editado por lucashgas
Link para o comentário
Compartilhar em outros sites

deu esses erros....

[12/09/2011 01:35:18] [Error - TalkAction Interface]

[12/09/2011 01:35:18] data/talkactions/scripts/summon.lua:onSay

[12/09/2011 01:35:18] Description:

[12/09/2011 01:35:18] data/talkactions/scripts/summon.lua:4: attempt to index local 't' (a nil value)

[12/09/2011 01:35:18] stack traceback:

[12/09/2011 01:35:18] data/talkactions/scripts/summon.lua:4: in function <data/talkactions/scripts/summon.lua:1>

 

[12/09/2011 01:35:21] [Error - TalkAction Interface]

[12/09/2011 01:35:21] data/talkactions/scripts/summon.lua:onSay

[12/09/2011 01:35:21] Description:

[12/09/2011 01:35:21] data/talkactions/scripts/summon.lua:4: attempt to index local 't' (a nil value)

[12/09/2011 01:35:21] stack traceback:

[12/09/2011 01:35:21] data/talkactions/scripts/summon.lua:4: in function <data/talkactions/scripts/summon.lua:1>

[12/09/2011 01:37:48] [Error - LuaScriptInterface::loadFile] data/npc/scripts/bonus.lua:43: '<eof>' expected near 'end'

[12/09/2011 01:37:48] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/bonus.lua

[12/09/2011 01:37:48] data/npc/scripts/bonus.lua:43: '<eof>' expected near 'end'

[12/09/2011 01:37:50] [Error - LuaScriptInterface::loadFile] data/npc/scripts/bonus.lua:43: '<eof>' expected near 'end'

[12/09/2011 01:37:50] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/bonus.lua

[12/09/2011 01:37:50] data/npc/scripts/bonus.lua:43: '<eof>' expected near 'end'

 

 

[12/09/2011 01:39:04] [Error - Npc interface]

[12/09/2011 01:39:04] (Unknown script file)

[12/09/2011 01:39:04] Description:

[12/09/2011 01:39:04] attempt to index a function value

[12/09/2011 01:39:04] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/loot.lua

 

 

[12/09/2011 01:39:04] [Error - Npc interface]

[12/09/2011 01:39:04] (Unknown script file)

[12/09/2011 01:39:04] Description:

[12/09/2011 01:39:04] attempt to call a nil value

[12/09/2011 01:39:04] stack traceback:

[12/09/2011 01:39:04] Reloaded npcs.

[12/09/2011 01:39:04] [Error - Npc interface]

[12/09/2011 01:39:04] data/npc/scripts/default.lua:onThink

[12/09/2011 01:39:04] Description:

[12/09/2011 01:39:04] attempt to call a nil value

[12/09/2011 01:39:04] stack traceback:

[12/09/2011 01:39:04] [C]: in function 'getItemDescriptionsById'

[12/09/2011 01:39:04] data/lib/050-function.lua:222: in function 'getItemNameById'

[12/09/2011 01:39:04] data/npc/lib/npcsystem/modules.lua:1119: in function 'addSellableItem'

[12/09/2011 01:39:04] data/npc/lib/npcsystem/modules.lua:907: in function 'parseSellable'

[12/09/2011 01:39:04] data/npc/lib/npcsystem/modules.lua:825: in function 'parseParameters'

[12/09/2011 01:39:04] data/npc/lib/npcsystem/npchandler.lua:240: in function 'addModule'

[12/09/2011 01:39:05] data/npc/lib/npcsystem/npcsystem.lua:161: in function 'parseParameters'

[12/09/2011 01:39:05] data/npc/scripts/loot.lua:3: in main chunk

 

 

ae eu pus um end la no Bonus.lua,parou esse erro,dps veio outro!

 

[12/09/2011 01:45:12] [Error - Npc interface]

[12/09/2011 01:45:12] (Unknown script file)

[12/09/2011 01:45:12] Description:

[12/09/2011 01:45:12] attempt to call a nil value

[12/09/2011 01:45:12] stack traceback:

 

[12/09/2011 01:45:13] [Error - Npc interface]

[12/09/2011 01:45:13] (Unknown script file)

[12/09/2011 01:45:13] Description:

[12/09/2011 01:45:14] Stack size changed!

 

ajuda ae :p ja ganhou rep + só por ter dado um inicio^^!

Link para o comentário
Compartilhar em outros sites

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 doCreatureSayWithDelay(cid,text,type,delay,e)
  if delay<=0 then
     doCreatureSay(cid,text,type)
  else
     local func=function(pars)
                   doCreatureSay(pars.cid,pars.text,pars.type)
                   pars.e.done=TRUE
                end
     e.done=FALSE
     e.event=addEvent(func,delay,{cid=cid, text=text, type=type, e=e})
  end
end


function cancelNPCTalk(events)
 local ret=1
 for aux=1,table.getn(events) do
    if events[aux].done==FALSE then
       stopEvent(events[aux].event)
    else
       ret=ret+1
    end
 end
 events=nil
 return(ret)
end


function doNPCTalkALot(msgs,interval)
 local e={}
 local ret={}
 if interval==nil then interval=3000 end --3 seconds is default time between messages
 for aux=1,table.getn(msgs) do
     e[aux]={}
     doCreatureSayWithDelay(getNpcCid(),msgs[aux],TALKTYPE_PRIVATE_NP,(aux-1)*interval,e[aux])
     table.insert(ret,e[aux])
 end
 return(ret)
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

   if(msgcontains(msg, 'Poke Ball') or msgcontains(msg, 'poke ball')) then
   selfSay('Tem certeza que deseja comprar {10 Poke Balls} + {1 Great Ball} ({Bônus})?', cid)
   talkState[talkUser] = 1

   elseif(msgcontains(msg, 'Yes') or msgcontains(msg, 'yes')) then
   selfSay('Você adquiriu {10 Poke Balls} + {1 Great Ball} ({Bônus})', cid)
  doPlayerAddItem(cid,pokeballID,10)
  doPlayerAddItem(cid,greatballID,1)
     talkState[talkUser] = 0

   elseif(msgcontains(msg, 'No') or msgcontains(msg, 'no')) then
   selfSay('Bem, então em quê posso ajuda-lo?', cid)
     talkState[talkUser] = 0

   elseif(msgcontains(msg, 'Small Potion') or msgcontains(msg, 'small potion')) then
   selfSay('Tem certeza que deseja comprar {10 Small potions} + {1 Great Potion ({Bônus})?', cid)
   talkState[talkUser] = 1

   elseif(msgcontains(msg, 'Yes') or msgcontains(msg, 'yes')) then
   selfSay('Você adquiriu {10 Small potions} + {1 Great Potion ({Bônus})', cid)
  doPlayerAddItem(cid,smallpotionID,10)
  doPlayerAddItem(cid,greatpotionID,1)
     talkState[talkUser] = 0

   elseif(msgcontains(msg, 'No') or msgcontains(msg, 'no')) then
   selfSay('Bem, então em quê posso ajuda-lo?', cid)
     talkState[talkUser] = 0

	end	  
return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new()) 

 

 

 

Você precisa colocar a ID das coisas que comprou e do Item Bônus.

Edite :

 

	  doPlayerAddItem(cid,pokeballID,10)
  doPlayerAddItem(cid,greatballID,1)
  doPlayerAddItem(cid,smallpotionID,10)
  doPlayerAddItem(cid,greatpotionID,1)

 

Abraços !! :smile_positivo:

Editado por Frenesy
Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...