Jump to content

Aio setup


Makpptfox

Recommended Posts

Hello guys,

I'm new in the Eluna's work and was looking on the AIO because it's seem to be an awesome tool, but I have a little problem.

I tried to install the KaevStatTest from the Rochet2's github (https://github.com/Rochet2/AIO/tree/master/Examples/KaevStatTest) and I can't make it work.

I think the server side is OK, but I don't know why but the Client side don't want to display the frame.

And yes, the AIO addon is activated on the client side.

The only log message I have when I trigger the KaevStatTest script is

AIO: Received messagelength: 29
received {{1, "Kaev","ShowAttritubes"}}
AIO: Received block before Init: Kaev 1 ShowAttributes

If you know what is doing here i'll appreciate some help.

And, if it's really newbish, sincerely sorry. Wasn't into Lua and AddOns 3 days ago. :|

Regards !

Link to comment
Share on other sites

If you have latest AIO, then extra debug messages are printed when AIO_ENABLE_DEBUG_MSGS is true.

In this case the server sends a message to the player before AIO has had time to initialize.
This is not dangerous however, since AIO will store that message and process the messages in the correct order after initializing.

Initialization consists of sending a message to server to request addon files, server sending back a response and AIO handling that response.

 

However since the frame does not appear something is wrong.
What did you do with the scripts, where did you place which file? Did you know you need to use the command ".para" ingame to show the frame?

Link to comment
Share on other sites

My AIO_Server is in my ./Trinity/lua_scripts/AIO_Server
The Kaev script is in ./Trinity/lua_scripts/KaevStatTest

I tried the .para and also tried to change the hook to being triggered on any level changes with the AIO_ENABLE_DEBUG_MSGS on True and I get this answer in the two situations :

received {{1, "Kaev","ShowAttritubes"}}

I must have fucked up something client side...
 

It's like that ./Interface/AddOns/AIO_client
and (Think it's not useful, but I tested many things so..) I added the Kaev script client side too at ./Interface/AddOns/AIO_client/KaevStatTest

Thanks for your help.


---------- FIXED IT

I had another addon who was in conflict with it. It's an addon made by a friend to see the ID of every spells/items when i've disabled it, everything seems to be OK.

I'm sorry for the inconvenience and going to learn with the wiki and google !

Link to comment
Share on other sites

I dont really know.

It shouldn't interfere since it's just some GameTooltips addon and I haven't anymore the creator in my contacts to ask him (yeah, like I said, i'm a batshit in Lua).

I can send you the addon if you want, but it's really just a core.lua with less than 80 lines.

Just to know - tell me right now if I have to do a new thread - but it's possible to save the Stats in our own DB ? (The point is not to lose all the attributes at each connections)

I would love to enhance this Stats panel, or at least if you know some nice tutorials, i'm not afraid of learning.
 

Link to comment
Share on other sites

1 hour ago, Makpptfox said:

I can send you the addon if you want, but it's really just a core.lua with less than 80 lines.

it's possible to save the Stats in our own DB ? (The point is not to lose all the attributes at each connections)
I would love to enhance this Stats panel, or at least if you know some nice tutorials, i'm not afraid of learning.

Sure, send the addon if you can so I can look into it maybe.

It is possible to save the stats. You would need to make the lua script on server side to save it to database.
You could use for example OnSave hook and OnLogin hook to trigger saving and loading of the points.
You can make database queries with http://www.elunaengine.com/?search=DBQuery

Im not so sure there are tutorials about saving and loading, but here are some examples of scripts:
https://github.com/ElunaLuaEngine/Scripts/blob/master/Custom/SQL Teleporter/Eluna SQL Teleporter.lua#L47-L66
https://github.com/ElunaLuaEngine/Scripts/blob/master/Custom/Transmogrifier.lua#L479-L493

Link to comment
Share on other sites

 

47 minutes ago, Rochet2 said:


I tried thoses and compared it to another Kaev's attribute table, and I really don't know what I do wrong, and even how the other guy did it.

