function I4810184_GiftBag(MapID, InstanceID, TypeID, TargetID) --玩家ID, 生成物品TypeID,数量,品质,生成模式,log用网络消息枚举 local r = math.random(10000) local temp = 0 local index = 1 local tbl = {} tbl[1]={4810183,1,1200} tbl[2]={4810183,100,80} tbl[3]={3020082,2,400} tbl[4]={5600001,1,850} tbl[5]={3070002,1,840} tbl[6]={4820047,3,1100} tbl[7]={4820046,3,1100} tbl[8]={4820256,1,150} tbl[9]={4820062,3,700} tbl[10]={3500039,1,100} tbl[11]={4810055,1,350} tbl[12]={4810056,1,255} tbl[13]={3500208,1,80} tbl[14]={3500207,1,120} tbl[15]={3500204,1,150} tbl[16]={3500048,1,800} tbl[17]={4810109,1,5} tbl[18]={4820180,1,60} tbl[19]={4810154,3,230} tbl[20]={4810157,1,1} tbl[21]={3030467,1,5} tbl[22]={3030474,1,5} tbl[23]={3030481,1,5} tbl[24]={3030488,1,5} tbl[25]={3051616,1,50} tbl[26]={3020052,1,309} tbl[27]={3020103,100,400} tbl[28]={3020106,1,100} tbl[29]={4820274,1,400} tbl[30]={4820262,100,150} for i = 1,30 do temp = temp + tbl[i][3] if temp >= r then index = i break end end if index == 2 or index == 10 or index == 13 or index == 17 or index == 18 or index == 20 or index == 21 or index == 22 or index == 23 or index == 24 or index == 25 or index == 30 then local MsgID = msg.BeginMsgEvent() msg.AddMsgEvent(MsgID, 100, 280) --开启了获得了 msg.AddMsgEvent(MsgID, 2, TargetID) msg.AddMsgEvent(MsgID, 4, TypeID) msg.AddMsgEvent(MsgID, 4, tbl[index][1]) msg.DispatchWorldMsgEvent(MsgID) end role.AddRoleItem(MapID, InstanceID, TargetID, tbl[index][1], tbl[index][2], -1, 8, 420) end aux.RegisterItemEvent(4810184, 1, "I4810184_GiftBag") function I4810184_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false --判断背包空闲空间是否足够 local FreeSize = role.GetBagFreeSize(TargetID) if(FreeSize < 1) then --提示玩家背包空间不足 bRet = 40 end return bRet, bIgnore end aux.RegisterItemEvent(4810184, 0, "I4810184_CanUseGiftBag")