定时邮件整理(@青梅煮酒)

定时邮件整理(@青梅煮酒)

/**
* 第一次发送道具,代表发了两个道具 无色(3036) -> 20个,复活币(1)-> 20个(你要给在线玩家得东西)
*
* @type {number[][]}
*/
var item_list_one = [
[3036, 20],
[1, 20]
];

// 当天的16点24分0秒,0 ->代表发多少个金币,item_list_one ->发送的道具最多10个道具!(什么时间发送)
executeAtTime(16, 24, 0, 0, item_list_one, function () {
api_GameWorld_SendNotiPacketMessage("在线奖励[ 1 ],已发放!!!", 14);
});

var G_GameWorld = new NativeFunction(ptr(0x080DA3A7), ‘pointer’, [], {“abi”: “sysv”});
var gameworld_user_map_begin = new NativeFunction(ptr(0x80F78A6), ‘int’, [‘pointer’, ‘pointer’], {“abi”: “sysv”});
var gameworld_user_map_end = new NativeFunction(ptr(0x80F78CC), ‘int’, [‘pointer’, ‘pointer’], {“abi”: “sysv”});
var gameworld_user_map_not_equal = new NativeFunction(ptr(0x80F78F2), ‘bool’, [‘pointer’, ‘pointer’], {“abi”: “sysv”});
var gameworld_user_map_get = new NativeFunction(ptr(0x80F7944), ‘pointer’, [‘pointer’], {“abi”: “sysv”});
var CUser_get_state = new NativeFunction(ptr(0x80DA38C), ‘int’, [‘pointer’], {“abi”: “sysv”});
var CUserCharacInfo_getCurCharacNo = new NativeFunction(ptr(0x80CBC4E), ‘int’, [‘pointer’], {“abi”: “sysv”});
var gameworld_user_map_next = new NativeFunction(ptr(0x80F7906), ‘pointer’, [‘pointer’, ‘pointer’], {“abi”: “sysv”});
var Inven_Item_Inven_Item = new NativeFunction(ptr(0x80CB854), ‘pointer’, [‘pointer’], {“abi”: “sysv”});
var std_vector_std_pair_int_int_push_back = new NativeFunction(ptr(0x80DD606), ‘pointer’, [‘pointer’, ‘pointer’], {“abi”: “sysv”});
var std_make_pair_int_int = new NativeFunction(ptr(0x81B8D41), ‘pointer’, [‘pointer’, ‘pointer’, ‘pointer’], {“abi”: “sysv”});
var std_vector_std_pair_int_int_vector = new NativeFunction(ptr(0x81349D6), ‘pointer’, [‘pointer’], {“abi”: “sysv”});
var std_vector_std_pair_int_int_clear = new NativeFunction(ptr(0x817A342), ‘pointer’, [‘pointer’], {“abi”: “sysv”});

var WongWork_CMailBoxHelper_ReqDBSendNewSystemMultiMail = new NativeFunction(ptr(0x8556B68), ‘int’, [‘pointer’, ‘pointer’, ‘int’, ‘int’, ‘int’, ‘pointer’, ‘int’, ‘int’, ‘int’, ‘int’], {“abi”: “sysv”});
var WongWork_CMailBoxHelper_MakeSystemMultiMailPostal = new NativeFunction(ptr(0x8556A14), ‘int’, [‘pointer’, ‘pointer’, ‘int’], {“abi”: “sysv”});

/**
* 发系统邮件(多道具)
*
* @param target_charac_no 角色charac_no
* @param title 邮件标题
* @param text 邮件正文
* @param gold 金币数量
* @param item_list 道具列表
*/
function api_WongWork_CMailBoxHelper_ReqDBSendNewSystemMultiMail(target_charac_no, title, text, gold, item_list) {

var vector = Memory.alloc(100);
std_vector_std_pair_int_int_vector(vector);
std_vector_std_pair_int_int_clear(vector);

for (var i = 0; i < item_list.length; ++i) {
var item_id = Memory.alloc(4);
var item_cnt = Memory.alloc(4);
item_id.writeInt(item_list[i][0]);
item_cnt.writeInt(item_list[i][1]);
var pair = Memory.alloc(100);
std_make_pair_int_int(pair, item_id, item_cnt);
std_vector_std_pair_int_int_push_back(vector, pair);
}

var addition_slots = Memory.alloc(1000);
for (var i = 0; i < 10; ++i) {
Inven_Item_Inven_Item(addition_slots.add(i * 61));
}
WongWork_CMailBoxHelper_MakeSystemMultiMailPostal(vector, addition_slots, 10);
var title_ptr = Memory.allocUtf8String(title);
var text_ptr = Memory.allocUtf8String(text);
var text_len = strlen(text_ptr);
//发邮件给角色
WongWork_CMailBoxHelper_ReqDBSendNewSystemMultiMail(title_ptr, addition_slots, item_list.length, gold, target_charac_no, text_ptr, text_len, 0, 99, 1);
}

/**
* 遍历在线玩家列表
*
* @param it 参数
* @returns {*}
*/
function api_gameworld_user_map_next(it) {
var next = Memory.alloc(4);
gameworld_user_map_next(next, it);
return next;
}

/**
* 获取当前正在遍历的玩家
* @param it 参数
* @returns {*}
*/
function api_gameworld_user_map_get(it) {
return gameworld_user_map_get(it).add(4).readPointer();
}

/**
* 获取在线玩家列表表头
*
* @returns {*}
*/
function api_gameworld_user_map_begin() {
var begin = Memory.alloc(4);
gameworld_user_map_begin(begin, G_GameWorld().add(308));
return begin;
}

/**
* //获取在线玩家列表表尾
*
* @returns {*}
*/
function api_gameworld_user_map_end() {
var end = Memory.alloc(4);
gameworld_user_map_end(end, G_GameWorld().add(308));
return end;
}

/**
* 全服在线玩家发信
*
* @param title 标题
* @param text 内容
* @param gold 金币
* @param item_list 道具数组
*/
function api_gameworld_send_mail(title, text, gold, item_list) {
//遍历在线玩家列表
var it = api_gameworld_user_map_begin();
var end = api_gameworld_user_map_end();

//判断在线玩家列表遍历是否已结束
while (gameworld_user_map_not_equal(it, end)) {
//当前被遍历到的玩家
var user = api_gameworld_user_map_get(it);

//只处理已登录角色
if (CUser_get_state(user) >= 3) {
//角色uid
var charac_no = CUserCharacInfo_getCurCharacNo(user);
//给角色发信
api_WongWork_CMailBoxHelper_ReqDBSendNewSystemMultiMail(charac_no, title, text, gold, item_list);
}
//继续遍历下一个玩家
api_gameworld_user_map_next(it);
}
}

/**
* 定时发送邮件
*
* @param hour 小时
* @param minute 分钟
* @param second 秒
* @param gold 金币数量
* @param item_list 道具 二维数组
* @param task 表示需要执行的任务,通常是一个函数对象,将在设定的时间点触发执行。
*/
function executeAtTime(hour, minute, second, gold, item_list, task) {

var now = new Date();

var target = new Date(now.getFullYear(), now.getMonth(), now.getDate(), hour, minute, second);

if (now.getTime() > target.getTime()) {
target.setDate(target.getDate() + 1);
}

var diff = target.getTime() – now.getTime();

setTimeout(function () {
// 发邮件
api_gameworld_send_mail(“GM台服官方邮件”, “DNF台服运营商不会已任何形式索要你的用户名密码请你不要邮寄关于您账号密码的任何信息!”, gold, item_list);
task();

executeAtTime(hour, minute, second, task);
}, diff);
}

/**
* 第一次发送道具,代表发了两个道具 无色(3036) -> 20个,复活币(1)-> 20个
*
* @type {number[][]}
*/
var item_list_one = [
[3036, 20],
[1, 20]
];

// 当天的16点24分0秒,0 ->代表发多少个金币,item_list_one ->发送的道具最多10个道具!
executeAtTime(16, 24, 0, 0, item_list_one, function () {
api_GameWorld_SendNotiPacketMessage(“在线奖励[ 1 ],已发放!!!”, 14);
});

/**
* 第二次发送道具,代表发了两个道具 无色(3036) -> 20个,无色(3036)-> 20个
*
* @type {number[][]}
*/
var item_list_two = [
[3036, 20],
[3036, 20]
];

// 当天的16点25分0秒,0 ->代表发多少个金币,item_list_one ->发送的道具最多10个道具!
executeAtTime(16, 25, 0, 0, item_list_two, function () {
api_GameWorld_SendNotiPacketMessage(“在线奖励[ 2 ],已发放!!!”, 14);
});

