I am trying to code a GUI with buttons that Set the class for the player. However my Custom Player object is not found when I try it out although it works when I press a button to assign the class:
ClassSetter(Agent:agent):void=
if(IsAgent:agent = agent[Agent]):
if(CP:CustomPlayer = PlayersMap[Agent]):
CP.SetClass(6)
Print("Class Set")
else:
Print("Player is not a custom object")
(This was in the Game Manager Script)
In the Script of the UI I have the following code to send the agent to the function:
Interface := class():
var MainCanvas : canvas = canvas{}
var AbilityButton1 : button_loud = button_loud{}
var AbilityButton2 : button_loud = button_loud{}
var AbilityButton3 : button_loud = button_loud{}
var GM: game_manager = game_manager{}
ToMessage<localizes>(String : string) : message = "{String}"
AddUI(Agent:agent):void=
if(Player := player[Agent],PlayerUI := GetPlayerUI[Player]):
set MainCanvas = CreateUI()
PlayerUI.AddWidget(MainCanvas, player_ui_slot{InputMode := ui_input_mode.All})
AbilityHandler(Message : widget_message):void=
Player := Message.Player
if(PlayerUI := GetPlayerUI[Player]):
PlayerUI.RemoveWidget(MainCanvas)
if(Agent:agent = agent[Player]):
GM.ClassSetter(Agent)
I am really confused because I am using the same code and don’t understand why it wouldn’t work, also sorry for bad formatting, I am writing on my phone at 1:30 AM
I would really appreciate it if some1 could help me, thanks in advance