Terrabull
Veteran Member (Done that)
- Reaction score
- 38
I am using ShareEverythingWithTeam to allow people to control their teammates if the spots are empty. I also have a custom multiboard that shows players special information. When I use ShareEverything the Team Resources multiboard appears, I then set that to LeaverBoard. I am able to hide that and show my custom one again, but I am not able to switch between the two for my users. When I use this code to test it, it says "Multiboard is not set" which is the error message my code gives if the appropriate Leaverboard is set to null. This means that the code assigning Leaverboard is not working correctly for some reason. You can see that I have commented out one set of assign codes, this is because I tried assigning it at multiple parts of the function, and neither of them worked. Any help would be greatly appreciated.
This trigger runs when players type the command to enter 1v1 mode and gain control of their allies.
This function is supposed to switch the multiboard when the player types -switch
Strangely, when this code runs, the multiboard script worked (at least in the last testings.)
This trigger runs when players type the command to enter 1v1 mode and gain control of their allies.
JASS:
function IsUserNotThere takes player testme returns boolean
return GetPlayerController(testme) == MAP_CONTROL_COMPUTER or GetPlayerSlotState(testme) == PLAYER_SLOT_STATE_EMPTY
endfunction
function PeonHall takes nothing returns boolean
return GetUnitTypeId(GetFilterUnit()) == 039;h000039; or GetUnitTypeId(GetFilterUnit()) == 039;h007039;
endfunction
function Explode takes nothing returns nothing
call SetUnitExploded(GetEnumUnit(),true)
call KillUnit(GetEnumUnit())
endfunction
function Trig_One_v_One_Mode_Actions takes nothing returns nothing
local integer i = 0
local player eastblow
local player westblow
local group tg = CreateGroup()
if ((IsUserNotThere(Player(2)) and IsUserNotThere(Player(1))) or (IsUserNotThere(Player(2)) and IsUserNotThere(Player(0))) or (IsUserNotThere(Player(1)) and IsUserNotThere(Player(0)))) and ((IsUserNotThere(Player(5)) and IsUserNotThere(Player(4))) or (IsUserNotThere(Player(5)) and IsUserNotThere(Player(3))) or (IsUserNotThere(Player(4)) and IsUserNotThere(Player(3)))) then
loop
exitwhen i > 5
if IsUserNotThere(Player(i)) then
call ShareEverythingWithTeam(Player(i))
endif
if i < 3 then
set udg_LeaverBoard[0] = bj_lastCreatedMultiboard
else
set udg_LeaverBoard[1] = bj_lastCreatedMultiboard
endif
set i = i + 1
endloop
if SubString(GetEventPlayerChatString(),4,5) == "2" then
if IsUserNotThere(Player(2)) then
set westblow = Player(2)
elseif IsUserNotThere(Player(1)) then
set westblow = Player(1)
endif
if IsUserNotThere(Player(5)) then
set eastblow = Player(5)
elseif IsUserNotThere(Player(4)) then
set westblow = Player(4)
endif
call GroupEnumUnitsOfPlayer(tg,eastblow,Condition(function PeonHall))
call ForGroup(tg,function Explode)
call GroupClear(tg)
call GroupEnumUnitsOfPlayer(tg,westblow,Condition(function PeonHall))
call ForGroup(tg,function Explode)
endif
// call EnableTrigger(gg_trg_Switch_Board)
call DisplayTextToPlayer(GetLocalPlayer(),0,0,"1v1 Mode Initiated.")
// if GetPlayerId(GetLocalPlayer()) < 3 then
// set udg_LeaverBoard[0] = bj_lastCreatedMultiboard
// else
// set udg_LeaverBoard[1] = bj_lastCreatedMultiboard
// endif
if IsPlayerAlly((GetLocalPlayer()), Player(10)) == true then
call MultiboardDisplay(udg_LeftBoard,true)
elseif IsPlayerAlly((GetLocalPlayer()), Player(11)) == true then
call MultiboardDisplay(udg_RightBoard,true)
else
call MultiboardDisplay(udg_OtherBoard,true)
endif
else
call DisplayTextToPlayer(GetLocalPlayer(),0,0,"There are to many players to initiate 1v1 mode.")
endif
endfunction
//===========================================================================
function InitTrig_One_v_One_Mode takes nothing returns nothing
set gg_trg_One_v_One_Mode = CreateTrigger()
call TriggerRegisterAnyPlayerChatEventDK(gg_trg_One_v_One_Mode, "-1v1", false)
call TriggerAddAction(gg_trg_One_v_One_Mode, function Trig_One_v_One_Mode_Actions)
endfunction
This function is supposed to switch the multiboard when the player types -switch
JASS:
function Trig_Switch_Board_Actions takes nothing returns nothing
call DisplayTextToPlayer(GetLocalPlayer(),0,0,"Multiboard Switch Starting.")
if GetLocalPlayer() == GetTriggerPlayer() then
if GetPlayerId(GetTriggerPlayer()) < 3 then
if IsMultiboardDisplayed(udg_LeftBoard) == true then
if udg_LeaverBoard[0] == null then
call DisplayTextToPlayer(GetLocalPlayer(),0,0,"Multiboard not set.")
else
call MultiboardDisplay(udg_LeftBoard,false)
call MultiboardDisplay(udg_LeaverBoard[0],true)
call DisplayTextToPlayer(GetLocalPlayer(),0,0,"Multiboard switched.")
endif
else
call MultiboardDisplay(udg_LeaverBoard[0],false)
call MultiboardDisplay(udg_LeftBoard,true)
endif
else
if IsMultiboardDisplayed(udg_RightBoard) then
if udg_LeaverBoard[1] == null then
call DisplayTextToPlayer(GetLocalPlayer(),0,0,"Multiboard not set.")
else
call MultiboardDisplay(udg_RightBoard,false)
call MultiboardDisplay(udg_LeaverBoard[1],true)
call DisplayTextToPlayer(GetLocalPlayer(),0,0,"Multiboard switched.")
endif
else
call MultiboardDisplay(udg_LeaverBoard[1],false)
call MultiboardDisplay(udg_RightBoard,true)
endif
endif
endif
endfunction
//===========================================================================
function InitTrig_Switch_Board takes nothing returns nothing
set gg_trg_Switch_Board = CreateTrigger()
call TriggerRegisterAnyPlayerChatEventDK( gg_trg_Switch_Board, "-switch", true )
call TriggerAddAction( gg_trg_Switch_Board, function Trig_Switch_Board_Actions )
// call DisableTrigger(gg_trg_Switch_Board)
endfunction
Strangely, when this code runs, the multiboard script worked (at least in the last testings.)
JASS:
function Cond_New_Leaver takes nothing returns boolean
return IsPlayerObserver(GetTriggerPlayer()) == false
endfunction
function Act_New_Leaver takes nothing returns nothing
local player leaver = GetTriggerPlayer()
// call SetPlayerAllianceStateBJ( Player(1), Player(0), bj_ALLIANCE_ALLIED_ADVUNITS )
call DisplayTextToPlayer(GetLocalPlayer(),0,0,GetPlayerName(leaver) + " has left the game, what a loser.")
call ShareEverythingWithTeam(leaver)
if GetPlayerId(leaver) < 3 then
set udg_LeaverBoard[0] = bj_lastCreatedMultiboard
else
set udg_LeaverBoard[1] = bj_lastCreatedMultiboard
endif
call MultiboardDisplay(bj_lastCreatedMultiboard,false)
if IsPlayerAlly((GetLocalPlayer()), Player(10)) == true then
call MultiboardDisplay(udg_LeftBoard,true)
elseif IsPlayerAlly((GetLocalPlayer()), Player(11)) == true then
call MultiboardDisplay(udg_RightBoard,true)
else
call MultiboardDisplay(udg_OtherBoard,true)
endif
if IsPlayerAlly(leaver,GetLocalPlayer()) then
call DisplayTextToPlayer(GetLocalPlayer(),0,0,"Type -switch to see the Team Resources Board.")
endif
set leaver = null
endfunction
//===========================================================================
function InitTrig_New_Leaver takes nothing returns nothing
local integer i = 0
set gg_trg_New_Leaver = CreateTrigger()
loop
exitwhen i > 5
call TriggerRegisterPlayerEvent(gg_trg_New_Leaver,Player(i),EVENT_PLAYER_LEAVE)
set i = i + 1
endloop
call TriggerAddCondition(gg_trg_New_Leaver,Condition(function Cond_New_Leaver))
call TriggerAddAction(gg_trg_New_Leaver,function Act_New_Leaver)
endfunction