/**
* 第三次发送道具,(以此类推)
*
* @type {number[][]}
*/
var item_list_two = [
[3036, 20],
[3036, 20]
];

executeAtTime(16, 25, 0, 0, item_list_two, function () {
api_GameWorld_SendNotiPacketMessage(“在线奖励[ 3 ],已发放!!!”, 14);
});

var G_GameWorld = new NativeFunction(ptr(0x080DA3A7), 'pointer', [], {"abi": "sysv"});
var gameworld_user_map_begin = new NativeFunction(ptr(0x80F78A6), 'int', ['pointer', 'pointer'], {"abi": "sysv"});
var gameworld_user_map_end = new NativeFunction(ptr(0x80F78CC), 'int', ['pointer', 'pointer'], {"abi": "sysv"});
var gameworld_user_map_not_equal = new NativeFunction(ptr(0x80F78F2), 'bool', ['pointer', 'pointer'], {"abi": "sysv"});
var gameworld_user_map_get = new NativeFunction(ptr(0x80F7944), 'pointer', ['pointer'], {"abi": "sysv"});
var CUser_get_state = new NativeFunction(ptr(0x80DA38C), 'int', ['pointer'], {"abi": "sysv"});
var CUserCharacInfo_getCurCharacNo = new NativeFunction(ptr(0x80CBC4E), 'int', ['pointer'], {"abi": "sysv"});
var gameworld_user_map_next = new NativeFunction(ptr(0x80F7906), 'pointer', ['pointer', 'pointer'], {"abi": "sysv"});
var Inven_Item_Inven_Item = new NativeFunction(ptr(0x80CB854), 'pointer', ['pointer'], {"abi": "sysv"});
var std_vector_std_pair_int_int_push_back = new NativeFunction(ptr(0x80DD606), 'pointer', ['pointer', 'pointer'], {"abi": "sysv"});
var std_make_pair_int_int = new NativeFunction(ptr(0x81B8D41), 'pointer', ['pointer', 'pointer', 'pointer'], {"abi": "sysv"});
var std_vector_std_pair_int_int_vector = new NativeFunction(ptr(0x81349D6), 'pointer', ['pointer'], {"abi": "sysv"});
var std_vector_std_pair_int_int_clear = new NativeFunction(ptr(0x817A342), 'pointer', ['pointer'], {"abi": "sysv"});

var WongWork_CMailBoxHelper_ReqDBSendNewSystemMultiMail = new NativeFunction(ptr(0x8556B68), 'int', ['pointer', 'pointer', 'int', 'int', 'int', 'pointer', 'int', 'int', 'int', 'int'], {"abi": "sysv"});
var WongWork_CMailBoxHelper_MakeSystemMultiMailPostal = new NativeFunction(ptr(0x8556A14), 'int', ['pointer', 'pointer', 'int'], {"abi": "sysv"});

/**
 * 发系统邮件(多道具)
 *
 * @param target_charac_no 角色charac_no
 * @param title 邮件标题
 * @param text 邮件正文
 * @param gold 金币数量
 * @param item_list 道具列表
 */
function api_WongWork_CMailBoxHelper_ReqDBSendNewSystemMultiMail(target_charac_no, title, text, gold, item_list) {

    var vector = Memory.alloc(100);
    std_vector_std_pair_int_int_vector(vector);
    std_vector_std_pair_int_int_clear(vector);

    for (var i = 0; i < item_list.length; ++i) {
        var item_id = Memory.alloc(4);
        var item_cnt = Memory.alloc(4);
        item_id.writeInt(item_list[i][0]);
        item_cnt.writeInt(item_list[i][1]);
        var pair = Memory.alloc(100);
        std_make_pair_int_int(pair, item_id, item_cnt);
        std_vector_std_pair_int_int_push_back(vector, pair);
    }

    var addition_slots = Memory.alloc(1000);
    for (var i = 0; i < 10; ++i) {
        Inven_Item_Inven_Item(addition_slots.add(i * 61));
    }
    WongWork_CMailBoxHelper_MakeSystemMultiMailPostal(vector, addition_slots, 10);
    var title_ptr = Memory.allocUtf8String(title);
    var text_ptr = Memory.allocUtf8String(text);
    var text_len = strlen(text_ptr);
    //发邮件给角色
    WongWork_CMailBoxHelper_ReqDBSendNewSystemMultiMail(title_ptr, addition_slots, item_list.length, gold, target_charac_no, text_ptr, text_len, 0, 99, 1);
}

