Premium .Avenue™ 782 Posted March 15, 2015 Premium Share Posted March 15, 2015 M2 Download Center This is the hidden content, please Sign In or Sign Up ( Internal ) quest_functions: string_in_table item.is_worn item.get_worn_vnum item.get_worn_wearflag item.get_worn_flag item.get_wearflag item.get_flag questlib.lua slottypes = {["armor"] = 90, ["helmet"] = 91, ["shoes"] = 92, ["bracelet"] = 93, ["weapon"] = 94, ["necklace"] = 95, ["earrings"] = 96, ["slot1"] = 97, ["slot2"] = 98, ["shield"] = 100, ["costume_armor"] = 109, ["costume_hair"] = 110, ["costume_weapon"] = 111} function string_in_table(s,t) -- syntax: string_in_table(string, table) return ((t[s] == nil) == false) end function item.is_worn(itype) -- syntax: item.is_worn(itemtype) // e.g.: item.is_worn("helmet") if not string_in_table(itype, slottypes) then return end local itemcell = tonumber(slottypes[itype]) item.select_cell(itemcell) if item.get_cell() == itemcell and item.get_vnum() >= 0 then return true else return false end end function item.get_worn_vnum(itype) -- syntax: item.get_worn_vnum(itemtype) // e.g.: item.get_worn_vnum("helmet") if not string_in_table(itype, slottypes) then return end local itemcell = tonumber(slottypes[itype]) if not item.is_worn(itemcell) then return end item.select_cell(itemcell) return item.get_vnum() end function item.get_worn_wearflag(itype) -- syntax: item.get_worn_wearflag(itemtype) // e.g.: item.get_worn_wearflag("helmet") if not string_in_table(itype, slottypes) then return end local itemcell = tonumber(slottypes[itype]) if not item.is_worn(itemcell) then return end item.select_cell(itemcell) return item.get_wearflag() end function item.get_worn_flag(itype) -- syntax: item.get_worn_flag(itemtype) // e.g.: item.get_worn_flag("helmet") if not string_in_table(itype, slottypes) then return end local itemcell = tonumber(slottypes[itype]) if not item.is_worn(itemcell) then return end item.select_cell(itemcell) return item.get_flag() end function item.get_wearflag() -- syntax: item.get_wearflag() return tonumber(mysql_query("SELECT wearflag FROM player.item_proto WHERE vnum='"..item.get_vnum().."';")[1]) end function item.get_flag() -- syntax: item.get_flag() return tonumber(mysql_query("SELECT flag FROM player.item_proto WHERE vnum='"..item.get_vnum().."';")[1]) end 9 1 1 9 Link to comment Share on other sites More sharing options...
valessio 13 Posted March 15, 2015 Share Posted March 15, 2015 i m sorry i have not high knowledge can you please explain all these new functions, what are the functions in game? thanks you. Link to comment Share on other sites More sharing options...
Premium .Avenue™ 782 Posted March 15, 2015 Author Premium Share Posted March 15, 2015 (edited) i m sorry i have not high knowledge can you please explain all these new functions, what are the functions in game? thanks you. Edited August 19, 2022 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
Dean 84 Posted July 22, 2018 Share Posted July 22, 2018 One thing to mention for everyone facing issues whilst using this function, check below: if not item.is_worn(itemcell) then return end Change into if not item.is_worn(itype) then return end As you're using the previous function which takes a string not a number, itemcell returns the itype's number. Other than that thank you very much for posting these functions Avenue. for brain_cells in xrange(brain): if brain_cells == 0: print("0x3703c7 Fatal error occurred. Please replace the brain.") break if brain_cells == "damaged": print("0x3703c7 Error occurred. Please repair damaged brain_cells") break print("brain_cells are at 100% capacity.") Link to comment Share on other sites More sharing options...
Premium Syreldar 1875 Posted July 24, 2018 Premium Share Posted July 24, 2018 Rewritten, slottypes = { ["armor"] = 90, ["helmet"] = 91, ["shoes"] = 92, ["bracelet"] = 93, ["weapon"] = 94, ["necklace"] = 95, ["earrings"] = 96, ["slot1"] = 97, ["slot2"] = 98, ["shield"] = 100, ["costume_armor"] = 109, ["costume_hair"] = 110, ["costume_weapon"] = 111 }; function string_in_table(s, t) return t[s] ~= nil; end -- function function item.is_worn(itype) if (not string_in_table(itype, slottypes)) then return false; end -- if local itemcell = slottypes[itype]; item.select_cell(itemcell); return item.get_cell() == itemcell; end -- function function item.select_cell_check(itype) if (not string_in_table(itype, slottypes) or not item.is_worn(itype)) then return; end -- if local itemcell = slottypes[itype]; item.select_cell(itemcell); end -- function function item.get_worn_vnum(itype) item.select_cell_check(itype); return item.get_vnum(); end -- function function item.get_worn_wearflag(itype) item.select_cell_check(itype); return item.get_wearflag(); end -- function function item.get_worn_flag(itype) item.select_cell_check(itype); return item.get_flag(); end -- function function item.get_wearflag() return mysql_query(string.format("SELECT wearflag FROM player.item_proto WHERE vnum = %d;", item.get_vnum()))[1]; end -- function function item.get_flag() return mysql_query(string.format("SELECT flag FROM player.item_proto WHERE vnum = %d;", item.get_vnum()))[1]; end -- function 3 "Nothing's free in this life. Ignorant people have an obligation to make up for their ignorance by paying those who help them. Either you got the brains or cash, if you lack both you're useless." Syreldar Link to comment Share on other sites More sharing options...
Recommended Posts