[JX] Hàm mới hay cũ
Hello & Welcome to our community. Is this your first visit? Đăng Ký
Follow us on
Follow us on Facebook Follow us on Twitter Linked In Flickr Watch us on YouTube My Space Blogger
 
Kết quả 1 đến 2 của 2

Chủ đề: Hàm mới hay cũ

  1. #1
    Thành Viên sky.light9530's Avatar
    Ngày tham gia
    Jan 2012
    Bài viết
    255
    Thanks
    118
    Thanked 371 Times in 84 Posts

    Hàm mới hay cũ

    szNpcName = "Tho ren"
    tbClickLine = {6, 2, 2, 2}
    nRepeat = 0
    --------------------------------------------------------------------------------
    nDelay = 100

    TalkToNpc = function(szNpcName)
    local nPlrX, nPlrY = player.GetMapPos()
    local nNpcX, nNpcY = 0, 0
    local nIndex = 0
    local nDistance = 10000
    for i = 2, 255 do
    if system.MatchString(npc.GetName(i), szNpcName) ~= 0 then
    nNpcX, nNpcY = npc.GetMapPos(i)
    if (nPlrX - nNpcX) * (nPlrX - nNpcX) + (nPlrY - nNpcY) * (nPlrY - nNpcY) < nDistance * nDistance then
    nDistance = math.sqrt((nPlrX - nNpcX) * (nPlrX - nNpcX) + (nPlrY - nNpcY) * (nPlrY - nNpcY))
    nIndex = i
    end
    end
    end

    nNpcX, nNpcY = npc.GetMapPos(nIndex)
    if (nPlrX - nNpcX)*(nPlrX - nNpcX) + (nPlrY - nNpcY) * (nPlrY - nNpcY) > 65 * 65 then
    player.MoveTo(nNpcX, nNpcY)
    else
    player.DialogNpc(nIndex)
    end
    end

    IsMenuVisible = function()
    if menu.IsVisible(0) ~= 0 or menu.IsVisible(1) ~= 0 then
    return 1
    end
    return 0
    end

    GetMenuText = function(nIndex)
    if menu.IsVisible(0) ~= 0 then
    return menu.GetText(0, nIndex)
    end

    if menu.IsVisible(1) ~= 0 then
    return menu.GetText(1, nIndex)
    end
    return ""
    end

    ClickMenuIndex = function(nIndex)
    if menu.IsVisible(0) ~= 0 then
    menu.ClickIndex(0, nIndex)
    end

    if menu.IsVisible(1) ~= 0 then
    menu.ClickIndex(1, nIndex)
    end
    end


    DoScript = function()
    local szBuffer = ""
    local nCount = 0

    while true do
    while dialog.IsVisible() ~= 0 do dialog.Close() timer.Sleep(nDelay) end

    while IsMenuVisible() == 0 do TalkToNpc(szNpcName) timer.Sleep(nDelay) end

    for i = 1, table.maxn(tbClickLine) do
    szBuffer = GetMenuText(0)
    ClickMenuIndex(tbClickLine[i] - 1)
    if i < table.maxn(tbClickLine) then
    while (szBuffer == GetMenuText(0) or IsMenuVisible() == 0) do timer.Sleep(nDelay) end
    end
    end
    nCount = nCount + 1
    if nRepeat > 0 and nCount >= nRepeat then break end
    end
    end

    function StopTimer()
    end

    function main()
    DoScript()
    end
    Khách viếng thăm hãy cùng sky.light9530 xây dựng diễn đàn CLBGAMESVN vững mạnh nhé!

  2. #2
    Vi phạm quy định
    Ngày tham gia
    Jun 2011
    Bài viết
    102
    Thanks
    0
    Thanked 156 Times in 30 Posts

    Ðề: Hàm mới hay cũ

    đây là code mới,nhưng mà code kiểu này script chạy chậm lắm.
    đây là code table
    Khách viếng thăm hãy cùng LeHuyetVoHon xây dựng diễn đàn CLBGAMESVN vững mạnh nhé!

 

 

Quyền viết bài

  • Bạn Không thể gửi Chủ đề mới
  • Bạn Không thể Gửi trả lời
  • Bạn Không thể Gửi file đính kèm
  • Bạn Không thể Sửa bài viết của mình
  •  
Múi giờ GMT +7. Bây giờ là 10:54 AM.
vBulletin®, Copyright ©2000-2011, Jelsoft Enterprises Ltd.
CLBGamesVN không chịu trách nhiệm về Luật Bản Quyền của các tài liệu, bài viết v.v...được đăng tải trên diễn đàn này.
Diễn đàn phát triển dưới sự đóng góp của tất cả thành viên. BQT chỉ là những người thành lập ra sân chơi, quản lý và duy trì về mặt kỹ thuật, nội dung khi hợp lệ.