Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Es gibt 2 Varianten:
- - eine für die 40k Game ("Source fix")
- - eine für alle Games
- Die Source-Variante:
- Quest:
- quest guildstorage begin
- state start begin
- function getinput(c)
- cmdchat("GetInputStart")
- local ret = input(cmdchat(c))
- cmdchat("GetInputStop")
- return ret
- end
- function item_can_store(itemvnum)
- local antiflags = guildstorage.item_get_real_antiflags(guildstorage.item_antiflag(itemvnum))
- for i = 1 , table.getn(antiflags) do
- if antiflags[i] == 128 or antiflags[i] == 131072 or antiflags[i] == 8192 or antiflags[i] == 64 then return false end
- end
- return true
- end
- function item_get_real_antiflags(antiflag_)
- antiflags = {131072,65536,32768,16384,8192,4096,2048,1024,512,256,128,64,32,16,8,4,2,1}
- tab2 = {}
- table.foreach(antiflags,function(_,v) if antiflag_ >= v then table.insert(tab2,v) antiflag_ = antiflag_ - v end end)
- return tab2
- end
- function item_antiflag(item_vnum)
- local result = mysql_query("SELECT antiflag from player.item_proto where vnum = "..item_vnum..";")
- return (result[1][1])--pack
- end
- ----------------------
- --LOGS START
- ----------------------
- function load_logs()
- local logs = {}
- local gs_logs = io.open("/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/logs.txt", "r")
- for line in gs_logs:lines() do
- table.insert(logs,guildstorage.split_(line,"#"))
- end
- return logs
- end
- function clear_logs()
- local gs_log = io.open("/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/logs.txt", "w+")
- gs_log:flush()
- gs_log:close()
- end
- function add_log(name_,type_,do_,desc_)
- local gs_log = io.open("/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/logs.txt", "a+")
- local date_ = os.date()
- date_ = string.gsub(date_," ", "+-+")
- desc_ = string.gsub(desc_," ", "+-+")
- gs_log:write(name_..'#'..date_..'#'..type_..'#'..do_..'#'..desc_..'\\n')
- gs_log:flush()
- gs_log:close()
- end
- ----------------------
- --LOGS END
- ----------------------
- ----------------------
- --MEMBER & AUTHORITY START
- ----------------------
- -- Auth 0 = einlagern
- -- Auth 1 = rausnehmen
- -- Auth 2 = einzahlen
- -- Auth 3 = auszahlen
- function get_members()
- local members = {}
- local gs_member = io.open("/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/authority.txt", "r")
- for line in gs_member:lines() do
- table.insert(members,guildstorage.split_(line,"#"))
- end
- return members
- end
- function get_authority(authID)
- if pc.is_guild_master() then return true end
- local members = guildstorage.get_members()
- for i = 1, table.getn(members) do
- if members[i][1] == pc.get_name() then
- if tonumber(members[i][authID+2]) == 0 then return false else return true end
- end
- end
- return false
- end
- function set_authority(member,authID,auth)
- local members = guildstorage.get_members()
- for i = 1, table.getn(members) do
- if members[i][1] == member then
- members[i][authID+2] = auth
- break
- end
- end
- local gs_member = io.open("/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/authority.txt", "w+")
- for i = 1, table.getn(members) do
- gs_member:write(members[i][1]..'#'..members[i][2]..'#'..members[i][3]..'#'..members[i][4]..'#'..members[i][5]..'\\n')
- end
- gs_member:flush()
- gs_member:close()
- end
- function add_member(member)
- local members = guildstorage.get_members()
- for i = 1, table.getn(members) do
- if members[i][1] == member then
- syschat'Member ist schon eingetragen.'
- return
- end
- end
- local gs_member = io.open("/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/authority.txt", "a+")
- gs_member:write(member..'#0#0#0#0\\n')
- gs_member:flush()
- gs_member:close()
- end
- function delete_member(member)
- local members = guildstorage.get_members()
- for i = 1, table.getn(members) do
- if members[i][1] == member then
- table.remove(members,i)
- break
- end
- end
- local gs_member = io.open("/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/authority.txt", "w+")
- for i = 1, table.getn(members) do
- gs_member:write(members[i][1]..'#'..members[i][2]..'#'..members[i][3]..'#'..members[i][4]..'#'..members[i][5]..'\\n')
- end
- gs_member:flush()
- gs_member:close()
- end
- ----------------------
- --MEMBER & AUTHORITY END
- ----------------------
- ----------------------
- --MONEY START
- ----------------------
- function get_money()
- local gs_money = io.open("/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/money.txt", "r")
- for line in gs_money:lines() do
- return tonumber(line)
- end
- end
- function change_money(money)
- local old_money = guildstorage.get_money()
- local gs_money = io.open("/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/money.txt", "w+")
- gs_money:write(old_money+money)
- gs_money:flush()
- gs_money:close()
- end
- ----------------------
- --MONEY END
- ----------------------
- ----------------------
- --STORAGE START
- ----------------------
- function has_guildstorage()
- local guildstorage = io.open("/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/storage.txt", "r")
- if guildstorage == nil then
- return false
- else
- return true
- end
- end
- function give_item(itemTab)
- pc.give_item2_select(itemTab[1],itemTab[2])
- local attr,socket = {},{}
- for i = 10,23 do table.insert(attr,{itemTab[i],itemTab[i+1]}) i = i+1 end
- for i = 4,6 do table.insert(socket,itemTab[i]) end
- for i = 1, table.getn(attr) do
- item.set_attr(i-1, attr[i][1], attr[i][2])
- end
- for i = 1, table.getn(socket) do if tonumber(socket[i]) > 0 then item.set_socket(i-1, socket[i]) end end
- end
- function get_slot_item(slot)
- local items = guildstorage.get_items()
- for i = 1, table.getn(items) do
- local item = guildstorage.split_(items[i],"#")
- if tonumber(item[3]) == slot then
- return item
- end
- end
- return 0
- end
- function refresh()
- cmdchat('GUILDSTORAGE REFRESH_MONEY/'..guildstorage.get_money())
- local items = guildstorage.get_items()
- if items != 0 then
- for i = 1, table.getn(items) do
- local item = guildstorage.split_(items[i],"#")
- -- chat(table.getn(item))
- cmdchat('GUILDSTORAGE_ADDITEM '..item[3]..' '..item[1]..' '..item[2]..' '..item[4]..' '..item[5]..' '..item[6]..' '..item[7]..' '..item[8]..' '..item[9]..' '..item[10]..' '..item[11]..' '..item[12]..' '..item[13]..' '..item[14]..' '..item[15]..' '..item[16]..' '..item[17]..' '..item[18]..' '..item[19]..' '..item[20]..' '..item[21]..' '..item[22]..' '..item[23])
- end
- end
- cmdchat('GUILDSTORAGE REFRESH')
- end
- function refresh_tempslots()
- cmdchat('GUILDSTORAGE REFRESH_MONEY/'..guildstorage.get_money())
- cmdchat('GUILDSTORAGE CLEAR_TEMPSLOTS')
- local items = guildstorage.get_items()
- if items != 0 then
- for i = 1, table.getn(items) do
- local item = guildstorage.split_(items[i],"#")
- cmdchat('GUILDSTORAGE_ADDTEMPSLOT '..item[3]..' '..item[1]..' '..item[2]..' '..item[4]..' '..item[5]..' '..item[6]..' '..item[7]..' '..item[8]..' '..item[9]..' '..item[10]..' '..item[11]..' '..item[12]..' '..item[13]..' '..item[14]..' '..item[15]..' '..item[16]..' '..item[17]..' '..item[18]..' '..item[19]..' '..item[20]..' '..item[21]..' '..item[22]..' '..item[23])
- end
- end
- cmdchat('GUILDSTORAGE COMPARE_TEMPSLOTS')
- end
- function slot_empty(slot)
- local itemList = guildstorage.get_items()
- for i = 1 , table.getn(itemList) do
- local item = guildstorage.split_(itemList[i],"#")
- if tonumber(item[3]) == slot then
- return false
- end
- end
- return true
- end
- function create_guildstorage()
- os.execute("mkdir ".."/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild())
- local guildstorage = io.open("/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/storage.txt", "w+")
- local guildstorage = io.open("/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/money.txt", "w+")
- guildstorage:write("0")
- guildstorage:close()
- local guildstorage = io.open("/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/authority.txt", "w+")
- local guildstorage = io.open("/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/logs.txt", "w+")
- guildstorage:close()
- end
- function insert_item(cell,slot,tab)
- item.select_cell(cell)
- local attr = {{item.attr_type(0),item.attr_value(0)}, {item.attr_type(1),item.attr_value(1)}, {item.attr_type(2),item.attr_value(2)}, {item.attr_type(3),item.attr_value(3)},{item.attr_type(4),item.attr_value(4)},{item.attr_type(5),item.attr_value(5)},{item.attr_type(6),item.attr_value(6)}}
- local socket, itemVnum, itemCount = {item.get_socket(0), item.get_socket(1), item.get_socket(2),item.get_socket(3),item.get_socket(4),item.get_socket(5)}, item.get_vnum(), item.get_count()
- if not guildstorage.item_can_store(itemVnum) then syschat'Dieses Item kann nicht gelagert werden.' return end
- guildstorage.add_log(pc.get_name(),'Item','einlagern',item_name(itemVnum)..' ('..itemCount..')')
- local guildstorage = io.open("/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/storage.txt", "a+")
- item.select(cell)
- if item.vnum == 0 then return end
- if item.rem(item.get_count()) then
- guildstorage:write(itemVnum.."#"..itemCount.."#"..(slot+120*tab).."#"..socket[1].."#"..socket[2].."#"..socket[3].."#"..socket[4].."#"..socket[5].."#"..socket[6].."#"..attr[1][1].."#"..attr[1][2].."#"..attr[2][1].."#"..attr[2][2].."#"..attr[3][1].."#"..attr[3][2].."#"..attr[4][1].."#"..attr[4][2].."#"..attr[5][1].."#"..attr[5][2].."#"..attr[6][1].."#"..attr[6][2].."#"..attr[7][1].."#"..attr[7][2].."\\n")
- guildstorage:flush()
- guildstorage:close()
- cmdchat('GUILDSTORAGE_ADDITEMSLOT '..slot..' '..tab..' '..itemVnum..' '..itemCount..' '..socket[1]..' '..socket[2]..' '..socket[3]..' '..socket[4]..' '..socket[5]..' '..socket[6]..' '..attr[1][1]..' '..attr[1][2]..' '..attr[2][1]..' '..attr[2][2]..' '..attr[3][1]..' '..attr[3][2]..' '..attr[4][1]..' '..attr[4][2]..' '..attr[5][1]..' '..attr[5][2]..' '..attr[6][1]..' '..attr[6][2]..' '..attr[7][1]..' '..attr[7][2])
- else
- syschat("Du hast das Item nicht mehr")
- end
- end
- function remove_item(slot)
- local gsPath = "/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/storage.txt"
- local items = {}
- local itemList = guildstorage.get_items()
- for i = 1 , table.getn(itemList) do
- table.insert(items,guildstorage.split_(itemList[i],"#"))
- end
- for i = 1, table.getn(items) do
- if items[i][3] == tostring(slot) then
- guildstorage.add_log(pc.get_name(),'Item','rausnehmen',item_name(items[i][1])..' ('..items[i][2]..')')
- table.remove(items,i)
- break
- end
- end
- local gs = io.open(gsPath, "w+")
- for i = 1, table.getn(items) do
- gs:write(items[i][1]..'#'..items[i][2]..'#'..items[i][3]..'#'..items[i][4]..'#'..items[i][5]..'#'..items[i][6]..'#'..items[i][7]..'#'..items[i][8]..'#'..items[i][9]..'#'..items[i][10]..'#'..items[i][11]..'#'..items[i][12]..'#'..items[i][13]..'#'..items[i][14]..'#'..items[i][15]..'#'..items[i][16]..'#'..items[i][17]..'#'..items[i][18]..'#'..items[i][19]..'#'..items[i][20]..'#'..items[i][21]..'#'..items[i][22]..'#'..items[i][23]..'\\n')
- end
- gs:flush()
- gs:close()
- end
- function get_items()
- local guildstorageTab = {}
- local guildstorage = io.open("/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/storage.txt", "r")
- for item in guildstorage:lines() do
- table.insert(guildstorageTab,item)
- end
- return guildstorageTab or 0
- end
- function move_item(from,to)
- local gsPath = "/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/storage.txt"
- local items = {}
- local itemList = guildstorage.get_items()
- for i = 1 , table.getn(itemList) do
- table.insert(items,guildstorage.split_(itemList[i],"#"))
- end
- for i = 1, table.getn(items) do
- if items[i][3] == tostring(from) then items[i][3] = tostring(to) end
- end
- local gs = io.open(gsPath, "w+")
- for i = 1, table.getn(items) do
- gs:write(items[i][1]..'#'..items[i][2]..'#'..items[i][3]..'#'..items[i][4]..'#'..items[i][5]..'#'..items[i][6]..'#'..items[i][7]..'#'..items[i][8]..'#'..items[i][9]..'#'..items[i][10]..'#'..items[i][11]..'#'..items[i][12]..'#'..items[i][13]..'#'..items[i][14]..'#'..items[i][15]..'#'..items[i][16]..'#'..items[i][17]..'#'..items[i][18]..'#'..items[i][19]..'#'..items[i][20]..'#'..items[i][21]..'#'..items[i][22]..'#'..items[i][23]..'\\n')
- end
- gs:flush()
- gs:close()
- end
- ----------------------
- --STORAGE END
- ----------------------
- function client_command(command_)
- return guildstorage.split_(command_,"#")
- end
- function split_(string_,delimiter)
- local result = { }
- local from = 1
- local delim_from, delim_to = string.find( string_, delimiter, from )
- while delim_from do
- table.insert( result, string.sub( string_, from , delim_from-1 ) )
- from = delim_to + 1
- delim_from, delim_to = string.find( string_, delimiter, from )
- end
- table.insert( result, string.sub( string_, from ) )
- return result
- end
- when login begin
- cmdchat("GUILDSTORAGE QID/"..q.getcurrentquestindex())
- end
- when 70028.use begin
- cmdchat("GetInputStop")
- end
- when 20095.chat."Gildenlager" begin
- if not pc.has_guild() then syschat'Du benoetigst eine Gilde um das Gildenlager benutzen zu koennen.' setskin(NOWINDOW) return end
- if not guildstorage.has_guildstorage() then guildstorage.create_guildstorage() end
- -- chat("PENIS")
- if pc.is_guild_master() then
- cmdchat('GUILDSTORAGE OPEN/1')
- else
- cmdchat('GUILDSTORAGE OPEN/0')
- end
- -- chat("2")--pack reload mein ich xD wo ist mein chat du judenkind frag das die quest nicht mich
- guildstorage.refresh()
- pc.setqf("GUILDSTORAGE",1)
- setskin(NOWINDOW)
- -- say("TEST")
- --ka ob das am setskin liegt, ich nutze das nie hm...
- end
- when button begin
- local cmd = guildstorage.client_command(guildstorage.getinput("GUILDSTORAGE QUESTCMD"))
- -- [ITEM]
- --chat(cmd)
- --bist in ner gilde? xD erst auf unserem server testen haben das doch auch danach da sonst müsste ich leveln xDok xD
- if cmd[1] == 'TAKE_ITEM' then
- if not guildstorage.get_authority(1) then syschat'Du besitzt keine Berechtigung hierfuer.' return end
- if pc.get_empty_inventory_count() < 3 then syschat'Du hast nicht genug Platz im Inventar, du brauchst mindestens drei freie Plaetze' return end
- local slot = tonumber(cmd[2])+120*tonumber(cmd[3])
- local item = guildstorage.get_slot_item(slot)
- if guildstorage.slot_empty(slot) then syschat'Dieses Item befindet sich an einer anderen Position, oder wurde schon rausgenommen' return end
- guildstorage.remove_item(slot)
- guildstorage.give_item(item)
- elseif cmd[1] == 'MOVE_ITEM' then
- if not guildstorage.get_authority(0) then syschat'Du besitzt keine Berechtigung hierfuer.' return end
- --possible to store the item? antiflag/flag
- if cmd[2] == 'INVENTORY' then
- if not guildstorage.slot_empty(tonumber(cmd[4])+120*tonumber(cmd[5])) then syschat'Dieser Slot ist bereits belegt.' return end
- guildstorage.insert_item(tonumber(cmd[3]),tonumber(cmd[4]),tonumber(cmd[5]))
- elseif cmd[2] == 'GUILDSTORAGE' then
- if not guildstorage.slot_empty(tonumber(cmd[5])+120*tonumber(cmd[6])) then syschat'Dieser Slot ist bereits belegt, oder das Item existiert nichtmehr.' return end
- guildstorage.move_item(tonumber(cmd[3])+120*tonumber(cmd[4]),tonumber(cmd[5])+120*tonumber(cmd[6]))
- end
- -- [MONEY]
- elseif cmd[1] == 'TAKE_MONEY' then
- if not guildstorage.get_authority(3) then syschat'Du besitzt keine Berechtigung hierfuer.' return end
- local old_money = guildstorage.get_money()
- if old_money < tonumber(cmd[2]) then syschat'Soviel Yang ist nicht im Gildenlager.' return end
- local new_money = tonumber(cmd[2])
- if new_money+pc.get_money() >= 1999999999 then syschat'Du kannst nicht mehr wie 2.000.000.000 Yang bei dir haben.' return end
- guildstorage.change_money(-new_money)
- pc.change_money(new_money)
- guildstorage.add_log(pc.get_name(),'Yang','abheben',new_money)
- cmdchat('GUILDSTORAGE REFRESH_MONEY/'..(old_money-new_money))
- elseif cmd[1] == 'GIVE_MONEY' then
- if not guildstorage.get_authority(2) then syschat'Du besitzt keine Berechtigung hierfuer.' return end
- local old_money = guildstorage.get_money()
- local new_money = tonumber(cmd[2])
- if new_money > pc.get_money() then syschat'Soviel Yang besitzt du nicht' return end
- pc.change_money(-new_money)
- guildstorage.change_money(new_money)
- guildstorage.add_log(pc.get_name(),'Yang','einzahlen',new_money)
- cmdchat('GUILDSTORAGE REFRESH_MONEY/'..(old_money+new_money))
- elseif cmd[1] == 'GETGUILDSTORAGEMONEY' then
- cmdchat('GUILDSTORAGE REFRESH_GUILDWINDOW_MONEY/'..guildstorage.get_money())
- -- [MEMBER]
- elseif cmd[1] == 'ADD_MEMBER' then
- if not pc.is_guild_master() then syschat'Cheese. ;p' return end
- local members = guildstorage.get_members()
- if table.getn(members) >= 12 then syschat'Du kannst maximal nur 12 Member eintragen.' return end
- guildstorage.add_member(cmd[2])
- cmdchat('GUILDSTORAGE MEMBER_COMPLETE')
- elseif cmd[1] == 'DELETE_MEMBER' then
- if not pc.is_guild_master() then syschat'Cheese. ;p' return end
- guildstorage.delete_member(cmd[2])
- cmdchat('GUILDSTORAGE MEMBER_COMPLETE')
- elseif cmd[1] == 'AUTHORITY' then
- if not pc.is_guild_master() then syschat'Cheese. ;p' return end
- guildstorage.set_authority(cmd[2],tonumber(cmd[3]),cmd[4])
- elseif cmd[1] == 'GETMEMBERLIST' then
- if not pc.is_guild_master() then syschat'Cheese. ;p' return end
- local members = guildstorage.get_members()
- for i = 1, table.getn(members) do
- -- id, membername, authority 1-4
- cmdchat('GUILDSTORAGE_ADDMEMBER '..(i-1)..' '..members[i][1]..' '..members[i][2]..' '..members[i][3]..' '..members[i][4]..' '..members[i][5])
- end
- cmdchat('GUILDSTORAGE REFRESH_MEMBERS')
- elseif cmd[1] == 'UPDATE' then
- guildstorage.refresh_tempslots()
- elseif cmd[1] == 'LOAD_LOGS' then
- if not pc.is_guild_master() then syschat'Cheese. ;p' return end
- local logs = guildstorage.load_logs()
- local logsLen = table.getn(logs)
- for i = 0, logsLen-1 do
- local var = (logsLen-i)
- cmdchat('GUILDSTORAGE_ADDLOG '..(var-1)..' '..logs[var][1]..' '..logs[var][2]..' '..logs[var][3]..' '..logs[var][4]..' '..logs[var][5])
- end
- elseif cmd[1] == 'DELETE_LOGS' then
- if not pc.is_guild_master() then syschat'Cheese. ;p' return end
- guildstorage.clear_logs()
- elseif cmd[1] == 'BUTTON' then
- if cmd[2] == "0" then
- setskin(NOWINDOW)
- game.open_mall()
- elseif cmd[2] == "1" then
- setskin(NOWINDOW)
- game.open_safebox()
- elseif cmd[2] == "2" then
- if not pc.has_guild() then syschat'Du benoetigst eine Gilde um das Gildenlager benutzen zu koennen.' setskin(NOWINDOW) return end
- if not guildstorage.has_guildstorage() then guildstorage.create_guildstorage() end
- if pc.is_guild_master() then
- cmdchat('GUILDSTORAGE OPEN/1')
- else
- cmdchat('GUILDSTORAGE OPEN/0')
- end
- guildstorage.refresh()
- pc.setqf("GUILDSTORAGE",1)
- setskin(NOWINDOW)
- end
- end
- cmdchat("Finish banane")--pack
- end
- end
- end
- Die remove Funktion (in die questlua_item.cpp packen):
- int item_rem(lua_State* L)
- {
- LPITEM item = CQuestManager::instance().GetCurrentItem();
- if(!item || CQuestManager::instance().GetCurrentCharacterPtr() != item->GetOwner())
- {
- lua_pushboolean(L, 0);
- return 0;
- }
- int count = (int)lua_tonumber(L, 1);
- item->SetCount(item->GetCount() - count);
- lua_pushboolean(L, 1);
- return 1;
- }
- Die Quest-Variante:
- quest guildstorage begin
- state start begin
- function getinput(c)
- cmdchat("GetInputStart")
- local ret = input(cmdchat(c))
- cmdchat("GetInputStop")
- return ret
- end
- function item_can_store(itemvnum)
- local antiflags = guildstorage.item_get_real_antiflags(guildstorage.item_antiflag(itemvnum))
- for i = 1 , table.getn(antiflags) do
- if antiflags[i] == 128 or antiflags[i] == 131072 or antiflags[i] == 8192 or antiflags[i] == 64 then return false end
- end
- return true
- end
- function item_get_real_antiflags(antiflag_)
- antiflags = {131072,65536,32768,16384,8192,4096,2048,1024,512,256,128,64,32,16,8,4,2,1}
- tab2 = {}
- table.foreach(antiflags,function(_,v) if antiflag_ >= v then table.insert(tab2,v) antiflag_ = antiflag_ - v end end)
- return tab2
- end
- function item_antiflag(item_vnum)
- local result = mysql_query("SELECT antiflag from player.item_proto where vnum = "..item_vnum..";")
- return (result[1][1])--pack
- end
- ----------------------
- --LOGS START
- ----------------------
- function load_logs()
- local logs = {}
- local gs_logs = io.open("/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/logs.txt", "r")
- for line in gs_logs:lines() do
- table.insert(logs,guildstorage.split_(line,"#"))
- end
- return logs
- end
- function clear_logs()
- local gs_log = io.open("/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/logs.txt", "w+")
- gs_log:flush()
- gs_log:close()
- end
- function add_log(name_,type_,do_,desc_)
- local gs_log = io.open("/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/logs.txt", "a+")
- local date_ = os.date()
- date_ = string.gsub(date_," ", "+-+")
- desc_ = string.gsub(desc_," ", "+-+")
- gs_log:write(name_..'#'..date_..'#'..type_..'#'..do_..'#'..desc_..'\\n')
- gs_log:flush()
- gs_log:close()
- end
- ----------------------
- --LOGS END
- ----------------------
- ----------------------
- --MEMBER & AUTHORITY START
- ----------------------
- -- Auth 0 = einlagern
- -- Auth 1 = rausnehmen
- -- Auth 2 = einzahlen
- -- Auth 3 = auszahlen
- function get_members()
- local members = {}
- local gs_member = io.open("/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/authority.txt", "r")
- for line in gs_member:lines() do
- table.insert(members,guildstorage.split_(line,"#"))
- end
- return members
- end
- function get_authority(authID)
- if pc.is_guild_master() then return true end
- local members = guildstorage.get_members()
- for i = 1, table.getn(members) do
- if members[i][1] == pc.get_name() then
- if tonumber(members[i][authID+2]) == 0 then return false else return true end
- end
- end
- return false
- end
- function set_authority(member,authID,auth)
- local members = guildstorage.get_members()
- for i = 1, table.getn(members) do
- if members[i][1] == member then
- members[i][authID+2] = auth
- break
- end
- end
- local gs_member = io.open("/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/authority.txt", "w+")
- for i = 1, table.getn(members) do
- gs_member:write(members[i][1]..'#'..members[i][2]..'#'..members[i][3]..'#'..members[i][4]..'#'..members[i][5]..'\\n')
- end
- gs_member:flush()
- gs_member:close()
- end
- function add_member(member)
- local members = guildstorage.get_members()
- for i = 1, table.getn(members) do
- if members[i][1] == member then
- syschat'Member ist schon eingetragen.'
- return
- end
- end
- local gs_member = io.open("/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/authority.txt", "a+")
- gs_member:write(member..'#0#0#0#0\\n')
- gs_member:flush()
- gs_member:close()
- end
- function delete_member(member)
- local members = guildstorage.get_members()
- for i = 1, table.getn(members) do
- if members[i][1] == member then
- table.remove(members,i)
- break
- end
- end
- local gs_member = io.open("/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/authority.txt", "w+")
- for i = 1, table.getn(members) do
- gs_member:write(members[i][1]..'#'..members[i][2]..'#'..members[i][3]..'#'..members[i][4]..'#'..members[i][5]..'\\n')
- end
- gs_member:flush()
- gs_member:close()
- end
- ----------------------
- --MEMBER & AUTHORITY END
- ----------------------
- ----------------------
- --MONEY START
- ----------------------
- function get_money()
- local gs_money = io.open("/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/money.txt", "r")
- for line in gs_money:lines() do
- return tonumber(line)
- end
- end
- function change_money(money)
- local old_money = guildstorage.get_money()
- local gs_money = io.open("/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/money.txt", "w+")
- gs_money:write(old_money+money)
- gs_money:flush()
- gs_money:close()
- end
- ----------------------
- --MONEY END
- ----------------------
- ----------------------
- --STORAGE START
- ----------------------
- function has_guildstorage()
- local guildstorage = io.open("/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/storage.txt", "r")
- if guildstorage == nil then
- return false
- else
- return true
- end
- end
- function give_item(itemTab)
- pc.give_item2_select(itemTab[1],itemTab[2])
- local attr,socket = {},{}
- for i = 10,23 do table.insert(attr,{itemTab[i],itemTab[i+1]}) i = i+1 end
- for i = 4,6 do table.insert(socket,itemTab[i]) end
- for i = 1, table.getn(attr) do
- item.set_attr(i-1, attr[i][1], attr[i][2])
- end
- for i = 1, table.getn(socket) do if tonumber(socket[i]) > 0 then item.set_socket(i-1, socket[i]) end end
- end
- function get_slot_item(slot)
- local items = guildstorage.get_items()
- for i = 1, table.getn(items) do
- local item = guildstorage.split_(items[i],"#")
- if tonumber(item[3]) == slot then
- return item
- end
- end
- return 0
- end
- function refresh()
- cmdchat('GUILDSTORAGE REFRESH_MONEY/'..guildstorage.get_money())
- local items = guildstorage.get_items()
- if items != 0 then
- for i = 1, table.getn(items) do
- local item = guildstorage.split_(items[i],"#")
- -- chat(table.getn(item))
- cmdchat('GUILDSTORAGE_ADDITEM '..item[3]..' '..item[1]..' '..item[2]..' '..item[4]..' '..item[5]..' '..item[6]..' '..item[7]..' '..item[8]..' '..item[9]..' '..item[10]..' '..item[11]..' '..item[12]..' '..item[13]..' '..item[14]..' '..item[15]..' '..item[16]..' '..item[17]..' '..item[18]..' '..item[19]..' '..item[20]..' '..item[21]..' '..item[22]..' '..item[23])
- end
- end
- cmdchat('GUILDSTORAGE REFRESH')
- end
- function refresh_tempslots()
- cmdchat('GUILDSTORAGE REFRESH_MONEY/'..guildstorage.get_money())
- cmdchat('GUILDSTORAGE CLEAR_TEMPSLOTS')
- local items = guildstorage.get_items()
- if items != 0 then
- for i = 1, table.getn(items) do
- local item = guildstorage.split_(items[i],"#")
- cmdchat('GUILDSTORAGE_ADDTEMPSLOT '..item[3]..' '..item[1]..' '..item[2]..' '..item[4]..' '..item[5]..' '..item[6]..' '..item[7]..' '..item[8]..' '..item[9]..' '..item[10]..' '..item[11]..' '..item[12]..' '..item[13]..' '..item[14]..' '..item[15]..' '..item[16]..' '..item[17]..' '..item[18]..' '..item[19]..' '..item[20]..' '..item[21]..' '..item[22]..' '..item[23])
- end
- end
- cmdchat('GUILDSTORAGE COMPARE_TEMPSLOTS')
- end
- function slot_empty(slot)
- local itemList = guildstorage.get_items()
- for i = 1 , table.getn(itemList) do
- local item = guildstorage.split_(itemList[i],"#")
- if tonumber(item[3]) == slot then
- return false
- end
- end
- return true
- end
- function create_guildstorage()
- os.execute("mkdir ".."/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild())
- local guildstorage = io.open("/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/storage.txt", "w+")
- local guildstorage = io.open("/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/money.txt", "w+")
- guildstorage:write("0")
- guildstorage:close()
- local guildstorage = io.open("/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/authority.txt", "w+")
- local guildstorage = io.open("/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/logs.txt", "w+")
- guildstorage:close()
- end
- function insert_item(cell,slot,tab)
- item.select_cell(cell)
- local attr = {{item.attr_type(0),item.attr_value(0)}, {item.attr_type(1),item.attr_value(1)}, {item.attr_type(2),item.attr_value(2)}, {item.attr_type(3),item.attr_value(3)},{item.attr_type(4),item.attr_value(4)},{item.attr_type(5),item.attr_value(5)},{item.attr_type(6),item.attr_value(6)}}
- local socket, itemVnum, itemCount = {item.get_socket(0), item.get_socket(1), item.get_socket(2),item.get_socket(3),item.get_socket(4),item.get_socket(5)}, item.get_vnum(), item.get_count()
- if not guildstorage.item_can_store(itemVnum) then syschat'Dieses Item kann nicht gelagert werden.' return end
- guildstorage.add_log(pc.get_name(),'Item','einlagern',item_name(itemVnum)..' ('..itemCount..')')
- local guildstorage = io.open("/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/storage.txt", "a+")
- if not pc.can_warp() then return end
- item.select(cell)
- if item.vnum == 0 then return end
- --if item.rem(item.get_count()) then
- item.remove()
- guildstorage:write(itemVnum.."#"..itemCount.."#"..(slot+120*tab).."#"..socket[1].."#"..socket[2].."#"..socket[3].."#"..socket[4].."#"..socket[5].."#"..socket[6].."#"..attr[1][1].."#"..attr[1][2].."#"..attr[2][1].."#"..attr[2][2].."#"..attr[3][1].."#"..attr[3][2].."#"..attr[4][1].."#"..attr[4][2].."#"..attr[5][1].."#"..attr[5][2].."#"..attr[6][1].."#"..attr[6][2].."#"..attr[7][1].."#"..attr[7][2].."\\n")
- guildstorage:flush()
- guildstorage:close()
- cmdchat('GUILDSTORAGE_ADDITEMSLOT '..slot..' '..tab..' '..itemVnum..' '..itemCount..' '..socket[1]..' '..socket[2]..' '..socket[3]..' '..socket[4]..' '..socket[5]..' '..socket[6]..' '..attr[1][1]..' '..attr[1][2]..' '..attr[2][1]..' '..attr[2][2]..' '..attr[3][1]..' '..attr[3][2]..' '..attr[4][1]..' '..attr[4][2]..' '..attr[5][1]..' '..attr[5][2]..' '..attr[6][1]..' '..attr[6][2]..' '..attr[7][1]..' '..attr[7][2])
- --else
- --syschat("Du hast das Item nicht mehr")
- --end
- end
- function remove_item(slot)
- local gsPath = "/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/storage.txt"
- local items = {}
- local itemList = guildstorage.get_items()
- for i = 1 , table.getn(itemList) do
- table.insert(items,guildstorage.split_(itemList[i],"#"))
- end
- for i = 1, table.getn(items) do
- if items[i][3] == tostring(slot) then
- guildstorage.add_log(pc.get_name(),'Item','rausnehmen',item_name(items[i][1])..' ('..items[i][2]..')')
- table.remove(items,i)
- break
- end
- end
- local gs = io.open(gsPath, "w+")
- for i = 1, table.getn(items) do
- gs:write(items[i][1]..'#'..items[i][2]..'#'..items[i][3]..'#'..items[i][4]..'#'..items[i][5]..'#'..items[i][6]..'#'..items[i][7]..'#'..items[i][8]..'#'..items[i][9]..'#'..items[i][10]..'#'..items[i][11]..'#'..items[i][12]..'#'..items[i][13]..'#'..items[i][14]..'#'..items[i][15]..'#'..items[i][16]..'#'..items[i][17]..'#'..items[i][18]..'#'..items[i][19]..'#'..items[i][20]..'#'..items[i][21]..'#'..items[i][22]..'#'..items[i][23]..'\\n')
- end
- gs:flush()
- gs:close()
- end
- function get_items()
- local guildstorageTab = {}
- local guildstorage = io.open("/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/storage.txt", "r")
- for item in guildstorage:lines() do
- table.insert(guildstorageTab,item)
- end
- return guildstorageTab or 0
- end
- function move_item(from,to)
- local gsPath = "/usr/home/game/share/locale/singapore/quest/Guildstorage/".."Guildstorage/"..pc.get_guild().."/storage.txt"
- local items = {}
- local itemList = guildstorage.get_items()
- for i = 1 , table.getn(itemList) do
- table.insert(items,guildstorage.split_(itemList[i],"#"))
- end
- for i = 1, table.getn(items) do
- if items[i][3] == tostring(from) then items[i][3] = tostring(to) end
- end
- local gs = io.open(gsPath, "w+")
- for i = 1, table.getn(items) do
- gs:write(items[i][1]..'#'..items[i][2]..'#'..items[i][3]..'#'..items[i][4]..'#'..items[i][5]..'#'..items[i][6]..'#'..items[i][7]..'#'..items[i][8]..'#'..items[i][9]..'#'..items[i][10]..'#'..items[i][11]..'#'..items[i][12]..'#'..items[i][13]..'#'..items[i][14]..'#'..items[i][15]..'#'..items[i][16]..'#'..items[i][17]..'#'..items[i][18]..'#'..items[i][19]..'#'..items[i][20]..'#'..items[i][21]..'#'..items[i][22]..'#'..items[i][23]..'\\n')
- end
- gs:flush()
- gs:close()
- end
- ----------------------
- --STORAGE END
- ----------------------
- function client_command(command_)
- return guildstorage.split_(command_,"#")
- end
- function split_(string_,delimiter)
- local result = { }
- local from = 1
- local delim_from, delim_to = string.find( string_, delimiter, from )
- while delim_from do
- table.insert( result, string.sub( string_, from , delim_from-1 ) )
- from = delim_to + 1
- delim_from, delim_to = string.find( string_, delimiter, from )
- end
- table.insert( result, string.sub( string_, from ) )
- return result
- end
- when login begin
- cmdchat("GUILDSTORAGE QID/"..q.getcurrentquestindex())
- end
- when 70028.use begin
- cmdchat("GetInputStop")
- end
- when 20095.chat."Gildenlager" begin
- if not pc.has_guild() then syschat'Du benoetigst eine Gilde um das Gildenlager benutzen zu koennen.' setskin(NOWINDOW) return end
- if not guildstorage.has_guildstorage() then guildstorage.create_guildstorage() end
- -- chat("PENIS")
- if pc.is_guild_master() then
- cmdchat('GUILDSTORAGE OPEN/1')
- else
- cmdchat('GUILDSTORAGE OPEN/0')
- end
- -- chat("2")--pack reload mein ich xD wo ist mein chat du judenkind frag das die quest nicht mich
- guildstorage.refresh()
- pc.setqf("GUILDSTORAGE",1)
- setskin(NOWINDOW)
- -- say("TEST")
- --ka ob das am setskin liegt, ich nutze das nie hm...
- end
- when button begin
- local cmd = guildstorage.client_command(guildstorage.getinput("GUILDSTORAGE QUESTCMD"))
- -- [ITEM]
- --chat(cmd)
- --bist in ner gilde? xD erst auf unserem server testen haben das doch auch danach da sonst müsste ich leveln xDok xD
- if cmd[1] == 'TAKE_ITEM' then
- if not guildstorage.get_authority(1) then syschat'Du besitzt keine Berechtigung hierfuer.' return end
- if pc.get_empty_inventory_count() < 3 then syschat'Du hast nicht genug Platz im Inventar, du brauchst mindestens drei freie Plaetze' return end
- local slot = tonumber(cmd[2])+120*tonumber(cmd[3])
- local item = guildstorage.get_slot_item(slot)
- if guildstorage.slot_empty(slot) then syschat'Dieses Item befindet sich an einer anderen Position, oder wurde schon rausgenommen' return end
- guildstorage.remove_item(slot)
- guildstorage.give_item(item)
- elseif cmd[1] == 'MOVE_ITEM' then
- if not guildstorage.get_authority(0) then syschat'Du besitzt keine Berechtigung hierfuer.' return end
- --possible to store the item? antiflag/flag
- if cmd[2] == 'INVENTORY' then
- if not guildstorage.slot_empty(tonumber(cmd[4])+120*tonumber(cmd[5])) then syschat'Dieser Slot ist bereits belegt.' return end
- guildstorage.insert_item(tonumber(cmd[3]),tonumber(cmd[4]),tonumber(cmd[5]))
- elseif cmd[2] == 'GUILDSTORAGE' then
- if not guildstorage.slot_empty(tonumber(cmd[5])+120*tonumber(cmd[6])) then syschat'Dieser Slot ist bereits belegt, oder das Item existiert nichtmehr.' return end
- guildstorage.move_item(tonumber(cmd[3])+120*tonumber(cmd[4]),tonumber(cmd[5])+120*tonumber(cmd[6]))
- end
- -- [MONEY]
- elseif cmd[1] == 'TAKE_MONEY' then
- if not guildstorage.get_authority(3) then syschat'Du besitzt keine Berechtigung hierfuer.' return end
- local old_money = guildstorage.get_money()
- if old_money < tonumber(cmd[2]) then syschat'Soviel Yang ist nicht im Gildenlager.' return end
- local new_money = tonumber(cmd[2])
- if new_money+pc.get_money() >= 1999999999 then syschat'Du kannst nicht mehr wie 2.000.000.000 Yang bei dir haben.' return end
- guildstorage.change_money(-new_money)
- pc.change_money(new_money)
- guildstorage.add_log(pc.get_name(),'Yang','abheben',new_money)
- cmdchat('GUILDSTORAGE REFRESH_MONEY/'..(old_money-new_money))
- elseif cmd[1] == 'GIVE_MONEY' then
- if not guildstorage.get_authority(2) then syschat'Du besitzt keine Berechtigung hierfuer.' return end
- local old_money = guildstorage.get_money()
- local new_money = tonumber(cmd[2])
- if new_money > pc.get_money() then syschat'Soviel Yang besitzt du nicht' return end
- pc.change_money(-new_money)
- guildstorage.change_money(new_money)
- guildstorage.add_log(pc.get_name(),'Yang','einzahlen',new_money)
- cmdchat('GUILDSTORAGE REFRESH_MONEY/'..(old_money+new_money))
- elseif cmd[1] == 'GETGUILDSTORAGEMONEY' then
- cmdchat('GUILDSTORAGE REFRESH_GUILDWINDOW_MONEY/'..guildstorage.get_money())
- -- [MEMBER]
- elseif cmd[1] == 'ADD_MEMBER' then
- if not pc.is_guild_master() then syschat'Cheese. ;p' return end
- local members = guildstorage.get_members()
- if table.getn(members) >= 12 then syschat'Du kannst maximal nur 12 Member eintragen.' return end
- guildstorage.add_member(cmd[2])
- cmdchat('GUILDSTORAGE MEMBER_COMPLETE')
- elseif cmd[1] == 'DELETE_MEMBER' then
- if not pc.is_guild_master() then syschat'Cheese. ;p' return end
- guildstorage.delete_member(cmd[2])
- cmdchat('GUILDSTORAGE MEMBER_COMPLETE')
- elseif cmd[1] == 'AUTHORITY' then
- if not pc.is_guild_master() then syschat'Cheese. ;p' return end
- guildstorage.set_authority(cmd[2],tonumber(cmd[3]),cmd[4])
- elseif cmd[1] == 'GETMEMBERLIST' then
- if not pc.is_guild_master() then syschat'Cheese. ;p' return end
- local members = guildstorage.get_members()
- for i = 1, table.getn(members) do
- -- id, membername, authority 1-4
- cmdchat('GUILDSTORAGE_ADDMEMBER '..(i-1)..' '..members[i][1]..' '..members[i][2]..' '..members[i][3]..' '..members[i][4]..' '..members[i][5])
- end
- cmdchat('GUILDSTORAGE REFRESH_MEMBERS')
- elseif cmd[1] == 'UPDATE' then
- guildstorage.refresh_tempslots()
- elseif cmd[1] == 'LOAD_LOGS' then
- if not pc.is_guild_master() then syschat'Cheese. ;p' return end
- local logs = guildstorage.load_logs()
- local logsLen = table.getn(logs)
- for i = 0, logsLen-1 do
- local var = (logsLen-i)
- cmdchat('GUILDSTORAGE_ADDLOG '..(var-1)..' '..logs[var][1]..' '..logs[var][2]..' '..logs[var][3]..' '..logs[var][4]..' '..logs[var][5])
- end
- elseif cmd[1] == 'DELETE_LOGS' then
- if not pc.is_guild_master() then syschat'Cheese. ;p' return end
- guildstorage.clear_logs()
- elseif cmd[1] == 'BUTTON' then
- if cmd[2] == "0" then
- setskin(NOWINDOW)
- game.open_mall()
- elseif cmd[2] == "1" then
- setskin(NOWINDOW)
- game.open_safebox()
- elseif cmd[2] == "2" then
- if not pc.has_guild() then syschat'Du benoetigst eine Gilde um das Gildenlager benutzen zu koennen.' setskin(NOWINDOW) return end
- if not guildstorage.has_guildstorage() then guildstorage.create_guildstorage() end
- if pc.is_guild_master() then
- cmdchat('GUILDSTORAGE OPEN/1')
- else
- cmdchat('GUILDSTORAGE OPEN/0')
- end
- guildstorage.refresh()
- pc.setqf("GUILDSTORAGE",1)
- setskin(NOWINDOW)
- end
- end
- cmdchat("Finish banane")--pack
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement