Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local config = {
- map = 1,
- x = 100,
- y = 200,
- z = 3000
- }
- -- ฟังก์ชันสำหรับการปรับค่าการตั้งค่า
- function setConfig(newMap, newX, newY, newZ)
- config.map = newMap
- config.x = newX
- config.y = newY
- config.z = newZ
- end
- -- ฟังก์ชันหลัก
- function Loop60()
- -- รับค่าการพักจากผู้ใช้เป็นวินาที
- local input = gg.prompt({
- "Sleep เมื่อพบค่า (วินาที)",
- "Sleep เมื่อไม่พบค่า (วินาที)"
- }, {5, 1}, {"number", "number"}) -- ค่าดีฟอลต์คือ 5 วินาที และ 1 วินาที
- -- ตรวจสอบว่าผู้ใช้กรอกค่าหรือไม่
- if input == nil then
- gg.alert("การตั้งค่าถูกยกเลิก")
- return
- end
- local sleepWhenFound = input[1] * 1000 -- แปลงเป็นมิลลิวินาที
- local sleepWhenNotFound = input[2] * 1000 -- แปลงเป็นมิลลิวินาที
- -- วาร์ปครั้งแรก
- warp256(config.map, config.y, config.x)
- while true do
- -- ดึงรายการข้อมูลจาก Game Guardian
- t = gg.getListItems()
- local found = false
- -- ตรวจสอบว่ามีค่าที่ต้องการหรือไม่
- for i, v in ipairs(t) do
- if v.value == config.z or v.value == 15000 then
- found = true
- break
- end
- end
- -- ถ้าเจอค่า ให้พักตามเวลาที่กำหนด ถ้าไม่เจอ ให้พักเวลาที่สั้นกว่า
- if found then
- gg.sleep(sleepWhenFound) -- พักตามเวลาที่กำหนดเมื่อเจอค่า
- warp256(config.map, config.y, config.x)
- else
- gg.sleep(sleepWhenNotFound) -- พักเวลาที่กำหนดเมื่อไม่เจอค่า
- end
- end
- end
- --Module Zone
- local ShnMap = "11001~20008;100;0~255::9"
- local ShnMapNG = "11001;0;0~255::9"
- local ShnMapNG2 = 11001
- local RefMap = "11001~20008"
- local offsetMap = 0x2C
- local offsetX = -4
- local offsetY = -12
- local offsetNextMap = 0xCC
- local offsetAutoSkip = 0xC
- local ShnXY = "497;2373;3921;34;2;218;131072::29"
- local RefXY = 497
- local offsetXYOpen = 0x19C
- --Body Zone
- local ShnBody = "3;1;1~9999999;1~999999999;-1::21"
- local RefBody = 3
- local offsetRun = 0x24
- local offsetAID = 0xC
- --NPC Zone
- local ShnNPC = "128;1;2;3;4::17"
- local RefNPC = 128
- local offsetNPC1 = 4
- local offsetNPC2 = 8
- local offsetNPC3 = 12
- local offsetNPC4 = 16
- --Boss Zone
- local Drfazen = 1290 local DrfazenM = 2200
- local BellArt = 2290 local BellArtM = 2200
- function Admin(address,flags,freeze,name,value)
- set = {}
- set[1] = {}
- set[1].address = address
- set[1].flags = flags
- set[1].value = value
- set[1].freeze = freeze
- set[1].name = name
- gg.setValues(set)
- end
- local NextMap = 16842753
- function GetLis() GL = gg.getListItems() gg.toast[[CheckGetLis]] end
- function warp(map,x,y)
- Admin(GetMap[1].address + offsetMap,4,false,nil,map) gg.addListItems(set)
- Admin(GetMap[1].address + offsetX,4,false,nil,x)
- Admin(GetMap[1].address + offsetY,4,false,nil,y)
- Admin(GetMap[1].address + offsetNextMap,4,false,nil,NextMap)
- end
- function warp256(map,y,x)
- Admin(GetMap[1].address + offsetMap,4,false,"Map",map) gg.addListItems(set)
- Admin(GetMap[1].address + offsetX,4,false,nil,x*256)
- Admin(GetMap[1].address + offsetY,4,false,nil,y*256)
- Admin(GetMap[1].address + offsetNextMap,4,false,nil,NextMap)
- end
- --Map
- local hasRun = false
- function runOnce()
- if not hasRun then
- gg.clearResults()
- gg.setVisible(false)
- gg.searchNumber(ShnXY, gg.TYPE_DWORD)
- gg.refineNumber(RefXY, gg.TYPE_DWORD)
- gg.setVisible(false)
- GetXY = gg.getResults(2)
- gg.clearResults()
- gg.setVisible(false)
- gg.searchNumber(ShnMap, gg.TYPE_DWORD)
- gg.refineNumber(RefMap, gg.TYPE_DWORD)
- gg.setVisible(false)
- GetMap = gg.getResults(2)
- if GetMap ~= 11001 and GetMap ~= 20008 then
- gg.clearResults()
- gg.setVisible(false)
- gg.searchNumber(ShnMapNG, gg.TYPE_DWORD)
- gg.refineNumber(RefMap, gg.TYPE_DWORD)
- gg.setVisible(false)
- GetMap = gg.getResults(2)
- gg.clearResults()
- end
- if GetMap ~= 11001 and GetMap ~= 20008 then
- gg.clearResults()
- gg.setVisible(false)
- gg.searchNumber(ShnMapNG2, gg.TYPE_DWORD)
- gg.refineNumber(RefMap, gg.TYPE_DWORD)
- gg.setVisible(false)
- GetMap = gg.getResults(2)
- gg.clearResults()
- end
- hasRun = true
- end
- end
- local hasRun = false
- function EP1()
- runOnce()
- E1 = gg.choice({
- "-เช็คเลขห้อง-",--1
- "-วนบอส-",--2
- "-นาวาบอส-",--3
- "-ออโต้Skip-",--4
- "ออก",--5
- }, nil, [[NUYACHA]])
- if E1 == nil then
- return
- end
- if E1 == 1 then CheckMap() end
- if E1 == 2 then Loopprom()
- end
- if E1 == 3 then warp(80010,14848,20480) end
- if E1 == 4 then Admin(GetMap[1].address + offsetAutoSkip,4,true,nil,128) gg.addListItems(set)
- end
- if E1 == 5 then
- os.exit()
- end
- end
- function GetMapNum(address,name)
- O = {}
- O[1] = {}
- O[1].address = address
- O[1].flags = 4
- O[1].name = name
- O[1].value = value
- gg.addListItems(O)
- end
- function Loopprom()
- local fileName = "/storage/emulated/0/Android/NYC.txt" -- ชื่อไฟล์ที่จะบันทึกข้อมูล
- -- ฟังก์ชันเพื่อบันทึกค่าลงไฟล์
- function saveConfig(name, map, x, y, bossMap)
- local file, err = io.open(fileName, "a")
- if not file then
- gg.toast("ไม่สามารถเปิดหรือสร้างไฟล์ได้: " .. (err or "Unknown error"))
- return
- end
- local success, writeErr = pcall(function()
- file:write(name .. "," .. map .. "," .. x .. "," .. y .. "," .. bossMap .. "\n")
- end)
- if not success then
- gg.toast("ไม่สามารถบันทึกข้อมูลได้: " .. (writeErr or "Unknown error"))
- else
- gg.toast("บันทึกข้อมูลสำเร็จ")
- end
- file:close()
- end
- -- ฟังก์ชันเพื่อโหลดค่าจากไฟล์
- function loadConfigs()
- local configs = {}
- local file = io.open(fileName, "r")
- if file then
- for line in file:lines() do
- local name, map, x, y, bossMap = line:match("([^,]+),([^,]+),([^,]+),([^,]+),([^,]+)")
- table.insert(configs, {name = name, map = tonumber(map), x = tonumber(x), y = tonumber(y), bossMap = tonumber(bossMap)})
- end
- file:close()
- end
- return configs
- end
- -- ฟังก์ชันเพื่อบันทึกไฟล์หลังจากลบหรือแก้ไขข้อมูล
- function saveAllConfigs(configs)
- local file, err = io.open(fileName, "w")
- if not file then
- gg.toast("ไม่สามารถเปิดหรือสร้างไฟล์ได้: " .. (err or "Unknown error"))
- return
- end
- for _, config in ipairs(configs) do
- file:write(config.name .. "," .. config.map .. "," .. config.x .. "," .. config.y .. "," .. config.bossMap .. "\n")
- end
- file:close()
- gg.toast("อัปเดตไฟล์เรียบร้อยแล้ว")
- end
- -- ฟังก์ชันเพื่อลบเซฟ
- function deleteConfig(index)
- local configs = loadConfigs()
- table.remove(configs, index)
- saveAllConfigs(configs)
- end
- -- ฟังก์ชันเพื่อแก้ไขเซฟ
- function editConfig(index)
- local configs = loadConfigs()
- local config = configs[index]
- local input = gg.prompt(
- {"แก้ไขเลขแมพบอส", "แก้ไข X", "แก้ไข Y", "แก้ไขเลขแมพรอบอส"},
- {config.map, config.x, config.y, config.bossMap},
- {"number", "number", "number", "number"}
- )
- if input ~= nil then
- configs[index] = {name = config.name, map = input[1], x = input[2], y = input[3], bossMap = input[4]}
- saveAllConfigs(configs)
- else
- gg.toast("ยกเลิกการแก้ไข")
- end
- end
- -- ฟังก์ชันแสดงเมนูให้ผู้ใช้เลือกว่าจะโหลดค่า, กรอกข้อมูลใหม่, ลบ หรือแก้ไขข้อมูล
- function promptForInput()
- local configs = loadConfigs()
- local choices = {"*เพิ่มเซฟ"}
- for i, config in ipairs(configs) do
- table.insert(choices, config.name)
- end
- table.insert(choices, "*ลบเซฟ")
- table.insert(choices, "*แก้ไขเซฟ")
- local choice = gg.choice(choices, nil, "เลือกวิธีการป้อนข้อมูล")
- if choice == nil then
- gg.toast("ยกเลิกการเลือก")
- return
- elseif choice == 1 then
- -- ผู้ใช้เลือกกรอกข้อมูลใหม่
- local input = gg.prompt(
- {"ใส่เลขแมพบอส", "X", "Y", "เลขแมพรอบอส"},
- {5160, 59, 51, 5004}, -- ค่าเริ่มต้น
- {"number", "number", "number", "number"}
- )
- if input ~= nil then
- -- ตั้งค่าที่รับเข้ามาจาก prompt
- local saveName = gg.prompt({"กรอกชื่อเพื่อบันทึกค่า"}, {""}, {"text"})
- if saveName ~= nil then
- saveConfig(saveName[1], input[1], input[2], input[3], input[4])
- end
- setConfig(input[1], input[2], input[3], input[4])
- Loop60()
- else
- gg.toast("ยกเลิกการใส่ข้อมูล")
- end
- elseif choice == #choices - 1 then
- -- ผู้ใช้เลือกลบเซฟ
- local deleteChoice = gg.choice(choices, nil, "เลือกเซฟที่จะลบ")
- if deleteChoice ~= nil and deleteChoice > 1 then
- deleteConfig(deleteChoice - 1)
- end
- elseif choice == #choices then
- -- ผู้ใช้เลือกแก้ไขเซฟ
- local editChoice = gg.choice(choices, nil, "เลือกเซฟที่จะแก้ไข")
- if editChoice ~= nil and editChoice > 1 then
- editConfig(editChoice - 1)
- end
- else
- -- ผู้ใช้เลือกค่าเดิมจากไฟล์
- local config = configs[choice - 1]
- setConfig(config.map, config.x, config.y, config.bossMap)
- Loop60()
- end
- end
- -- เรียกฟังก์ชันให้ผู้ใช้เลือกวิธีการป้อนข้อมูล
- promptForInput()
- end
- function GetMapNumXY(address,name,value)
- O = {}
- O[1] = {}
- O[1].address = address
- O[1].flags = 4
- O[1].name = name
- O[1].value = value
- gg.addListItems(O)
- end
- function CheckMap()
- gg.clearList(Map)
- GetMapNum(GetMap[1].address + 0x28, "Map")
- GetMapNumXY(GetMap[1].address + offsetX, "X")
- GetMapNumXY(GetMap[1].address + offsetY, "Y")
- local H = gg.getListItems()
- local map_value, x_value, y_value -- Declare variables to store values
- -- Find the Map value
- for i, v in ipairs(H) do
- if v.name == "Map" then
- map_value = v.value
- break
- end
- end
- -- Find the X value
- for i, v in ipairs(H) do
- if v.name == "X" then
- x_value = v.value / 256 -- Scale X value
- break
- end
- end
- -- Find the Y value
- for i, v in ipairs(H) do
- if v.name == "Y" then
- y_value = v.value / 256 -- Scale Y value
- break
- end
- end
- -- Display all values together in a single alert and allow copying
- if map_value and x_value and y_value then
- local output = "Map:"..map_value.." X:"..x_value.." Y:"..y_value
- gg.sleep(1000)
- gg.alert(output) -- Display the values
- gg.copyText(output) -- Copy the values to clipboard
- gg.sleep(500)
- gg.clearList(Map)
- else
- gg.alert("Error: Could not retrieve Map, X, or Y values.")
- end
- end
- while true do
- if gg.isVisible(true) then
- NUX=1
- gg.setVisible(false)
- end
- if NUX==1 then EP1()
- NUX=-1
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement