- Joined
- Jun 26, 2020
- Messages
- 1,915
Hello, I wanna add buttons in the Allies Menu, specifically in the AllianceSlot frames to make it more dynamic and not having to create another custom menu that fills the screen, the thing is the alliance slot are labeled from 0 to 23 but they are not asigned to their respective player with that id (I mean the AllianceSlot_0 is not necessarly asigned to the Player 0), they are asigned based on the order their ids but excluding the local player, (it means that for example for the player 2 the AllianceSlot 0 and 1, will be asigned to the players 0 and 1 respectively but the AllianceSlot 2 is asinged to the Player 3 and the AllianceSlot 3 for the Player 4 and so on, because the player 2 is not visible in the allies menu of the player 2).
I made this script to correctly asign them and it worked, but when I click them I cause a desync, and I have understood that a frame can have a different parent or frame points between players without a desync, can you tell me what should I do?
I made this script to correctly asign them and it worked, but when I click them I cause a desync, and I have understood that a frame can have a different parent or frame points between players without a desync, can you tell me what should I do?
Lua:
Debug.beginFile("SpectAlly")
OnInit.final(function ()
--Require "FrameLoader"
--Require "PlayerUtils"
local slots = {}
--FrameLoaderAdd(function ()
BlzFrameClick(BlzGetFrameByName("UpperButtonBarAlliesButton", 0))
BlzFrameClick(BlzGetFrameByName("AllianceCancelButton", 0))
for i = 0, bj_MAX_PLAYER_SLOTS - 1 do
-- To create their handles
BlzGetFrameByName("AllianceSlot", i)
BlzGetFrameByName("PlayerNameLabel", i)
local p = Player(i)
if GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController(p) == MAP_CONTROL_USER then
slots[p] = __jarray(bj_MAX_PLAYER_SLOTS - 1)
local s = 0
for j = 0, bj_MAX_PLAYER_SLOTS - 1 do
local p2 = Player(j)
if GetPlayerSlotState(p2) == PLAYER_SLOT_STATE_PLAYING then
if p ~= p2 then
slots[p][p2] = s
s = s + 1
end
end
end
end
end
for i = 0, bj_MAX_PLAYER_SLOTS - 1 do
local p = Player(i)
if GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING --[[and GetPlayerController(p) == MAP_CONTROL_USER]] then
print(slots[GetLocalPlayer()][p])
local slot = BlzGetFrameByName("AllianceSlot", slots[GetLocalPlayer()][p])
local label = BlzGetFrameByName("PlayerNameLabel", slots[GetLocalPlayer()][p])
local text = BlzCreateFrame("ScriptDialogButton", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), 0, 0)
BlzFrameSetParent(text, slot)
BlzFrameSetPoint(text, FRAMEPOINT_TOPRIGHT, label, FRAMEPOINT_TOPRIGHT, -0.01, 0.005)
BlzFrameSetPoint(text, FRAMEPOINT_BOTTOMRIGHT, label, FRAMEPOINT_BOTTOMRIGHT, -0.01, -0.005)
BlzFrameSetPoint(text, FRAMEPOINT_LEFT, label, FRAMEPOINT_RIGHT, -0.06, 0.)
BlzFrameSetText(text, "See")
BlzFrameSetTextAlignment(text, TEXT_JUSTIFY_CENTER, TEXT_JUSTIFY_MIDDLE)
BlzFrameSetLevel(text, 4)
BlzFrameSetVisible(text, GetLocalPlayer() ~= p)
local t = CreateTrigger()
BlzTriggerRegisterFrameEvent(t, text, FRAMEEVENT_CONTROL_CLICK)
TriggerAddAction(t, function ()
print(GetPlayerName(p))
end)
end
end
--end)
local t = CreateTrigger()
TriggerRegisterPlayerChatEvent(t, Player(0), "r ", false)
TriggerAddAction(t, function ()
local sl = tonumber(GetEventPlayerChatString():sub(3))
RemovePlayer(Player(sl), PLAYER_GAME_RESULT_DEFEAT)
end)
end)
Debug.endFile()