Postado Fevereiro 25, 2012 13 anos Esse npc é utizado pela guild , um npc de banco para todos membros. 1- Você deve ir na sua database é adicionar esse comando alter table guilds add balance int(11) not null default 0; 2- Agora crie um arquivo na pasta npc e coloque isso dentro. <!--?xml version="1.0" encoding="UTF-8"?--> <npc name="Jhon" script="guildbank.lua" walkinterval="0" floorchange="0"> <health now="150" max="150"> <look type="129" head="114" body="119" legs="114" feet="114" corpse="2212"> <parameters> <parameter key="message_greet" value="Hello |PLAYERNAME|. If you wan't to see your guild's balance, say {balance}."> </parameter></parameters> </look></health></npc> Em seguida abra pasta scripts que está dentro da pasta npcs , crie um arquivo chamado guildbank e cole isto. function getGuildBalance(id) local query = db.getResult("select balance from guilds where id = " .. id .. ";") if query:getID() ~= -1 then return query:getDataInt("balance") end return LUA_ERROR end 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 money = 0 function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_PRIVATE and 0 or cid if msgcontains(msg, "balance") then if getPlayerGuildId(cid) < 1 then selfSay("You don't have any guild.", cid) else selfSay("The balance for the guild " .. getPlayerGuildName(cid) .. " is " .. getGuildBalance(getPlayerGuildId(cid)) .. " gold coins.", cid) talkState[talkUser] = 0 end elseif msgcontains(msg, "deposit") then if getPlayerGuildId(cid) < 1 then selfSay("You don't have any guild.", cid) else selfSay("How much money do you want deposit to your guild balance?", cid) talkState[talkUser] = 1 end elseif talkState[talkUser] == 1 then if not tonumber(msg) or tonumber(msg) < 1 then selfSay("Please tell me how much do you want to deposit to your guild's balance?", cid) end money = math.abs(tonumber(msg)) selfSay("Are you sure that do you want to deposit " .. money .. " gold coins to your guild's balance?", cid) talkState[talkUser] = 2 elseif msgcontains(msg, "yes") and talkState[talkUser] == 2 then if getPlayerGuildId(cid) < 1 then selfSay("You don't have any guild.", cid) else if getPlayerMoney(cid) >= money then local query = db.executeQuery("update guilds set balance = balance + " .. money .. " where id = " .. getPlayerGuildId(cid) .. ";") if query ~= LUA_ERROR then selfSay("You have deposited " .. money .. " gold coins to your guild's balance.", cid) doPlayerRemoveMoney(cid, money) talkState[talkUser] = 0 else selfSay("Money can not be deposited, please contact a gamemaster.", cid) error("[Error::Query] " .. query .. ", error while trying to add a value into balance.") talkState[talkUser] = 0 end else selfSay("Sorry, you don't have the money.", cid) talkState[talkUser] = 0 end end elseif msgcontains(msg, "withdraw") then if getPlayerGuildId(cid) < 1 then selfSay("You don't have any guild.", cid) else selfSay("How much money do you want to withdraw from your guild's balance?", cid) talkState[talkUser] = 3 end elseif talkState[talkUser] == 3 then if not tonumber(msg) or tonumber(msg) < 1 then selfSay("Please tell me how much do you want to withdraw from your guild's balance?", cid) end money = math.abs(tonumber(msg)) selfSay("Are you sure that do you want to withdraw " .. money .. " gold coins from your guild's balance?", cid) talkState[talkUser] = 4 elseif msgcontains(msg, "yes") and talkState[talkUser] == 4 then if getPlayerGuildId(cid) < 1 then selfSay("You don't have any guild.", cid) else if getGuildBalance(getPlayerGuildId(cid)) >= money then local query = db.executeQuery("update guilds set balance = (balance - " .. money.. ") where id = " .. getPlayerGuildId(cid) .. ";") if query then selfSay("You withdraw " .. money .. " gold coins from your guild's balance.", cid) doPlayerAddMoney(cid, money) talkState[talkUser] = 0 else selfSay("Money can not be retired, please contact a gamemaster.", cid) error("[Error::Query] " .. query .. ", error while trying to remove a value from balance.") talkState[talkUser] = 0 end else selfSay("Sorry, your guild don't have the money in the balance.", cid) talkState[talkUser] = 0 end end end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Pronto , bom divertimento. Créditos: darkhaos http://baiakuza.com/IP: baiakuza.com TIBIA: 10.96 Baiak Custom [ High Exp Rate ]
Postado Outubro 13, 2016 8 anos Desculpe reviver o Topico, más tem como colocar somente para o Lider da Guild poder Sacar o dinheiro deste Npc?
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.