williampasqualini 22 Postado Maio 22, 2010 Share Postado Maio 22, 2010 Tipo do script: NPC Protocolo (versão do Tibia): 8.50 Servidor utilizado: Alissow [ theforgottenserver ] Nível de experiência: Baixo Adicionais/Informações: Player conseguem nukar meu server pelo npc bank,o script é o seguinte: -- npc maded by ta4e for tibia 8.31 to 8.42--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 --------------------MESSAGES------------------------------------------------------------------------------ if msgcontains(msg, 'deposit') then selfSay('Please tell me how much gold it is you would like to deposit.', cid) talkState[talkUser] = 1 elseif msgcontains(msg, 'withdraw') then selfSay('Please tell me how much gold you would like to withdraw.', cid) talkState[talkUser] = 3 elseif msgcontains(msg, 'transfer') then selfSay('Please tell me the amount of gold coins you would like to transfer.', cid) talkState[talkUser] = 5 elseif msgcontains(msg, 'change gold') then selfSay('How many platinum coins do you want to get?', cid) talkState[talkUser] = 8 elseif msgcontains(msg, 'change platinum') then selfSay('Do you want to change your platinum coins to gold or crystal?', cid) talkState[talkUser] = 10 elseif msgcontains(msg, 'change crystal') then selfSay('How many crystal coins do you want to change to platinum?', cid) talkState[talkUser] = 15 elseif msgcontains(msg, 'balance') then n = getPlayerBalance(cid) selfSay('Your balance are '..n..' golds.', cid) talkState[talkUser] = 0 ----------------------DEPOSIT------------------------------------------------------- elseif talkState[talkUser] == 1 then if msgcontains(msg, 'all') then n = getPlayerMoney(cid) selfSay('Do you want deposit '..n..' golds ?', cid) talkState[talkUser] = 2 else n = getNumber(msg) selfSay('Do you want deposit '..n..' golds ?', cid) talkState[talkUser] = 2 end elseif talkState[talkUser] == 2 then if msgcontains(msg, 'yes') then if getPlayerMoney(cid) >= n then doPlayerDepositMoney(cid,n) selfSay('Sucessfull. Now your balance account is ' ..getPlayerBalance(cid)..' golds.', cid) talkState[talkUser] = 0 else selfSay('You don\'t have money.', cid) end else selfSay('Ok then', cid) end ----------------------WITHDRAW------------------------------------------------------------------------------------- elseif talkState[talkUser] == 3 then if msgcontains(msg, 'all') then n = getPlayerBalance(cid) selfSay('Do you want withdraw '..n..' golds ?', cid) talkState[talkUser] = 4 else n = getNumber(msg) selfSay('Do you want withdraw '..n..' golds ?', cid) talkState[talkUser] = 4 end elseif talkState[talkUser] == 4 then if msgcontains(msg, 'yes') then if getPlayerBalance(cid) >= n then doPlayerWithdrawMoney(cid, n) selfSay('Here you are, '..n..' gold. Now your balance account is ' ..getPlayerBalance(cid)..' golds.', cid) talkState[talkUser] = 0 else selfSay('There is not enough gold on your account', cid) end else selfSay('Ok then', cid) end ----------------------TRANSFER---------------------------------------------------------------------------------------- elseif talkState[talkUser] == 5 then if msgcontains(msg, 'all') then n = getPlayerBalance(cid) selfSay('Who would you like transfer '..n..' gold to?', cid) talkState[talkUser] = 6 else n = getNumber(msg) selfSay('Who would you like transfer '..n..' gold to?', cid) talkState[talkUser] = 6 end elseif talkState[talkUser] == 6 then p = msg selfSay('So you would like to transfer '..n..' gold to '..p..'?', cid) talkState[talkUser] = 7 elseif talkState[talkUser] == 7 then if msgcontains(msg, 'yes') then if getPlayerBalance(cid) >= n then if doPlayerTransferMoneyTo(cid, p, n) == TRUE then selfSay('You have transferred '..n..' gold to '..p..' and your account balance is '..getPlayerBalance(cid)..' golds.', cid) talkState[talkUser] = 0 else selfSay('This player does not exist. Please tell me a valid name!', cid) talkState[talkUser] = 0 end else selfSay('There is not enough gold on your account', cid) talkState[talkUser] = 0 end else selfSay('Ok then', cid) talkState[talkUser] = 0 end ----------------------CHANGE GOLD--------------------------------------------------------------------------------- elseif talkState[talkUser] == 8 then n = getNumber(msg) b = n * 100 selfSay('So I should change '..b..' of your gold coins to '..n..' platinum coins for you?', cid) talkState[talkUser] = 9 elseif talkState[talkUser] == 9 then if msgcontains(msg, 'yes') then if doPlayerRemoveItem(cid, 2148, b) == TRUE then doPlayerAddItem(cid, 2152, n) talkState[talkUser] = 0 else selfSay('You don\'t have money.', cid) talkState[talkUser] = 0 end else selfSay('Ok. We cancel.', cid) talkState[talkUser] = 0 end ---------------------CHANGE PLATINUM------------------------------------------------------------------------- elseif talkState[talkUser] == 10 then if msgcontains(msg, 'gold') then selfSay('How many platinum coins do you want to change to gold?', cid) talkState[talkUser] = 11 elseif msgcontains(msg, 'crystal') then selfSay('How many crystal coins do you want to get?', cid) talkState[talkUser] = 13 end elseif talkState[talkUser] == 11 then n = getNumber(msg) b = n * 100 selfSay('So I should change '..n..' of your platinum coins to '..b..' gold coins for you?', cid) talkState[talkUser] = 12 elseif talkState[talkUser] == 12 then if msgcontains(msg, 'yes') then if doPlayerRemoveItem(cid, 2152, n) == TRUE then doPlayerAddItem(cid, 2148, b) talkState[talkUser] = 0 else selfSay('You don\'t have money.', cid) talkState[talkUser] = 0 end else selfSay('Ok. We cancel.', cid) talkState[talkUser] = 0 end elseif talkState[talkUser] == 13 then n = getNumber(msg) b = n * 100 selfSay('So I should change '..b..' of your platinum coins to '..n..' crystal coins for you?', cid) talkState[talkUser] = 14 elseif talkState[talkUser] == 14 then if msgcontains(msg, 'yes') then if doPlayerRemoveItem(cid, 2152, b) == TRUE then doPlayerAddItem(cid, 2160, n) talkState[talkUser] = 0 else selfSay('You don\'t have money.', cid) talkState[talkUser] = 0 end else selfSay('Ok. We cancel.', cid) talkState[talkUser] = 0 end ---------------------CHANGE CRYSTAL------------------------------------------------------------------------------- elseif talkState[talkUser] == 15 then n = getNumber(msg) b = n * 100 selfSay('So I should change '..n..' of your crystal coins to '..b..' platinum coins for you?', cid) talkState[talkUser] = 16 elseif talkState[talkUser] == 16 then if msgcontains(msg, 'yes') then if doPlayerRemoveItem(cid, 2160, n) == TRUE then doPlayerAddItem(cid, 2152, b) talkState[talkUser] = 0 else selfSay('You don\'t have money.', cid) talkState[talkUser] = 0 end else selfSay('Ok. We cancel.', cid) talkState[talkUser] = 0 end end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) -- function maded by Gesior-- function getNumber(txt) --return number if its number and is > 0, else return 0 x = string.gsub(txt,"%a","") x = tonumber(x) if x ~= nill and x > 0 then return x else return 0 end end eles usam o sistema change pra trocar um valor muito alto tipo 9999999 e derrubar...Gostaria de saber como retirar a parte de change coin,crystal coin etc... sem que o npc parace de funcionar ou um script de banco que não dece para players derrubar meu server. Link para o comentário https://xtibia.com/forum/topic/133374-npc-banco/ Compartilhar em outros sites More sharing options...
Vodkart 1515 Postado Maio 23, 2010 Share Postado Maio 23, 2010 Evite postar em locais errados pois prejudica a moderação no fórum. Se não souber onde postar, procure por outros topicos parecidos para que voce possa encontrar a área. Reportado para que movam para Dúvidas de Script abraços Link para o comentário https://xtibia.com/forum/topic/133374-npc-banco/#findComment-878691 Compartilhar em outros sites More sharing options...
Henrique Moura 193 Postado Maio 23, 2010 Share Postado Maio 23, 2010 Movido Link para o comentário https://xtibia.com/forum/topic/133374-npc-banco/#findComment-879057 Compartilhar em outros sites More sharing options...
joaohd 200 Postado Maio 24, 2010 Share Postado Maio 24, 2010 Tente usar este: local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} local moneyTo = {} local playerTo = {} 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 function isValidMoney(cid, money) if isNumber(money) == TRUE and money > 0 and money < 999999999 and money <= getPlayerMoney(cid) then return TRUE end return FALSE end function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end if msgcontains(msg, 'ajuda') or msgcontains(msg, 'ofertas') then selfSay("Voce pode checar seu {saldo} da sua conta, {depositar} dinheiro ou {extrair} para retirar. Voce tambem pode {transferir} dinheiro para outros players, tambem pode entrar nas {açoes}, diga {informaçoes} para saber sobre as açoes.", cid) talkState[cid] = 0 ----------------------------------------------------------------- ---------------------------- Balance ---------------------------- ----------------------------------------------------------------- elseif msgcontains(msg, 'saldo') or msgcontains(msg, 'Saldo') then selfSay('Seu saldo é '..getPlayerBalance(cid)..' gold.', cid) talkState[cid] = 0 ----------------------------------------------------------------- ---------------------------- Help ------------------------------- ----------------------------------------------------------------- elseif msgcontains(msg, 'basic functions') then selfSay('Voce pode checar seu {balance} da sua conta, {deposit} dinheiro ou {withdraw} para extrair. Voce tambem pode {transfer} dinheiro para outros players.', cid) talkState[cid] = 0 ----------------------------------------------------------------- ---------------------------- Deposit ---------------------------- ----------------------------------------------------------------- elseif msgcontains(msg, 'depositar tudo') then moneyTo[cid] = getPlayerMoney(cid) if moneyTo[cid] < 1 then selfSay('Voce nao tem dinheiro.', cid) talkState[cid] = 0 else selfSay('Voce realmente quer adicionar '..moneyTo[cid]..' gold?', cid) talkState[cid] = 2 end elseif msgcontains(msg, 'depositar') then selfSay("Porfavor me diga quanto voce quer depositar.", cid) talkState[cid] = 1 elseif talkState[cid] == 1 then moneyTo[cid] = tonumber(msg) if isValidMoney(cid, moneyTo[cid]) == TRUE then selfSay('Voce realmente quer depositar '..moneyTo[cid]..' gold?', cid) talkState[cid] = 2 else selfSay('Nao é uma quantia valida para deposito.', cid) talkState[cid] = 0 end elseif talkState[cid] == 2 then if msgcontains(msg, 'sim') then if doPlayerDepositMoney(cid, moneyTo[cid], 1) ~= TRUE then selfSay('Voce nao tem esse dinheiro.', cid) else selfSay('Tudo bem, nos adicionamos '..moneyTo[cid]..' gold para seu saldo. Voce pode extrair seu dinheiro quando quiser. Seu saldo é ' .. getPlayerBalance(cid) .. '.', cid) end elseif msgcontains(msg, 'nao') then selfSay('Como desejar. Posso fazer mais alguma coisa por voce?', cid) end talkState[cid] = 0 ----------------------------------------------------------------- ---------------------------- Withdraw --------------------------- ----------------------------------------------------------------- elseif msgcontains(msg, 'extrair') then selfSay("Porfavor, diga-me quanto voce deseja extrair.", cid) talkState[cid] = 6 elseif talkState[cid] == 6 then moneyTo[cid] = tonumber(msg) if isValidMoney(cid, moneyTo[cid]) == TRUE then selfSay('Voce esta certo que quer extrair '..moneyTo[cid]..' gold de sua conta de banco?', cid) talkState[cid] = 7 else selfSay('Nao é uma quantia valida para extraçao.', cid) talkState[cid] = 0 end elseif talkState[cid] == 7 then if msgcontains(msg, 'sim') then if doPlayerWithdrawMoney(cid, moneyTo[cid]) ~= TRUE then selfSay('Voce nao tem essa quantia em sua conta. Seu saldo é '..getPlayerBalance(cid)..'. Por favor, diga-me quanto quer extrair.', cid) else selfSay('Aqui esta, ' .. moneyTo[cid] .. ' gold. Porfavor, digame se quizer mais alguma coisa.', cid) talkState[cid] = 0 end elseif msgcontains(msg, 'nao') then selfSay('Como desejar. Posso fazer mais algo?', cid) talkState[cid] = 0 end ----------------------------------------------------------------- ---------------------------- Transfer --------------------------- ----------------------------------------------------------------- elseif msgcontains(msg, 'transferir') then selfSay("Por favor, digame quanto de dinheiro voce quer transferir.", cid) talkState[cid] = 11 elseif talkState[cid] == 11 then moneyTo[cid] = tonumber(msg) if isValidMoney(cid, moneyTo[cid]) == TRUE then selfSay('Voce gostaria de transferir '..moneyTo[cid]..' gold para?', cid) talkState[cid] = 12 else selfSay('Nao é uma quantia valida para deposito.', cid) talkState[cid] = 0 end elseif talkState[cid] == 12 then playerTo[cid] = msg if getCreatureName(cid) == playerTo[cid] then selfSay('Voce deseja transferir dinheiro para voce mesmo? Isto e impossivel!', cid) talkState[cid] = 0 return TRUE end if playerExists(playerTo[cid]) then selfSay('Voce deseja transferir ' .. moneyTo[cid] .. ' gold para "' .. playerTo[cid] .. '" ?', cid) talkState[cid] = 13 else selfSay('O player "' .. playerTo[cid] .. '" nao existe.', cid) talkState[cid] = 0 end elseif talkState[cid] == 13 then if msgcontains(msg, 'sim') then if getPlayerBalance(cid) < moneyTo[cid] then selfSay('Voce nao tem dinheiro em sua conta.', cid) return TRUE end if doPlayerTransferMoneyTo(cid, playerTo[cid], moneyTo[cid]) ~= TRUE then selfSay('Esse player nao existe ou ainda nao tem vocaçao.', cid) else selfSay('Voce transferiu ' .. moneyTo[cid] .. ' gold tpara "' .. playerTo[cid] ..' ".', cid) playerTo[cid] = nil end elseif msgcontains(msg, 'nao') then selfSay('Como deseja. Posso fazer mais alguma coisa para voce?', cid) end talkState[cid] = 0 end return TRUE end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) O script foi retirado do Alissow Server e editado para retirar um possível bug. flw Link para o comentário https://xtibia.com/forum/topic/133374-npc-banco/#findComment-879650 Compartilhar em outros sites More sharing options...
williampasqualini 22 Postado Maio 27, 2010 Autor Share Postado Maio 27, 2010 Tente usar este: local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} local moneyTo = {} local playerTo = {} 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 function isValidMoney(cid, money) if isNumber(money) == TRUE and money > 0 and money < 999999999 and money <= getPlayerMoney(cid) then return TRUE end return FALSE end function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end if msgcontains(msg, 'ajuda') or msgcontains(msg, 'ofertas') then selfSay("Voce pode checar seu {saldo} da sua conta, {depositar} dinheiro ou {extrair} para retirar. Voce tambem pode {transferir} dinheiro para outros players, tambem pode entrar nas {açoes}, diga {informaçoes} para saber sobre as açoes.", cid) talkState[cid] = 0 ----------------------------------------------------------------- ---------------------------- Balance ---------------------------- ----------------------------------------------------------------- elseif msgcontains(msg, 'saldo') or msgcontains(msg, 'Saldo') then selfSay('Seu saldo é '..getPlayerBalance(cid)..' gold.', cid) talkState[cid] = 0 ----------------------------------------------------------------- ---------------------------- Help ------------------------------- ----------------------------------------------------------------- elseif msgcontains(msg, 'basic functions') then selfSay('Voce pode checar seu {balance} da sua conta, {deposit} dinheiro ou {withdraw} para extrair. Voce tambem pode {transfer} dinheiro para outros players.', cid) talkState[cid] = 0 ----------------------------------------------------------------- ---------------------------- Deposit ---------------------------- ----------------------------------------------------------------- elseif msgcontains(msg, 'depositar tudo') then moneyTo[cid] = getPlayerMoney(cid) if moneyTo[cid] < 1 then selfSay('Voce nao tem dinheiro.', cid) talkState[cid] = 0 else selfSay('Voce realmente quer adicionar '..moneyTo[cid]..' gold?', cid) talkState[cid] = 2 end elseif msgcontains(msg, 'depositar') then selfSay("Porfavor me diga quanto voce quer depositar.", cid) talkState[cid] = 1 elseif talkState[cid] == 1 then moneyTo[cid] = tonumber(msg) if isValidMoney(cid, moneyTo[cid]) == TRUE then selfSay('Voce realmente quer depositar '..moneyTo[cid]..' gold?', cid) talkState[cid] = 2 else selfSay('Nao é uma quantia valida para deposito.', cid) talkState[cid] = 0 end elseif talkState[cid] == 2 then if msgcontains(msg, 'sim') then if doPlayerDepositMoney(cid, moneyTo[cid], 1) ~= TRUE then selfSay('Voce nao tem esse dinheiro.', cid) else selfSay('Tudo bem, nos adicionamos '..moneyTo[cid]..' gold para seu saldo. Voce pode extrair seu dinheiro quando quiser. Seu saldo é ' .. getPlayerBalance(cid) .. '.', cid) end elseif msgcontains(msg, 'nao') then selfSay('Como desejar. Posso fazer mais alguma coisa por voce?', cid) end talkState[cid] = 0 ----------------------------------------------------------------- ---------------------------- Withdraw --------------------------- ----------------------------------------------------------------- elseif msgcontains(msg, 'extrair') then selfSay("Porfavor, diga-me quanto voce deseja extrair.", cid) talkState[cid] = 6 elseif talkState[cid] == 6 then moneyTo[cid] = tonumber(msg) if isValidMoney(cid, moneyTo[cid]) == TRUE then selfSay('Voce esta certo que quer extrair '..moneyTo[cid]..' gold de sua conta de banco?', cid) talkState[cid] = 7 else selfSay('Nao é uma quantia valida para extraçao.', cid) talkState[cid] = 0 end elseif talkState[cid] == 7 then if msgcontains(msg, 'sim') then if doPlayerWithdrawMoney(cid, moneyTo[cid]) ~= TRUE then selfSay('Voce nao tem essa quantia em sua conta. Seu saldo é '..getPlayerBalance(cid)..'. Por favor, diga-me quanto quer extrair.', cid) else selfSay('Aqui esta, ' .. moneyTo[cid] .. ' gold. Porfavor, digame se quizer mais alguma coisa.', cid) talkState[cid] = 0 end elseif msgcontains(msg, 'nao') then selfSay('Como desejar. Posso fazer mais algo?', cid) talkState[cid] = 0 end ----------------------------------------------------------------- ---------------------------- Transfer --------------------------- ----------------------------------------------------------------- elseif msgcontains(msg, 'transferir') then selfSay("Por favor, digame quanto de dinheiro voce quer transferir.", cid) talkState[cid] = 11 elseif talkState[cid] == 11 then moneyTo[cid] = tonumber(msg) if isValidMoney(cid, moneyTo[cid]) == TRUE then selfSay('Voce gostaria de transferir '..moneyTo[cid]..' gold para?', cid) talkState[cid] = 12 else selfSay('Nao é uma quantia valida para deposito.', cid) talkState[cid] = 0 end elseif talkState[cid] == 12 then playerTo[cid] = msg if getCreatureName(cid) == playerTo[cid] then selfSay('Voce deseja transferir dinheiro para voce mesmo? Isto e impossivel!', cid) talkState[cid] = 0 return TRUE end if playerExists(playerTo[cid]) then selfSay('Voce deseja transferir ' .. moneyTo[cid] .. ' gold para "' .. playerTo[cid] .. '" ?', cid) talkState[cid] = 13 else selfSay('O player "' .. playerTo[cid] .. '" nao existe.', cid) talkState[cid] = 0 end elseif talkState[cid] == 13 then if msgcontains(msg, 'sim') then if getPlayerBalance(cid) < moneyTo[cid] then selfSay('Voce nao tem dinheiro em sua conta.', cid) return TRUE end if doPlayerTransferMoneyTo(cid, playerTo[cid], moneyTo[cid]) ~= TRUE then selfSay('Esse player nao existe ou ainda nao tem vocaçao.', cid) else selfSay('Voce transferiu ' .. moneyTo[cid] .. ' gold tpara "' .. playerTo[cid] ..' ".', cid) playerTo[cid] = nil end elseif msgcontains(msg, 'nao') then selfSay('Como deseja. Posso fazer mais alguma coisa para voce?', cid) end talkState[cid] = 0 end return TRUE end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) O script foi retirado do Alissow Server e editado para retirar um possível bug. flw A função depositar não esta funcionando. Quando você fala depositar o npc pergunta a quantia que você quer depositar e depois quando você fala a quantia e fala yes ele não retira esta quantia da sua bp e se você conferir seu saldo vera que é 0 "ZERO". Link para o comentário https://xtibia.com/forum/topic/133374-npc-banco/#findComment-881392 Compartilhar em outros sites More sharing options...
Posts Recomendados