/**
 * 遍历在线玩家列表
 *
 * @param it 参数
 * @returns {*}
 */
function api_gameworld_user_map_next(it) {
    var next = Memory.alloc(4);
    gameworld_user_map_next(next, it);
    return next;
}

/**
 * 获取当前正在遍历的玩家
 * @param it 参数
 * @returns {*}
 */
function api_gameworld_user_map_get(it) {
    return gameworld_user_map_get(it).add(4).readPointer();
}

/**
 * 获取在线玩家列表表头
 *
 * @returns {*}
 */
function api_gameworld_user_map_begin() {
    var begin = Memory.alloc(4);
    gameworld_user_map_begin(begin, G_GameWorld().add(308));
    return begin;
}

/**
 * //获取在线玩家列表表尾
 *
 * @returns {*}
 */
function api_gameworld_user_map_end() {
    var end = Memory.alloc(4);
    gameworld_user_map_end(end, G_GameWorld().add(308));
    return end;
}

/**
 * 全服在线玩家发信
 *
 * @param title 标题
 * @param text 内容
 * @param gold 金币
 * @param item_list 道具数组
 */
function api_gameworld_send_mail(title, text, gold, item_list) {
    //遍历在线玩家列表
    var it = api_gameworld_user_map_begin();
    var end = api_gameworld_user_map_end();

    //判断在线玩家列表遍历是否已结束
    while (gameworld_user_map_not_equal(it, end)) {
        //当前被遍历到的玩家
        var user = api_gameworld_user_map_get(it);

        //只处理已登录角色
        if (CUser_get_state(user) >= 3) {
            //角色uid
            var charac_no = CUserCharacInfo_getCurCharacNo(user);
            //给角色发信
            api_WongWork_CMailBoxHelper_ReqDBSendNewSystemMultiMail(charac_no, title, text, gold, item_list);
        }
        //继续遍历下一个玩家
        api_gameworld_user_map_next(it);
    }
}


/**
 * 定时发送邮件
 *
 * @param hour 小时
 * @param minute 分钟
 * @param second 秒
 * @param gold 金币数量
 * @param item_list 道具 二维数组
 * @param task 表示需要执行的任务,通常是一个函数对象,将在设定的时间点触发执行。
 */
function executeAtTime(hour, minute, second, gold, item_list, task) {

    var now = new Date();

    var target = new Date(now.getFullYear(), now.getMonth(), now.getDate(), hour, minute, second);

    if (now.getTime() > target.getTime()) {
        target.setDate(target.getDate() + 1);
    }

    var diff = target.getTime() - now.getTime();

    setTimeout(function () {
        // 发邮件
        api_gameworld_send_mail("GM台服官方邮件", "DNF台服运营商不会已任何形式索要你的用户名密码请你不要邮寄关于您账号密码的任何信息!", gold, item_list);
        task();

        executeAtTime(hour, minute, second, task);
    }, diff);
}

/**
 * 第一次发送道具,代表发了两个道具 无色(3036) -> 20个,复活币(1)-> 20个
 *
 * @type {number[][]}
 */
var item_list_one = [
    [3036, 20],
    [1, 20]
];

// 当天的16点24分0秒,0 ->代表发多少个金币,item_list_one ->发送的道具最多10个道具!
executeAtTime(16, 24, 0, 0, item_list_one, function () {
    api_GameWorld_SendNotiPacketMessage("在线奖励[ 1 ],已发放!!!", 14);
});

/**
 * 第二次发送道具,代表发了两个道具 无色(3036) -> 20个,无色(3036)-> 20个
 *
 * @type {number[][]}
 */
var item_list_two = [
    [3036, 20],
    [3036, 20]
];

// 当天的16点25分0秒,0 ->代表发多少个金币,item_list_one ->发送的道具最多10个道具!
executeAtTime(16, 25, 0, 0, item_list_two, function () {
    api_GameWorld_SendNotiPacketMessage("在线奖励[ 2 ],已发放!!!", 14);
});


/**
 * 第三次发送道具,(以此类推)
 *
 * @type {number[][]}
 */
var item_list_two = [
    [3036, 20],
    [3036, 20]
];

executeAtTime(16, 25, 0, 0, item_list_two, function () {
    api_GameWorld_SendNotiPacketMessage("在线奖励[ 3 ],已发放!!!", 14);
© 版权声明
THE END
喜欢就支持一下吧
点赞3 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容