function I1241145_GiftBag(MapID, InstanceID, TypeID, TargetID) --玩家ID, 生成物品TypeID,数量,品质,生成模式,log用网络消息枚举 local r = math.random(35296) local temp = 0 local index = 1 local tbl = {} tbl[1 ]={9990006, 1, 6, 4000} -- 10% tbl[2 ]={9990007, 1, 6, 2900} -- 9% tbl[3 ]={9990008, 1, 6, 2800} -- 8% tbl[4 ]={9990009, 1, 6, 2700} -- 7% tbl[5 ]={9990010, 1, 6, 2400} -- 4% tbl[6 ]={9990011, 1, 6, 2300} -- 3% tbl[7 ]={9990012, 1, 6, 2200} -- 2% tbl[8 ]={9990013, 1, 6, 2200} -- 2% tbl[9 ]={9990014, 1, 6, 2200} -- 2% tbl[10]={9990020, 1, 6, 2200} -- 2% tbl[11]={9990021, 1, 6, 2150} -- 1.5% tbl[12]={9990022, 1, 6, 2100} -- 1% tbl[13]={9990026, 1, 6, 1150} -- 0.5% tbl[14]={9990029, 1, 6, 1125} -- 0.25% tbl[15]={9990032, 1, 6, 1110} -- 0.1% tbl[16]={9990033, 1, 6, 800} -- 0.05% tbl[17]={9990034, 1, 6, 500} -- 0.02% tbl[18]={9990035, 1, 6, 200} -- 0.01% tbl[19]={9990040, 1, 6, 150} -- 0.01% tbl[20]={9990041, 1, 6, 111} -- 0.01% for i = 1,20 do temp = temp + tbl[i][4] if temp >= r then index = i break end end if index >= 1 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], tbl[index][3], 8, 420) end function I1241145_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(1241145, 1, "I1241145_GiftBag") aux.RegisterItemEvent(1241145, 0, "I1241145_CanUseGiftBag")