Here's mine,

 

Spoiler

local AIO = AIO or require("AIO")

local MyHandlers = AIO.AddHandlers("Kaev", {})
local AttributesAuraIds = { 7464, 7471, 7477, 7468, 7474 } -- Strength, Agility, Stamina, Intellect, Spirit

local function AddPlayerStats(msg, player)
    local guid = player:GetGUIDLow()
    local spend, left = AttributesPointsSpend[guid], AttributesPointsLeft[guid]
    return msg:Add("Kaev", "SetStats", left, AIO.unpack(spend))
end
AIO.AddOnInit(AddPlayerStats)

local function UpdatePlayerStats(player)
    AddPlayerStats(AIO.Msg(), player):Send(player)
end

local function AttributesInitPoints(guid)
	local playerGUID = player:GetGUIDLow()
    AttributesPointsLeft[guid] = WorldDBQuery("SELECT RemainPoints FROM statssave WHERE GUID = "..playerGUID)
    AttributesPointsSpend[guid] = {WorldDBQuery("SELECT Force, Agilité, Endurance, Intelligence, Esprit FROM statssave WHERE GUID = "..playerGUID)}
end
local function AttributesDeinitPoints(guid)
	local playerGUID = player:GetGUIDLow()
    AttributesPointsLeft[guid] = WorldDBQuery("UPDATE RemainPoints FROM statssave WHERE GUID = "..playerGUID)
    AttributesPointsSpend[guid] = {WorldDBQuery("UPDATE Force, Agilité, Endurance, Intelligence, Esprit FROM statssave WHERE GUID = "..playerGUID)}
end

local function OnLogin(event, player)
    AttributesInitPoints(player:GetGUIDLow())
end
local function OnLogout(event, player)
    AttributesDeinitPoints(player:GetGUIDLow())
end

RegisterPlayerEvent(3, OnLogin)
RegisterPlayerEvent(4, OnLogout)
for k,v in ipairs(GetPlayersInWorld()) do
    OnLogin(3, v)
end

function MyHandlers.AttributesIncrease(player, statId)
    if (player:IsInCombat()) then
        player:SendBroadcastMessage("Du kannst während einem Kampfes keine Attributspunkte verteilen.")
    else
        local guid = player:GetGUIDLow()
        local spend, left = AttributesPointsSpend[guid], AttributesPointsLeft[guid]
        if not spend or not left then
            return
        end
        if not statId or not spend[statId] then
            return
        end
        if (left <= 0) then
            player:SendBroadcastMessage("Du hast nicht genuegend Attributspunkte.")
        else
            AttributesPointsLeft[guid] = left - 1
            spend[statId] = spend[statId] + 1
            local aura = player:GetAura(AttributesAuraIds[statId])
            if (aura) then
                aura:SetStackAmount(spend[statId])
            else
                player:AddAura(AttributesAuraIds[statId], player)
            end
            UpdatePlayerStats(player)
        end
    end
end

function MyHandlers.AttributesDecrease(player, statId)
    if (player:IsInCombat()) then
        player:SendBroadcastMessage("Du kannst während einem Kampfes keine Attributspunkte verteilen.")
    else
        local guid = player:GetGUIDLow()
        local spend, left = AttributesPointsSpend[guid], AttributesPointsLeft[guid]
        if not spend or not left then
            return
        end
        if not statId or not spend[statId] then
            return
        end
        if (spend[statId] <= 0) then
            player:SendBroadcastMessage("Es sind keine Punkte auf diesem Attribut verteilt.")
        else
            AttributesPointsLeft[guid] = left + 1
            spend[statId] = spend[statId] - 1
            local aura = player:GetAura(AttributesAuraIds[statId])
            if (aura) then
                aura:SetStackAmount(spend[statId])
            else
                player:AddAura(AttributesAuraIds[statId], player)
            end
            UpdatePlayerStats(player)
			player:SaveStatPoints()
        end
    end
end

local function AttributesOnCommand(event, player, command)
    if(command == "para") then
        AIO.Handle(player, "Kaev", "ShowAttributes")
        return false
    end
end
RegisterPlayerEvent(42, AttributesOnCommand)

 



tried to Select in a table on Login and Update on Logout. I just get 
 

lua_scripts/KaevStatTest/Server.lua:18: attempt to index global `player` (a nil value)
stack traceback:
		[C]: in function `__index`
		lua_scripts/KaevStatTest/Server.lua:18: in function `AttributesInitPoints`
		lua_scripts/KaevStatTest/Server.lua:29: in function `OnLogin`
		lua_scripts/KaevStatTest/Server.lua:38: in main chunk


And the server.lua from the other guy : 

 

Spoiler

local AIO = AIO or require("AIO")

local MyHandlers = AIO.AddHandlers("Kaev", {})
local AttributesAuraIds = { 7464, 7471, 7477, 7468, 7474 } -- Strength, Agility, Stamina, Intellect, Spirit

local function GetStatTable(player)
    local strength, agility, stamina, intellect, spirit = player:GetStatPoints()
    return {strength, agility, stamina, intellect, spirit}
end

local function GetFreeStats(player)
    local stats = GetStatTable(player)

    local count = 0
    for k, v in pairs(stats) do
        --print("Count: "..tostring(count).." Free: "..v.."K "..k)
        count = count + v
    end

    return player:GetLevel() - count
end

local function BuildModifierTable(statId, amount)
    local modifier = {0, 0, 0, 0, 0}
    modifier[statId] = amount
    return modifier
end

local function AddAuras(player)
    local stats = GetStatTable(player)

    for k, v in pairs(stats) do 
        if v >= 1 then 
            player:AddAura(AttributesAuraIds[k], player)

            if v > 1 then 
                local aura = player:GetAura(AttributesAuraIds[k])
                aura:SetStackAmount(v)
            end
        end
    end
end

local function AddPlayerStats(msg, player)
    local guid = player:GetGUIDLow()
    local spend = GetStatTable(player)
    local left = GetFreeStats(player)
    return msg:Add("Kaev", "SetStats", left, AIO.unpack(spend))
end

AIO.AddOnInit(AddPlayerStats)

local function UpdatePlayerStats(player)
    AddPlayerStats(AIO.Msg(), player):Send(player)
end

local function OnLogin(event, player)
    player:UpdateStatPoints()
    AddAuras(player)
end

RegisterPlayerEvent(3, OnLogin)

for k,v in ipairs(GetPlayersInWorld()) do
    OnLogin(3, v)
end

function MyHandlers.AttributesIncrease(player, statId)
    if (player:IsInCombat()) then
        player:SendBroadcastMessage("You can't modify your attributes while in combat.")
        return
    end

    local guid = player:GetGUIDLow()
    local stats = GetStatTable(player)
    local left = GetFreeStats(player)

    if not stats or not left then
        --print("StatAllocationSystem#Server: "..player:GetName().." does not have any stats or points left")
        return
    end

    if not statId or not stats[statId] then
        --print("StatAllocationSystem#Server: "..player:GetName().." tried to modify invalid statId")
        return
    end

    if left <= 0 then
        player:SendBroadcastMessage("You don't have any points left to spend.")
        return
    end

    local t = BuildModifierTable(statId, 1)
    --print("Modifiers 1: "..tostring(t[1]).." 2: "..tostring(t[2]).." 3: "..tostring(t[3]).."  4: "..tostring(t[4]).." 5: "..tostring(t[5]))
    player:ModifyStatPoints(t[1], t[2], t[3], t[4], t[5])

    local aura = player:GetAura(AttributesAuraIds[statId])

    if (aura) then
        aura:SetStackAmount(stats[statId])
    else
        player:AddAura(AttributesAuraIds[statId], player)
    end

    UpdatePlayerStats(player)
    player:SaveStatPoints()
end

function MyHandlers.AttributesDecrease(player, statId)
    if (player:IsInCombat()) then
        player:SendBroadcastMessage("You can't modify your attributes while in combat.")
        return
    end

    local guid = player:GetGUIDLow()
    local stats = GetStatTable(player)
    local left = GetFreeStats(player)

    if not stats or not left then
        --print("StatAllocationSystem#Server: "..player:GetName().." does not have any stats or points to remove")
        return
    end

    if not statId or not stats[statId] then
        --print("StatAllocationSystem#Server: "..player:GetName().." tried to modify invalid statId")
        return
    end

    if stats[statId] <= 0 then
        player:SendBroadcastMessage("You don't have any points left to remove.")
        return
    end

    local t = BuildModifierTable(statId, -1)
    --print("Modifiers 1: "..tostring(t[1]).." 2: "..tostring(t[2]).." 3: "..tostring(t[3]).."  4: "..tostring(t[4]).." 5: "..tostring(t[5]))
    player:ModifyStatPoints(t[1], t[2], t[3], t[4], t[5])

    local aura = player:GetAura(AttributesAuraIds[statId])
    if (aura) then
        --print("New amount: "..tostring(stats[statId]-1))
        aura:SetStackAmount(stats[statId]-1)
    else
        player:AddAura(AttributesAuraIds[statId], player)
    end

    UpdatePlayerStats(player)
    player:SaveStatPoints()
end

local function AttributesOnCommand(event, player, command)
    if(command == "stats") then
        AIO.Handle(player, "Kaev", "ShowAttributes")
        return false
    end
end

RegisterPlayerEvent(42, AttributesOnCommand)

local function OnLevelChange(event, player, oldLevel)
    UpdatePlayerStats(player)
    player:RemoveAura(7464)
    player:RemoveAura(7471)
    player:RemoveAura(7477)
    player:RemoveAura(7468)
    player:RemoveAura(7474)
end

RegisterPlayerEvent(13, OnLevelChange)

 

lua_scripts/StatAllocationSystem/Server.lua:58: attempt to call method `UpdatestatPoints` (a nil value)
stack traceback:
		[C]: in function `UpdateStatPoints`
		lua_scripts/StatAllocationSystem/Server.lua:58: in function `OnLogin`
		lua_scripts/StatAllocationSystem/Server.lua:65: in main chunk

Could you help me a little more, at least to understand this bad boy ?

Thank you.

Link to comment
Share on other sites

local function AttributesInitPoints(guid)
    local playerGUID = player:GetGUIDLow()

The local playerGUID is unnecessary, considering you get the guid from the call in OnLogin, and you can simply pass that guid. Considering you are not passing the 'player' variable to the function but just the guid, player is not a valid variable to use, as it is not a global variable. So simply do it like this:

local function AttributesInitPoints(guid)
    AttributesPointsLeft[guid] = WorldDBQuery("SELECT RemainPoints FROM statssave WHERE GUID = "..guid)
    AttributesPointsSpend[guid] = {WorldDBQuery("SELECT Force, Agilité, Endurance, Intelligence, Esprit FROM statssave WHERE GUID = "..guid)}
end

Same for AttributesDeinitPoints, what is this supposed to do actually? Just update the database table? If so, consider renaming the function.

Link to comment
Share on other sites

1 hour ago, Foereaper said:

Same for AttributesDeinitPoints, what is this supposed to do actually? Just update the database table? If so, consider renaming the function.

It was supposed to store the modified stats with an update to the DB, but I think my whole lua thing is shit.

I'm gonna try to make the clean one I linked before from the Waloria's work and change it a bit to know what is modifying what once it would be running. (Waloria is OK with the sharing https://github.com/Freddan962/Waloria )

Simple question, I've found nowhere on the Eluna wiki the method player:UpdateStatPoints(), is that a deprecated one ? Or Do I to add a hook or somewhat ? I'm kind of lost right now, but I really want to understand how this thing works. The possibilities are awesomes.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use