Page 5 of 5 FirstFirst ... 3 4 5
Results 41 to 42 of 42

Thread: anyone managed to use CreateHTTPRequest?

  1. #41
    Basic Member
    Join Date
    Dec 2016
    Posts
    687
    Wrote a quick Player Update data population function as an example. Here is the function:

    Code:
    dkjson = require( "game/dkjson" )
    
    local function dumpHeroInfo( hHero )
        if not ValidTarget(hHero) then return "{}" end
        local data = {}
        
        data.Level      = hHero:GetLevel()
        data.Health     = hHero:GetHealth()
        data.MaxHealth  = hHero:GetMaxHealth()
        data.HealthReg  = hHero:GetHealthRegen()
        data.Mana       = hHero:GetMana()
        data.MaxMana    = hHero:GetMaxMana()
        data.ManaReg    = hHero:GetManaRegen()
        data.Gold       = hHero:GetGold()
        data.AP         = hHero:GetAbilityPoints()
        data.MS         = hHero:GetCurrentMovementSpeed()
        
        local loc = hHero:GetLocation()
        data.X          = loc.x
        data.Y          = loc.y
        data.Z          = loc.z
        
        local items = {}
        for iInvIndex = 0, 15, 1 do
            local hItem = hHero:GetItemInSlot(iInvIndex)
            if hItem ~= nil then
                local str = hItem:GetName()
                local numCharges = hItem:GetCurrentCharges()
                if numCharges > 1 then
                    str = str .. '_' .. numCharges
                end
                table.insert(items, str)
            end
        end
        data.Items      = items
    
        local json = dkjson.encode(data)
        return json
    end
    The JSON packet that is sent:
    Code:
    Sending Player Update: {"Type": "P2", "Time": 3415.7595214844, "Data": {"ManaReg":24.209999084473,"Level":1,"MaxHealth":640,"Health":640,"HealthReg":26.919998168945,"Gold":625,"Z":512,"Mana":240,"AP":1,"X":-6700,"Y":-6700.00390625,"MS":315,"Items":[],"MaxMana":240}}

  2. #42

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •