Ir para conteúdo
  • Cadastre-se

Posts Recomendados

Oi gente, eu estava procurando aqui um npc de aposta de 21 e achei no meio das minhas coisas vou disponibilizar pra vcs.

 

Testado em 0.3.6 e 0.4

 

XML


<?xml version="1.0"?>
<npc name="Brian O'Conner" script="data/npc/scripts/dicer.lua" walkinterval="0" floorchange="0">
<health now="100" max="100"/>
<look type="132" head="114" body="0" legs="0" feet="114" addons="3"/>
<parameters>
<parameter key="message_greet" value="Ola |PLAYERNAME|, quer {apostar} comigo? " />
</parameters>
</npc>

 

 

 

 

LUA


price_21 = 1000 -- 1k ou 1000gold

price_jogo6 = 5000


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


if(msgcontains(msg, 'apostar')) then

selfSay('Eu faco 2 jogos: {21}, e jogo do {6}, escolha um deles!', cid)

talkState[talkUser] = 5

elseif (msgcontains(msg, '6') and talkState[talkUser] == 5)    then

selfSay('O Jogo do 6 funciona assim: Eu vou rodar um dado, e se cair no numero 6 voce ganha o sextuplo (6 vezes) do valor apostado.', cid)

selfSay('Caso nao caia no 6, voce perde apenas o dinheiro da aposta.', cid)

selfSay('Esta pronto para {comecar}?.', cid)

talkState[talkUser] = 3

elseif(msgcontains(msg, 'comecar') and talkState[talkUser] == 3) then

selfSay('Voce possui o {dinheiro} da aposta ('..price_jogo6..')golds ?', cid)

if doPlayerRemoveMoney(cid, price_jogo6) == TRUE then

talkState[talkUser] = 2

else

selfSay('Desculpe, mais voce nao tem dinheiro para apostar comigo.',cid)

end

elseif(msgcontains(msg, 'dinheiro') and talkState[talkUser] == 2) then

sorteio6 = math.random(1,6)

if sorteio6 == 6 then

talkState[talkUser] = 3

selfSay('Parabens, o numero sorteado foi 6 e voce acaba de ganhar '..(price_jogo6*6) ..'golds, mais o dinheiro que voce pagou da aposta.',cid)

doPlayerAddMoney(cid,price_jogo6*6)

else

talkState[talkUser] = 2

selfSay('Que azar, o numero sorteado foi '..sorteio6..', mais sorte na proxima.',cid)

end

elseif(msgcontains(msg, '21') and talkState[talkUser] == 5) then

selfSay('O 21 funciona assim: Voce ira ganhar 1 numero e o numero tem quer ser 21, ou chegar o mais proximo possivel sem ultrapassar esse valor.', cid)

selfSay('E a mesma coisa sera feita comigo, ganharei 1 numero.', cid)

selfSay('Voce pode ir comprando mais numeros dizendo {comprar} e se quiser parar e so dizer {parar}.', cid)

selfSay('Se voce ganhar de mim, voce leva o triplo do dinheiro apostado.', cid)

selfSay('Esta pronto para {comecar}?.', cid)

talkState[talkUser] = 0

elseif(msgcontains(msg, 'comecar') and talkState[talkUser] == 0) then

selfSay('Voce possui o {dinheiro} da aposta ('..price_21..')golds ?', cid)

talkState[talkUser] = 1

elseif(msgcontains(msg, 'dinheiro') and talkState[talkUser] == 1) then

if doPlayerRemoveMoney(cid, price_21) == TRUE then

talkState[talkUser] = 0

local mpn = math.random(1,21)

setPlayerStorageValue(cid, 55411,mpn)  

local pn = getPlayerStorageValue(cid, 55411)        

selfSay('Seu numero e '..pn..', quer comprar mais ou parar?',cid)

else

selfSay('Desculpe, mais voce nao tem dinheiro para apostar comigo.',cid)

end

elseif(msgcontains(msg, 'comprar') and talkState[talkUser] == 0) then

local cp = math.random(1,10)

setPlayerStorageValue(cid, 55411, (getPlayerStorageValue(cid, 55411))+cp)

selfSay('Seu numero e '..getPlayerStorageValue(cid, 55411)..', quer comprar mais ou parar?',cid)

talkState[talkUser] = 0  

elseif(msgcontains(msg, 'parar') and talkState[talkUser] == 0) then

local npcn = math.random(1,21)

setPlayerStorageValue(cid, 2224, npcn)

if getPlayerStorageValue(cid, 55411) < getPlayerStorageValue(cid, 2224) then

selfSay('Meu numero e '..getPlayerStorageValue(cid, 2224)..'.',cid)       

selfSay('Seu numero final e '..getPlayerStorageValue(cid, 55411)..'.',cid)  

selfSay('Ganhei, mais sorte na proxima vez.',cid)   

talkState[talkUser] = 1

elseif getPlayerStorageValue(cid, 55411) == getPlayerStorageValue(cid, 2224) then

selfSay('Meu numero e '..getPlayerStorageValue(cid, 2224)..'.',cid)       

selfSay('Seu numero final e '..getPlayerStorageValue(cid, 55411)..'.',cid)  

selfSay('Empato, portanto ninguem ganha nada.',cid)

talkState[talkUser] = 1

elseif  getPlayerStorageValue(cid, 55411) > getPlayerStorageValue(cid, 2224) and getPlayerStorageValue(cid, 55411) <= 21 then

selfSay('Meu numero e '..getPlayerStorageValue(cid, 2224)..'.',cid)       

selfSay('Seu numero final e '..getPlayerStorageValue(cid, 55411)..'.',cid)  

local somag = (price_21*3)

selfSay('Voce ganhou '..somag..'golds, mais os seus '..price_21..'golds de volta. Parabens !!!',cid)   

doPlayerAddMoney(cid, somag)

doPlayerAddMoney(cid, price_21)

talkState[talkUser] = 1

else

selfSay('Você tirou um numero maior que 21, então você perdeu.',cid)

end                       

end

return true

end


npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

Link para o post
Compartilhar em outros sites
  • Moderador

Tópico aprovado e agradecemos pela contribuição.

 

20230912_034613.png.cf49b650c34dd7d7b1f79bd49c70f53c.png

Eu sou um entusiasta da programação apaixonado por ajudar a comunidade open source a crescer. Sempre em busca de novos desafios e oportunidades para contribuir com meu código.  #OpenSource #Programação #Contribuição

 

Link para o post
Compartilhar em outros sites

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.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.


  • Conteúdo Similar

    • Por specail
      Olá. Estou com um problema no NPC Halvar, o carinha da arena de Svar... A quest funciona normalmente (cada player só pode fazer 1x cada e em ordem, começando pela Greenhorn, depois Scrapper e Warlord...)
       
      Porém aparecem alguns erros que incomodam um pouco, queria saber se tem como tirar...

      Quando falo hi pro npc:
       
      [15/7/2023 18:29:17] [Error - NpcScript Interface] [15/7/2023 18:29:17] data/npc/scripts/arena.lua:onCreatureSay [15/7/2023 18:29:17] Description: [15/7/2023 18:29:17] (LuaInterface::internalGetPlayerInfo) Player not found when requesting player info #3 [15/7/2023 18:29:17] [Error - NpcScript Interface] [15/7/2023 18:29:17] data/npc/scripts/arena.lua:onCreatureSay [15/7/2023 18:29:17] Description: [15/7/2023 18:29:17] data/npc/scripts/arena.lua:46: attempt to compare number with boolean [15/7/2023 18:29:17] stack traceback: [15/7/2023 18:29:17] data/npc/scripts/arena.lua:46: in function <data/npc/scripts/arena.lua:34> [15/7/2023 18:29:17] [C]: in function 'selfSay' [15/7/2023 18:29:17] data/npc/scripts/arena.lua:37: in function <data/npc/scripts/arena.lua:34>  
      E quando eu falo bye ou fico sem digitar nada por alguns segundos o NPC fica louco e spamma "bye" 20 vezes kkkkkk... Segue o erro:
      [15/7/2023 18:29:28] [Error - NpcEvents::onCreatureSay] NPC Name: Halvar - Call stack overflow  
      Eu renomeei todas falas dele com "bye" pra saber qual causava isso, porque o fdm tem 4 falas assim... e a mensagem que ele está spamando é essa que esta agora como "Bye three!"
      Segue o script completo que acusa o erro:
      domodlib('arenaFunctions') 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 focus = 0 local talk_start = 0 local TS = 0 function onCreatureDisappear(cid, pos) if focus == cid then selfSay('Bye one.') focus = 0 talk_start = 0 end end local function BYE() focus = 0 talk_start = 0 TS = 0 end function msgcontains(txt, str) return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)')) end function onCreatureSay(cid, type, msg) msg = string.lower(msg) if (msgcontains(msg, 'hi') and (focus == 0)) then selfSay('Hello ' .. getCreatureName(cid) .. ', do you want to fight in the arena?') focus = cid talk_start = os.clock() TS = 1 elseif msgcontains(msg, 'hi') and (focus ~= cid) then selfSay('Im Busy') elseif TS == 1 and msgcontains(msg, 'yes') or msgcontains(msg, 'fight') or msgcontains(msg, 'arena') then if getPlayerStorageValue(cid, myArenaLevel) < 3 then local enterArena = myArenaLevelIs(cid) if getPlayerLevel(cid) >= enterArena.RLV then if getPlayerMoney(cid) >= enterArena.RC then setPlayerStorageValue(cid, talkNPC, 1) doPlayerRemoveMoney(cid, enterArena.RC) selfSay("Now you can face the... ".. enterArena.LN .."level!") BYE() else selfSay("You don\'t have "..enterArena.RC.." gold! Come back when you are ready!") BYE() end else selfSay("You don\'t have level "..enterArena.RLV.." yet! Come back when you are ready!") BYE() end else selfSay(Cancel[6]) BYE() end elseif TS == 1 and msgcontains(msg, 'no') then selfSay("Bye two!") BYE() elseif msgcontains(msg, 'bye') then selfSay("Bye three!") BYE() end return true end function onThink() doNpcSetCreatureFocus(focus) if (os.clock() - talk_start) > 10 then if focus > 0 then selfSay('Bye four.') end focus = 0 end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())  
    • Por Imperius
      Olá! Estou disponibilizando um NPC que desenvolvi. Porém, devo avisar que só testei em TFS 0.4, e não posso garantir que funcionará em outras versões.
       
      Sobre:
       
      O NPC em questão é o "Gênio da Lâmpada". Para chegar até ele, o jogador precisa ter a "Lâmpada Mágica", que pode ser adquirida através de uma quest ou em algum evento do servidor, por exemplo.
       
      A lâmpada pode ser usada apenas uma vez e, mesmo que o jogador obtenha outra lâmpada, não poderá usá-la novamente. Ao usar a Lâmpada, o jogador será teleportado para a sala do Gênio. Lá, ele não poderá sair até realizar os três desejos.
       
      O Gênio pode atender desejos como "entregar itens", "reiniciar tasks", "completar addons" e até mesmo "matar um jogador". Você pode personalizar o NPC para oferecer outras recompensas, como "vip days", "premium points" ou "remover redskull". Seja criativo! :)
       
      Após o Gênio realizar os três desejos, o jogador será teleportado para o seu templo de origem.
       
       
      Vídeo demonstrativo:
       
       
       
       
      data > actions > actions.xml
       
       
       
      data > actions > lampadaDoGenio.lua
       
       
       
      data > npc > Genio.xml
       
       
       
      data > npc > scripts > Genio.lua
       
       
       
      Isso é tudo! Se tiverem sugestões ou dúvidas, estou à disposição!
    • Por L3K0T
      NPC DE TELETRANSPORTE
       
      Nada mais diz, é um NPC que faz para teletransportar jogadores para lugares aleatórios e deixando o jogo mais interessante.
       
       
      INSTALANDO:
      1 - vá em data/npc/scripts copie um arquivo .lua, renomeia a gosto, apague o que esta dentro e adicione o código abaixo:
       
      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 l3k0tpos = { {x = 1002, y = 1000, z = 7}, --trocar posisão 1 {x = 1003, y = 1000, z = 7}, --trocar posisão 2 {x = 1004, y = 1000, z = 7}, --trocar posisão 3 {x = 1004, y = 1000, z = 7} --trocar posisão 4 } 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, 'teleporte')) and talkState[talkUser] ~= 2 then selfSay('Gostaria de ir para um lugar aletorio? {yes} ou {no}.', cid) talkState[talkUser] = 1 elseif(msgcontains(msg, 'yes')) and talkState[talkUser] == 1 then local l3k0t = l3k0tpos[math.random(#l3k0tpos)] doTeleportThing(cid, l3k0t) doSendMagicEffect(l3k0t, CONST_ME_TELEPORT) selfSay('Pronto! Boa jornada.', cid) talkState[talkUser] = 0 elseif(msgcontains(msg, 'no')) and talkState[talkUser] ~= 1 then talkState[talkUser] = 0 selfSay('Ok, até logo!', cid) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())  
       
      2 - agora em data/npc/ copie um arquivo .xml, renomeia a gosto e coloque o colodigo abaixo:
       
      <npc name="Teleporte" script="data/npc/scripts/npctelerandom.lua" floorchange="0" walkinterval="2000" access="5" level="1" maglevel="1"> <health now="150" max="150"/> <look type="128" head="79" body="95" legs="57" feet="106" addons="2"/> <parameters> <parameter key="message_greet" value="Hello |PLAYERNAME| posso te levar para um ilugar especial, deseja ir? é só dizer {teleporte}" /> </parameters> </npc>  
       
      Créditos: @L3K0T
      agora é só por o npc no mapa e usar
       
       
       
       
    • Por Vodkart
      Em alguns servidores a função 'doPlayerRemoveItem' não tem o parâmetro 'ignoreEquipped', fazendo com que o jogador acabe vendendo os itens que estão nos slots(equipados).
       
      Esta função(gambiarra) serve para que o jogador ao vender itens no npc, o mesmo só compre itens que estiverem dentro da bp.
       
       
      Primeiramente coloque essas duas funções na lib do seu ot caso você não tenha:
       
      https://pastebin.com/raw/BfRLcrLA
       
       
      agora vá em \data\npc\lib\npcsystem e abra o seu modules.lua 
       
      substitua essa função:
       
      -- Callback onSell() function. If you wish, you can change certain Npc to use your onSell(). function ShopModule:callbackOnSell(cid, itemid, subType, amount, ignoreCap, inBackpacks) if(self.npcHandler.shopItems[itemid] == nil) then error("[ShopModule.onSell]", "items[itemid] == nil") return false end if(self.npcHandler.shopItems[itemid].sellPrice == -1) then error("[ShopModule.onSell]", "Attempt to sell a non-sellable item") return false end local parseInfo = { [TAG_PLAYERNAME] = getPlayerName(cid), [TAG_ITEMCOUNT] = amount, [TAG_TOTALCOST] = amount * self.npcHandler.shopItems[itemid].sellPrice, [TAG_ITEMNAME] = self.npcHandler.shopItems[itemid].realName } if(subType < 1) then subType = -1 end if(doPlayerRemoveItem(cid, itemid, amount, subType)) then local msg = self.npcHandler:getMessage(MESSAGE_SOLD) msg = self.npcHandler:parseMessage(msg, parseInfo) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, msg) doPlayerAddMoney(cid, amount * self.npcHandler.shopItems[itemid].sellPrice) if(NPCHANDLER_CONVBEHAVIOR ~= CONVERSATION_DEFAULT) then self.npcHandler.talkStart[cid] = os.time() else self.npcHandler.talkStart = os.time() end return true else local msg = self.npcHandler:getMessage(MESSAGE_NEEDITEM) msg = self.npcHandler:parseMessage(msg, parseInfo) doPlayerSendCancel(cid, msg) if(NPCHANDLER_CONVBEHAVIOR ~= CONVERSATION_DEFAULT) then self.npcHandler.talkStart[cid] = os.time() else self.npcHandler.talkStart = os.time() end return false end end  
      por esta:
       
      -- Callback onSell() function. If you wish, you can change certain Npc to use your onSell(). function ShopModule:callbackOnSell(cid, itemid, subType, amount, ignoreCap, inBackpacks) if(self.npcHandler.shopItems[itemid] == nil) then error("[ShopModule.onSell]", "items[itemid] == nil") return false end if(self.npcHandler.shopItems[itemid].sellPrice == -1) then error("[ShopModule.onSell]", "Attempt to sell a non-sellable item") return false end local parseInfo = { [TAG_PLAYERNAME] = getPlayerName(cid), [TAG_ITEMCOUNT] = amount, [TAG_TOTALCOST] = amount * self.npcHandler.shopItems[itemid].sellPrice, [TAG_ITEMNAME] = self.npcHandler.shopItems[itemid].realName } if(subType < 1) then subType = -1 end if getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).itemid ~= 0 then local bp = getPlayerSlotItem(cid, CONST_SLOT_BACKPACK) local z = getContainerItemsById(bp, itemid) if #z >= amount then for i = 1, amount do doRemoveItem(z[i].uid) end local msg = self.npcHandler:getMessage(MESSAGE_SOLD) msg = self.npcHandler:parseMessage(msg, parseInfo) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, msg) doPlayerAddMoney(cid, amount * self.npcHandler.shopItems[itemid].sellPrice) if(NPCHANDLER_CONVBEHAVIOR ~= CONVERSATION_DEFAULT) then self.npcHandler.talkStart[cid] = os.time() else self.npcHandler.talkStart = os.time() end return true else local msg = self.npcHandler:getMessage(MESSAGE_NEEDITEM) msg = self.npcHandler:parseMessage(msg, parseInfo) doPlayerSendCancel(cid, msg) if(NPCHANDLER_CONVBEHAVIOR ~= CONVERSATION_DEFAULT) then self.npcHandler.talkStart[cid] = os.time() else self.npcHandler.talkStart = os.time() end return false end else doPlayerSendCancel(cid, "I only buy items that are inside a BackPack") if(NPCHANDLER_CONVBEHAVIOR ~= CONVERSATION_DEFAULT) then self.npcHandler.talkStart[cid] = os.time() else self.npcHandler.talkStart = os.time() end return false end end  
    • Por Igor teodoro
      Bom dia meus amigos se alguém poder me ajudar eu preciso de uma script 
      Pra colocar em um npc ou um monster pra eele sera um guarda de uma cidade e atacará x vocations tipo vocações humano id 1 ou 2 3 4 5 não será atacadas. ou a vocation 6 7 8 será atacada e monstros invasores da cidade caso alguém possa me ajudar ficarei grato. Tfs 0.4
×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo