evtl. müssen die Lagerplätze noch angegeben werden.
Code:
quest SSt7uN3Qlb5Z begin
state start begin
when 35002.use begin
game.open_safebox()
end
function mobs_and_item(race, what)
tab = {
[1093] = {19, 1}, -- [Monster] = {Item, Anzahl}
[101] = {19, 1},
}
if what==1 then
return tab[race]
else
if tab[race]!=nil then return true end
end
end
when kill with SSt7uN3Qlb5Z.mobs_and_item(npc.get_race(), 0) begin
local MAX_LAGER_COUNT = 135
notice_all(pc.get_name().." hat den Boss "..mob_name(npc.get_race()).." getötet.")
local tab = SSt7uN3Qlb5Z.mobs_and_item(npc.get_race(), 1)
if pc.enough_inventory(tab[1]) then
--mysql
local id = (tonumber(mysql_query("SELECT * FROM player.item order by id DESC LIMIT 1;").id[1])+1)
local pos = mysql_query("SELECT * FROM player.item WHERE window='SAFEBOX' and owner_id='"..(pc.get_account_id()).."' ORDER BY pos ASC")
for i=1, table.getn(pos.pos), 1 do
if (tonumber(pos.pos[i])-1)!=i then
pos = i
break
end
end
if pos > MAX_LAGER_COUNT then
game.drop_item_with_ownership(tab[1], tab[2])
else
say_reward("Du hast zu wenig Platz gehabt, dein Item")
say_reward("wurde in dein Lager gelegt!")
mysql_query("INSERT INTO player.item (id, owner_id,window,pos,count,vnum,socket0,socket1,socket2,socket3,socket4,socket5,attrtype0,attrvalue0,attrtype1,attrvalue1,attrtype2,attrvalue2,attrtype3,attrvalue3,attrtype4,attrvalue4,attrtype5,attrvalue5,attrtype6,attrvalue6) VALUES ("..(id)..", "..(pc.get_account_id())..","..string.format("%q","SAFEBOX")..","..(pos)..","..(1)..","..tab[1]..","..tab[2]..","..(0)..","..(0)..","..(0)..","..(0)..","..(0)..","..(0)..","..(0)..","..(0)..","..(0)..","..(0)..","..(0)..","..(0)..","..(0)..","..(0)..","..(0)..","..(0)..","..(0)..","..(0)..","..(0)..")")
end
else
pc.give_item2(tab[1], tab[2])
end
end
end
end