111
This commit is contained in:
@@ -777,4 +777,71 @@ function User::DropItem(ItemId, Xpos, Ypos) {
|
||||
Sq_WriteByteArr(S_Ptr("0x85A773C"), [0x89, 0x44, 0x24, 0x04, 0x8B, 0x45, 0x08]);
|
||||
NativePointer("0x085A7599").writeShort(300);
|
||||
NativePointer("0x085A759F").writeShort(240);
|
||||
}
|
||||
|
||||
//角色类 发送邮件函数 (标题, 正文, 金币, 道具列表[[3037,100],[3038,100]])
|
||||
function User::ReqDBSendMultiMail(title, text, gold, item_list) {
|
||||
Timer.SetTimeOut(function(SUser,title, text, gold, item_list) {
|
||||
local Cid = SUser.GetCID();
|
||||
// 获取分割后的道具列表
|
||||
local subLists;
|
||||
local maxSlots = 10;
|
||||
local length = item_list.len();
|
||||
if (length <= maxSlots) {
|
||||
subLists = [item_list];
|
||||
} else {
|
||||
subLists = [];
|
||||
for (local i = 0; i< length; i += maxSlots) {
|
||||
local end = i + maxSlots;
|
||||
if (end > length) {
|
||||
end = length;
|
||||
}
|
||||
subLists.append(item_list.slice(i, end));
|
||||
}
|
||||
}
|
||||
if (subLists) {
|
||||
// 为每个子列表发送邮件
|
||||
for (local i = 0; i< subLists.len(); ++i) {
|
||||
local subList = subLists[i];
|
||||
|
||||
// 添加道具附件
|
||||
local vector = Memory.alloc(100);
|
||||
|
||||
Sq_CallFunc(S_Ptr("0x81349D6"), "pointer", ["pointer"], vector.C_Object);
|
||||
Sq_CallFunc(S_Ptr("0x817A342"), "pointer", ["pointer"], vector.C_Object);
|
||||
//将所有要发送的道具写入Vector
|
||||
for (local j = 0; j< subList.len(); ++j) {
|
||||
//道具ID 分配4字节内存
|
||||
local item_id = Memory.alloc(4);
|
||||
//道具数量 分配4字节内存
|
||||
local item_cnt = Memory.alloc(4);
|
||||
//写入道具ID和数量
|
||||
item_id.writeInt(subList[j][0]);
|
||||
item_cnt.writeInt(subList[j][1]);
|
||||
|
||||
local pair = Memory.alloc(100);
|
||||
|
||||
Sq_CallFunc(S_Ptr("0x81B8D41"), "pointer", ["pointer", "pointer", "pointer"], pair.C_Object, item_id.C_Object, item_cnt.C_Object);
|
||||
Sq_CallFunc(S_Ptr("0x80DD606"), "pointer", ["pointer", "pointer"], vector.C_Object, pair.C_Object);
|
||||
}
|
||||
|
||||
// 邮件支持10个道具附件格子
|
||||
local addition_slots = Memory.alloc(1000);
|
||||
|
||||
for (local j = 0; j< 10; ++j) {
|
||||
Sq_CallFunc(S_Ptr("0x80CB854"), "pointer", ["pointer"], addition_slots.add(j * 61).C_Object);
|
||||
}
|
||||
|
||||
Sq_CallFunc(S_Ptr("0x8556A14"), "int", ["pointer", "pointer", "int"], vector.C_Object, addition_slots.C_Object, 10);
|
||||
|
||||
local title_ptr = Memory.allocUtf8String(title); // 邮件标题
|
||||
local text_ptr = Memory.allocUtf8String(text); // 邮件正文
|
||||
|
||||
local text_len = text.len(); // 邮件正文长度
|
||||
|
||||
// 发邮件给角色
|
||||
Sq_CallFunc(S_Ptr("0x8556B68"), "int", ["pointer", "pointer", "int", "int", "int", "pointer", "int", "int", "int", "int"], title_ptr.C_Object, addition_slots.C_Object, subList.len(), gold, Cid, text_ptr.C_Object, text_len, 0, 99, 1);
|
||||
}
|
||||
}
|
||||
}, 1,this,title, text, gold, item_list);
|
||||
}
|
||||
Reference in New Issue
Block a user