Guten Tag,
hätte eine frage hätte ein Quest und die SQL habe ich nicht mehr kann mir jemand da weiter helfen wie ich sowas wieder erstellen kann ?
quest fblager begin
state start begin
when login begin
cmdchat("fblager qid|"..q.getcurrentquestindex())
end
function getEmptyStoragePos(vnum)
local fb_type = fblager.getBookType(vnum)
local res = mysql_query("SELECT slot_pos FROM player.fblager WHERE fb_type="..fb_type.." AND pid="..pc.get_player_id()..";")
if type(res) == "nil" then
return 0
end
local check = 0
for j = 0, 11 do
for i = 1, table.getn(res) do
if tonumber(res[i][1]) == j then
check = 1
break
end
end
if check == 0 then
return j
end
check = 0
end
return -1
end
function getBookStorePos(vnum, count)
local max_books = 201-count
return mysql_query("SELECT slot_pos FROM player.fblager WHERE fb_vnum="..tonumber(vnum).." AND count<"..max_books.." AND pid="..pc.get_player_id()..";")[1]
end
function getBookType(vnum)
if tonumber(vnum) >= 50401 and tonumber(vnum) <= 50420 then return 1
elseif tonumber(vnum) >= 50431 and tonumber(vnum) <= 50450 then return 2
elseif tonumber(vnum) >= 50461 and tonumber(vnum) <= 50481 then return 3
elseif tonumber(vnum) >= 50491 and tonumber(vnum) <= 50511 then return 4 end
end
function addBook(vnum, count, pickup)
local fb_type = fblager.getBookType(vnum)
local tab = {"Krieger", "Ninja", "Sura", "Schamanen"}
if not pickup then
if pc.getqf("fbsafeboxpage") != fb_type then
syschat("Du kannst kein "..tab[fb_type].." Buch im "..tab[pc.getqf("fbsafeboxpage")].." Lager rein tun.")
return
end
end
local pos = fblager.getBookStorePos(vnum, count)
if pos == nil then
pos = fblager.getEmptyStoragePos(vnum)
if pos == -1 then
syschat("Du hast kein Platz mehr in deinem FB Lager.")
return
end
mysql_query("INSERT INTO player.fblager (fb_vnum,count,slot_pos,fb_type,pid) VALUES ("..tonumber(vnum)..","..tonumber(count)..","..pos..","..fb_type..","..pc.get_player_id()..");")
else
pos = tonumber(pos[1])
mysql_query("UPDATE player.fblager SET count=count+"..tonumber(count).." WHERE fb_vnum="..tonumber(vnum).." AND slot_pos="..tonumber(pos).." AND pid="..pc.get_player_id()..";")
end
fblager.refreshStorage()
item.remove()
end
function refreshStorage()
cmdchat("fblager CLEARSLOTS")
local fblagerslots = mysql_query("SELECT slot_pos, fb_vnum, count FROM player.fblager WHERE fb_type="..tonumber(pc.getqf("fbsafeboxpage")).." AND pid="..pc.get_player_id().." ORDER BY slot_pos DESC ;")
table.foreachi(fblagerslots,function(nr,player)
cmdchat("fblager SETSLOTINFO|"..nr.."|"..player[1].."|"..player[2].."|"..player[3])
end)
end
when getitem with item.get_value(1) == 1337 begin
fblager.addBook(item.get_vnum(), item.get_count(), true)
end
when 20092.chat."FB-Lager" begin
pc.setqf("fbsafeboxpage", 1)
fblager.refreshStorage()
cmdchat("fblager OPENGUI")
setskin(NOWINDOW)
end
when button or info begin
cmdchat("getinputbegin")
local cmd = split(input(cmdchat("fblager SENDREQUEST|")), "|")
cmdchat("getinputend")
if cmd[1] == "storage" then
item.select_cell(cmd[2])
if item.get_value(1) != 1337 then
syschat("Du kannst nur Fertigkeitsbücher einlagern.")
return
end
fblager.addBook(item.get_vnum(),item.get_count(), false)
elseif cmd[1] == "setpage" then
pc.setqf("fbsafeboxpage",tonumber(cmd[2]))
fblager.refreshStorage()
elseif cmd[1] == "removeitem" then
local fb = mysql_query("SELECT fb_vnum, count from player.fblager WHERE slot_pos = "..tonumber(cmd[2]).." AND fb_type = "..pc.getqf("fbsafeboxpage").." AND pid="..pc.get_player_id()..";")[1]
pc.give_item2(fb[1], fb[2])
mysql_query("DELETE FROM player.fblager WHERE slot_pos = "..tonumber(cmd[2]).." and fb_type= "..pc.getqf("fbsafeboxpage").." AND pid="..pc.get_player_id()..";")
fblager.refreshStorage()
end
end
end
end