function I4810240_GiftBag(MapID, InstanceID, TypeID, TargetID) --玩家ID, 生成物品TypeID,数量,品质,生成模式,log用网络消息枚举 local r = math.random(16000) local temp = 0 local index = 1 local tbl = {} tbl[1] = {4820273,1,0,1000} tbl[2] = {4820273,5,0,1000} tbl[3] = {4810061,1,0,1000} tbl[4] = {3500201,1,0,1000} tbl[5] = {3500203,1,0,1000} tbl[6] = {4810059,1,0,1000} tbl[7] = {4810059,5,0,1000} tbl[8] = {3560002,1,0,1000} tbl[9] = {3541001,1,0,1000} tbl[10] = {3500050,1,0,1000} tbl[11] = {3500051,1,0,1000} tbl[12] = {3500053,1,0,1000} tbl[13] = {3500054,1,0,1000} tbl[14] = {3500055,1,0,1000} tbl[15] = {4810061,1,0,1000} tbl[16] = {3500056,1,0,1000} for i = 1,#tbl do temp = temp + tbl[i][4] if temp >= r then index = i break end end role.AddRoleItem(MapID, InstanceID, TargetID, tbl[index][1], tbl[index][2], tbl[index][3], 8, 420) end function I4810240_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false --判断背包空闲空间是否足够 local FreeSize = role.GetBagFreeSize(TargetID) if(FreeSize < 3) then --提示玩家背包空间不足 bRet = 40 end return bRet, bIgnore end aux.RegisterItemEvent(4810240, 1, "I4810240_GiftBag") aux.RegisterItemEvent(4810240, 0, "I4810240_CanUseGiftBag")