function I4520041_GiftBag(MapID, InstanceID, TypeID, TargetID) -- 耋礓箨 local r = math.random(300000) local temp = 0 local index = 1 local tbl = {} tbl[1]={5802275,1,-1,87000} tbl[2]={5802274,1,-1,9000} tbl[3]={5802269,1,-1,9000} tbl[4]={5802268,1,-1,9000} tbl[5]={5802263,1,-1,9000} tbl[6]={5802262,1,-1,9000} tbl[7]={5802260,1,-1,9000} tbl[8]={5802259,1,-1,9000} tbl[9]={5802257,1,-1,9000} tbl[10]={5802256,1,-1,9000} tbl[11]={5802254,1,-1,9000} tbl[12]={5802253,1,-1,9000} tbl[13]={5802241,1,-1,9000} tbl[14]={5802240,1,-1,9000} tbl[15]={5802232,1,-1,9000} tbl[16]={5802231,1,-1,9000} tbl[17]={5802229,1,-1,9000} tbl[18]={5802228,1,-1,9000} tbl[19]={5802206,1,-1,9000} tbl[20]={5802205,1,-1,9000} tbl[21]={5802203,1,-1,9000} tbl[22]={5802168,1,-1,2000} tbl[23]={5802169,1,-1,2000} tbl[24]={5802170,1,-1,3000} tbl[25]={5802171,1,-1,1000} tbl[26]={5802172,1,-1,2000} tbl[27]={5802181,1,-1,2000} tbl[28]={5802182,1,-1,2000} tbl[29]={5802184,1,-1,2000} tbl[30]={5802185,1,-1,2000} tbl[31]={5802187,1,-1,3000} tbl[32]={5802188,1,-1,2000} tbl[33]={5802190,1,-1,3000} tbl[34]={5802191,1,-1,2000} tbl[35]={5802196,1,-1,2000} tbl[36]={5802197,1,-1,2000} tbl[37]={5802202,1,-1,2000} for i = 1,37 do temp = temp + tbl[i][4] if temp >= r then index = i break end end local sex = role.GetRoleSex(TargetID) role.AddRoleItem(MapID, InstanceID, TargetID, tbl[index][1], tbl[index][2], tbl[index][3], 8, 420) 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 end function I4520041_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(4520041, 1, "I4520041_GiftBag") aux.RegisterItemEvent(4520041, 0, "I4520041_CanUseGiftBag")