Ok so I'm being a bit ambitious and creating a sweet admin-controlled event system. Been picking AxeCop's brain this weekend and figure I bugged him enough.
For this example, I need to display an admin menu if the following conditions are met (Event_Started = true, Match_Started = true, Round_Started = true)
These variables will be initialized and handled on the server side. However, I need my admins to know the status so that certain menus can be called depending on the status. Aka if I start an event, wait till player slots are assigned before starting match. The variables MUST be broadcast to all JIP and new clients ( I know how to do this so far ), so publicVariableEventHandlers are the best solution for me.
I have two options as I see it to grab these variables.
I think #2 looks cleaner but I feel both solutions are dirty... Passing 3 booleans every time a status updates when I only need to pass 1 is kind of dumb. Feels like too much data being handled would slow things down.
However, having the client handle 3 events vs 1 sounds dirty as well.
My question is mainly which of these methods would work the most efficiently?
Possibly I could branch out #2 to use a switch statement to only update whatever variable is passed to it.
edit: guess I kind of answered my own question. In looking over these options, I feel below is the most elegant of solutions. It requires me to write the least amount of code, handle the least amount of data, and it is modular in that I can use it for more than just this project.
Question
hambeast
Ok so I'm being a bit ambitious and creating a sweet admin-controlled event system. Been picking AxeCop's brain this weekend and figure I bugged him enough.
For this example, I need to display an admin menu if the following conditions are met (Event_Started = true, Match_Started = true, Round_Started = true)
These variables will be initialized and handled on the server side. However, I need my admins to know the status so that certain menus can be called depending on the status. Aka if I start an event, wait till player slots are assigned before starting match. The variables MUST be broadcast to all JIP and new clients ( I know how to do this so far ), so publicVariableEventHandlers are the best solution for me.
I have two options as I see it to grab these variables.
1. Have a separate handler for each variable
ex:
2. Have a single handler for all variables that expects all 3 booleans to be passed at once
I think #2 looks cleaner but I feel both solutions are dirty... Passing 3 booleans every time a status updates when I only need to pass 1 is kind of dumb. Feels like too much data being handled would slow things down.
However, having the client handle 3 events vs 1 sounds dirty as well.
My question is mainly which of these methods would work the most efficiently?
Possibly I could branch out #2 to use a switch statement to only update whatever variable is passed to it.
edit: guess I kind of answered my own question. In looking over these options, I feel below is the most elegant of solutions. It requires me to write the least amount of code, handle the least amount of data, and it is modular in that I can use it for more than just this project.
like this:
Link to comment
Share on other sites
1 answer to this question
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now