Postado Fevereiro 3, 2017 8 anos Em 01/02/2017 ás 20:39, Vodkart disse: <?xml version="1.0" encoding="ISO-8859-1"?> <mod name="Loot System" version="1.0" author="Vodkart And Mkalo" contact="none.com" enabled="yes"> <config name="Loot_func"><![CDATA[ info = { AutomaticDeposit = true, BlockMonsters = {}, BlockItemsList = {2123,2515}, Max_Slots = {free = 2, premium = 5} } function setPlayerStorageTable(cid, storage, tab) local tabstr = "&" for i,x in pairs(tab) do tabstr = tabstr .. i .. "," .. x .. ";" end setPlayerStorageValue(cid, storage, tabstr:sub(1, #tabstr-1)) end function getPlayerStorageTable(cid, storage) local tabstr = getPlayerStorageValue(cid, storage) local tab = {} if type(tabstr) ~= "string" then return {} end if tabstr:sub(1,1) ~= "&" then return {} end local tabstr = tabstr:sub(2, #tabstr) local a = string.explode(tabstr, ";") for i,x in pairs(a) do local b = string.explode(x, ",") tab[tonumber(b[1]) or b[1]] = tonumber(b[2]) or b[2] end return tab end function isInTable(cid, item) for _,i in pairs(getPlayerStorageTable(cid, 27000))do if tonumber(i) == tonumber(item) then return true end end return false end function addItemTable(cid, item) local x = {} for i = 1,#getPlayerStorageTable(cid, 27000) do table.insert(x,getPlayerStorageTable(cid, 27000)[i]) end if x ~= 0 then table.insert(x,tonumber(item)) setPlayerStorageTable(cid, 27000, x) else setPlayerStorageTable(cid, 27000, {item}) end end function removeItemTable(cid, item) local x = {} for i = 1,#getPlayerStorageTable(cid, 27000) do table.insert(x,getPlayerStorageTable(cid, 27000)[i]) end for i,v in ipairs(x) do if tonumber(v) == tonumber(item) then table.remove(x,i) end end return setPlayerStorageTable(cid, 27000, x) end function ShowItemsTabble(cid) local str,n = "-- My Loot List --\n\n",0 for i = 1,#getPlayerStorageTable(cid, 27000) do n = n + 1 str = str..""..n.." - "..getItemNameById(getPlayerStorageTable(cid, 27000)[i]).."\n" end return doShowTextDialog(cid, 2529, str) end function getContainerItems(containeruid) local items = {} local containers = {} if type(getContainerSize(containeruid)) ~= "number" then return false end for slot = 0, getContainerSize(containeruid)-1 do local item = getContainerItem(containeruid, slot) if item.itemid == 0 then break end if isContainer(item.uid) then table.insert(containers, item.uid) end table.insert(items, item) end if #containers > 0 then for i,x in ipairs(getContainerItems(containers[1])) do table.insert(items, x) end table.remove(containers, 1) end return items end function getItemsInContainerById(container, itemid) -- Function By Kydrai local items = {} if isContainer(container) and getContainerSize(container) > 0 then for slot=0, (getContainerSize(container)-1) do local item = getContainerItem(container, slot) if isContainer(item.uid) then local itemsbag = getItemsInContainerById(item.uid, itemid) for i=0, #itemsbag do table.insert(items, itemsbag[i]) end else if itemid == item.itemid then table.insert(items, item.uid) end end end end return items end function doPlayerAddItemStacking(cid, itemid, amount) -- revisado local item, _G = getItemsInContainerById(getPlayerSlotItem(cid, 3).uid, itemid), 0 if #item > 0 then for _ ,x in pairs(item) do local ret = getThing(x) if ret.type < 100 then doTransformItem(ret.uid, itemid, ret.type+amount) if ret.type+amount > 100 then doPlayerAddItem(cid, itemid, ret.type+amount-100) end break else _G = _G+1 end end if _G == #item then doPlayerAddItem(cid, itemid, amount) end else return doPlayerAddItem(cid, itemid, amount) end end function AutomaticDeposit(cid,item,n) local deposit = item == tonumber(2160) and (n*10000) or tonumber(item) == 2152 and (n*100) or (n*1) return doPlayerDepositMoney(cid, deposit) end function corpseRetireItems(cid, pos) local check = false for i = 0, 255 do pos.stackpos = i tile = getTileThingByPos(pos) if tile.uid > 0 and isCorpse(tile.uid) then check = true break end end if check == true then local items = getContainerItems(tile.uid) for i,x in pairs(items) do if isInArray(getPlayerStorageTable(cid, 27000), tonumber(x.itemid)) then if isItemStackable(x.itemid) then doPlayerAddItemStacking(cid, x.itemid, x.type) if info.AutomaticDeposit == true and isInArray({"2148","2152","2160"},tonumber(x.itemid)) then AutomaticDeposit(cid,x.itemid,x.type) end else doPlayerAddItem(cid, x.itemid) end doRemoveItem(x.uid) end end end end ]]></config> <event type="login" name="LootLogin" event="script"><![CDATA[ function onLogin(cid) registerCreatureEvent(cid, "LootEventKIll") if isPremium(cid) and getPlayerStorageValue(cid, 27001) <= 0 then setPlayerStorageValue(cid, 27001, 1) elseif getPlayerStorageValue(cid, 27001) > 0 and not isPremium(cid) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[Auto Loot] You premium is Over, Start a new list!") setPlayerStorageValue(cid, 27001, -1) setPlayerStorageValue(cid, 27000, -1) end return true end]]></event> <event type="kill" name="LootEventKIll" event="script"><![CDATA[ domodlib('Loot_func') function onKill(cid, target, lastHit) if isPlayer(cid) and isMonster(target) and not isInArray(info.BlockMonsters, getCreatureName(target):lower()) then addEvent(corpseRetireItems, 0, cid ,getThingPos(target)) end return true end]]></event> <talkaction words="!autoloot;/autoloot" event="buffer"><![CDATA[ domodlib('Loot_func') local t = string.explode(string.lower(param), ",") if not t[1] then ShowItemsTabble(cid) return true elseif tonumber(t[1]) or tonumber(t[2]) then doPlayerSendCancel(cid, "enter!autoloot add,name or !autoloot remove,name") return true elseif isInArray({"add","remove"}, tostring(t[1])) then local func,check = tostring(t[1]) == "add" and addItemTable or removeItemTable, tostring(t[1]) == "add" and true or false local item,slots = getItemIdByName(tostring(t[2]), false), isPremium(cid) and info.Max_Slots.premium or info.Max_Slots.free if not item then doPlayerSendCancel(cid, "This item does not exist.") return true elseif check == true and isInArray(info.BlockItemsList, item) then doPlayerSendCancel(cid, "You can not add this item in the list!") return true elseif check == true and #getPlayerStorageTable(cid, 27000) >= slots then doPlayerSendCancel(cid, "max "..slots.." from auto loot") return true elseif isInTable(cid, item) == check then doPlayerSendCancel(cid, "This Item "..(check == true and "already" or "is not").." in your list.") return true end func(cid, item) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,check == true and "you added the item "..t[2].." in the list" or "you removed the item "..t[2].." from the list") return true end return true]]></talkaction> </mod> Boa noite! Uma vez tentei procurar um Mod assim, mais sempre dava algum tipo de erro, peguei esse seu aí e posso dar a certeza que FUNCIONOU 100%! Os golds vão para meu npc Banker, e os loots para todas as bps.. Não sou o dono do tópico, mas me ajudou e muito! Obrigado! Aprovado! REP+!
Postado Fevereiro 3, 2017 8 anos Autor amigo @tirso, pode me passar seu npc banker completo para mim ? estou tendo problemas com o script do meu !!!
Postado Fevereiro 3, 2017 8 anos 9 horas atrás, Micheel15 disse: amigo @tirso, pode me passar seu npc banker completo para mim ? estou tendo problemas com o script do meu !!! Fala michel, eu uso sistema de autoloot, porém quando o player ativa ele fica ativo no player, com a storage do proprio sistema, seria muito melhor voce criar uma Talkactions onde o player pode tirar o dinheiro a hora que quiser.. tipow !balance = total de gold que voce tem em seu char !withdraw = total de valor que o balance mostrou a você, eu uso esse sistema porém achei mais pratico! mais se o @Vodkart,esta te ajudando ele e fera no scripts porém ele vai fazer funcionar, ou se não revisa todo o topico postado por ele, muito dificil um scripts não funcionar! Editado Fevereiro 3, 2017 8 anos por mateusmoretti (veja o histórico de edições)
Postado Fevereiro 3, 2017 8 anos 10 horas atrás, Micheel15 disse: amigo @tirso, pode me passar seu npc banker completo para mim ? estou tendo problemas com o script do meu !!! Aqui está Micheel Mais será que não fez algo de errado? Npc \/ Spoiler <?xml version="1.0" encoding="UTF-8"?> <npc name="Banker" script="data/npc/scripts/bank.lua" walkinterval="2000" floorchange="0" access="5" level="1" maglevel="1"> <health now="150" max="150"/> <look type="132" head="115" body="0" legs="114" feet="0" addons="3" corpse="2212"/> <parameters> <parameter key="message_greet" value="Welcome |PLAYERNAME|! Here, you can {deposit}, {withdraw} or {transfer} your money from your bank account. I can change your coins too."/> <parameter key="message_alreadyfocused" value="You are drunked ? I talk with you."/> <parameter key="message_farewell" value="Goodbye. I wanna see your money... oh you again."/> </parameters> </npc> Bank.Lua Spoiler 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(money) if isNumber(money) == TRUE and money > 0 and money < 999999999 then return TRUE end return FALSE end function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end if msgcontains(msg, 'help') or msgcontains(msg, 'offer') then selfSay("You can check the {balance} of your bank account, {deposit} money or {withdraw} it. You can also {transfer} money to other characters, provided that they have a vocation.", cid) talkState[cid] = 0 ----------------------------------------------------------------- ---------------------------- Balance ---------------------------- ----------------------------------------------------------------- elseif msgcontains(msg, 'balance') or msgcontains(msg, 'Balance') then selfSay('Your account balance is '..getPlayerBalance(cid)..' gold.', cid) talkState[cid] = 0 ----------------------------------------------------------------- ---------------------------- Help ------------------------------- ----------------------------------------------------------------- elseif msgcontains(msg, 'basic functions') then selfSay('You can check the {balance{ of your bank account, Pdeposit{ money or Pwithdraw{ it. You can also {transfer} money to othercharacters, provided that they have a vocation.', cid) talkState[cid] = 0 elseif msgcontains(msg, 'advanced functions') then selfSay('Renting a house has never been this easy. Simply make a bid for an auction. We will check immediately if you haveenough money.', cid) talkState[cid] = 0 ----------------------------------------------------------------- ---------------------------- Deposit ---------------------------- ----------------------------------------------------------------- elseif msgcontains(msg, 'deposit all') then moneyTo[cid] = getPlayerMoney(cid) if moneyTo[cid] < 1 then selfSay('You don\'t have any money to deposit in you inventory..', cid) talkState[cid] = 0 else selfSay('Would you really like to deposit '..moneyTo[cid]..' gold?', cid) talkState[cid] = 2 end elseif msgcontains(msg, 'deposit') then selfSay("Please tell me how much gold it is you would like to deposit.", cid) talkState[cid] = 1 elseif talkState[cid] == 1 then moneyTo[cid] = tonumber(msg) if isValidMoney(moneyTo[cid]) == TRUE then selfSay('Would you really like to deposit '..moneyTo[cid]..' gold?', cid) talkState[cid] = 2 else selfSay('Is isnt valid amount of gold to deposit.', cid) talkState[cid] = 0 end elseif talkState[cid] == 2 then if msgcontains(msg, 'yes') then if doPlayerDepositMoney(cid, moneyTo[cid], 1) ~= TRUE then selfSay('You do not have enough gold.', cid) else selfSay('Alright, we have added the amount of '..moneyTo[cid]..' gold to your balance. You can withdraw your money anytime you want to. Your account balance is ' .. getPlayerBalance(cid) .. '.', cid) end elseif msgcontains(msg, 'no') then selfSay('As you wish. Is there something else I can do for you?', cid) end talkState[cid] = 0 ----------------------------------------------------------------- ---------------------------- Withdraw --------------------------- ----------------------------------------------------------------- elseif msgcontains(msg, 'withdraw') then selfSay("Please tell me how much gold you would like to withdraw.", cid) talkState[cid] = 6 elseif talkState[cid] == 6 then moneyTo[cid] = tonumber(msg) if isValidMoney(moneyTo[cid]) == TRUE then selfSay('Are you sure you wish to withdraw '..moneyTo[cid]..' gold from your bank account?', cid) talkState[cid] = 7 else selfSay('Is isnt valid amount of gold to withdraw.', cid) talkState[cid] = 0 end elseif talkState[cid] == 7 then if msgcontains(msg, 'yes') then if doPlayerWithdrawMoney(cid, moneyTo[cid]) ~= TRUE then selfSay('There is not enough gold on your account. Your account balance is '..getPlayerBalance(cid)..'. Please tell me the amount of gold coins you would like to withdraw.', cid) else selfSay('Here you are, ' .. moneyTo[cid] .. ' gold. Please let me know if there is something else I can do for you.', cid) talkState[cid] = 0 end elseif msgcontains(msg, 'no') then selfSay('As you wish. Is there something else I can do for you?', cid) talkState[cid] = 0 end ----------------------------------------------------------------- ---------------------------- Transfer --------------------------- ----------------------------------------------------------------- elseif msgcontains(msg, 'transfer') then selfSay("Please tell me the amount of gold you would like to transfer.", cid) talkState[cid] = 11 elseif talkState[cid] == 11 then moneyTo[cid] = tonumber(msg) if isValidMoney(moneyTo[cid]) == TRUE then selfSay('Who would you like transfer '..moneyTo[cid]..' gold to?', cid) talkState[cid] = 12 else selfSay('Is isnt valid amount of gold to transfer.', cid) talkState[cid] = 0 end elseif talkState[cid] == 12 then playerTo[cid] = msg if getCreatureName(cid) == playerTo[cid] then selfSay('Ehm, You want transfer money to yourself? Its impossible!', cid) talkState[cid] = 0 return TRUE end if playerExists(playerTo[cid]) then selfSay('So you would like to transfer ' .. moneyTo[cid] .. ' gold to "' .. playerTo[cid] .. '" ?', cid) talkState[cid] = 13 else selfSay('Player with name "' .. playerTo[cid] .. '" doesnt exist.', cid) talkState[cid] = 0 end elseif talkState[cid] == 13 then if msgcontains(msg, 'yes') then if getPlayerBalance(cid) < moneyTo[cid] then selfSay('You dont have enought money on your bank account.', cid) return TRUE end if doPlayerTransferMoneyTo(cid, playerTo[cid], moneyTo[cid]) ~= TRUE then selfSay('This player does not exist on this world or have no vocation.', cid) else selfSay('You have transferred ' .. moneyTo[cid] .. ' gold to "' .. playerTo[cid] ..' ".', cid) playerTo[cid] = nil end elseif msgcontains(msg, 'no') then selfSay('As you wish. Is there something else I can do for you?', cid) end talkState[cid] = 0 end return TRUE end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
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.