Jump to content
  • 0
Sign in to follow this  
hambeast

publicVariableEventHandler Client & Server Performance

Question

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: 

"PV_Event_Started" addPublicVariableEventHandler { Event_Started = _this select 1; };
"PV_Match_Started " addPublicVariableEventHandler { Match_Started =  _this select 1; };
"PV_Round_Started " addPublicVariableEventHandler { Round_Started = _this select 1; };

2. Have a single handler for all variables that expects all 3 booleans to be passed at once

"PV_StatusHandler" addPublicVariableEventHandler {
  private ["_packet"];
  _packet = _this select 0;
  Event_Started = _packet select 0;
  Match_Started = _packet select 1;
  Round_Started = _packet select 2;
};

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:

// populate client data
"PV_StatusHandler" addPublicVariableEventHandler {
  private ["_packet"];
  _packet = _this select 1;
  _variableName = _packet select 0;
  _value = _packet select 1;


  // determine what variable we want to update
  switch (_variableName) do {
    case "Event_Started": { Event_Started = _value };
    case "Match_Started": { Match_Started = _value };
    case "Round_Started": { Round_Started = _value };
  };
};

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Ok so here's what I came up with:

 

info: Ok so here we are declaring handlers to handle... our variables.  If PV_IJS_EventStatus is broadcast as a publicVariable, the server and client will both populate their local variables with the value.  what if a client joins after these variables have been set? how do we sync them?  We sync them by calling PV_IJS_JIP_EventStatus as publicVariableServer which only calls the server side handler.  The server in turn broadcasts the values of the event (as defined) back to the client.

 

 

server side, call this whenever a variable we must track on server/client is updated.

// update our variables localy and make sure they populate to the clients.
if (isDedicated) then {
	"PV_IJS_EventStatus" addPublicVariableEventHandler {
		private ["_packet","_variableName","_value"];
		_packet = _this select 1;
		_variableName = _packet select 0;
		_value = _packet select 1;
		
		// assign variable value
		switch (_variableName) do {
			case "Event_Started": { Event_Started = _value };
			case "Match_Started": { Match_Started = _value };
			case "Round_Started": { Round_Started = _value };
		};
	};
};

server side JIP handler:

// handle JIP event status synchronization
if (isDedicated) then {
	"PV_IJS_JIP_EventStatus" addPublicVariableEventHandler {
		private ["_packet","_sender","_senderID"];
		_packet = _this select 1;
		_sender - _packet select 0;
		
		_senderID = owner _sender;
		
		// send Event_Started to JIP client
		PV_IJS_EventStatus = ["Event_Started", Event_Started];
		_senderID publicVariableClient "PV_IJS_EventStatus";
		
		// send Match_Started to JIP client
		PV_IJS_EventStatus = ["Match_Started", Match_Started];
		_senderID publicVariableClient "PV_IJS_EventStatus";
		
		// send Round_Started to JIP client
		PV_IJS_EventStatus = ["Round_Started", Round_Started];
		_senderID publicVariableClient "PV_IJS_EventStatus";
	};
};

client side handler to set variables we get from server:

// retrieve data from server and populate to local variables
if (!isDedicated) then {
	"PV_IJS_EventStatus" addPublicVariableEventHandler {
		private ["_packet","_variableName","_value"];
		_packet = _this select 1;
		_variableName = _packet select 0;
		_value = _packet select 1;
		
		switch (_variableName) do {
			case "Event_Started": { Event_Started = _value };
			case "Match_Started": { Match_Started = _value };
			case "Round_Started": { Round_Started = _value };
		};
	};
};

client side JIP check (bottom of init.sqf)

// handle JIP event status synchronization
if (!isDedicated then {
	private ["_sender"];
	
	PV_IJS_JIP_EventStatus = [_sender];
	publicVariableServer "PV_IJS_JIP_EventStatus";
};

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Similar Content

    • By Kushti
      ***NEW King Kong Overpoch NEVER WIPE|PVP|500K Start|Dedi|SSD|Semi-Mili|VG|Custom Areas/Spawn/Missions|FPS++
      BRAND NEW DATABASE + SERVER 3rd May 2018. Will not wipe!
      Admins are active. We help everyone from getting started to players with 5000 hours experience. 

      We have tonnes of mods including: 
      Auction House

      Custom HUD

      Custom In-game Menu (With Deployable's)

      View Server Rules & Tips, Deploy Vehicles, Virtual Garages, Scan For Nearby Players & AI (1000m) Set View Distance, Toggle Grass & Check Building Location For Plot.
      Parajump Off Buildings.

      Our Map & Events

      Custom Trader Style

      Custom GPS 

      Fake Death


      Plot For Life (Maintain Every 7 Days)

      Base raiding (Blow the door to someone else's base and have some fun)


      Hotwire vehicle

      Global banking
      Tow & Lift

      Campfire dance

       
      Deploy Blast Proof Bunker (Deployables In the In-Game Menu) (Auto Deployable Vehicles + Auto Force Into Vehicles + Turn Engines On Automatically)

      View distance with binoculars/rangefinders

      Suicide bomber
      Virtual Garage

      Custom Spawns/Loadouts




      Custom areas (Castles, Military areas, NEAF)

       

      Custom Traders
      Kozlovka Trader

      Bandit Trader

      Stary Trader

      Klen Trader

      Meat Trader (Not a Safezone)

      Currently updating our very own Devils Castle AI mission.
      & much more!


      Custom mission including drugs bust, veins, gems & more.

      Job System

      New King Kong Custom Mission


      Weather is clear and daytime.
       
      We have Teamspeak: 94.175.108.172
      Discord: https://discordapp.com/invite/bKbQaRh
       
      and Forums:  http://kkoverpoch.co.uk/index.php
       
       
       
       
      Let's stop the talking and just play!
      Server IP: 94.175.108.172:2302
       
       
       
       
       

    • By blueman
      I plan to get a dedicated Epoch server with a host. I have seen in A3 Launcher, game servers running Epoch, with the new Malden map.
      That's what I'd like to do. How do I get that accomplished? Thanks in advance.
    • By Thug
      I have setup many Epoch servers over the past 4 years. All of which were built on old PC's I have.
      Players have no problem getting into game.
      In the past month I built a Dedicated Server  Xeon, Server board, Server memory, etc 
      Installed Windows 2016 essentials on it.
      Set up a game server, one that has dinosaurs in it.    It works!
      Have the same Taviana Epoch server working on a nomal PC, Players can join!
      Now on with my problem
      Installed MySQL for Windows
      Installed all files for the Taviana Epoch Server
      Created a data base called tavi_2365
      Have port forwarded the port of 2365
      Setup new rules for inbound and outbound 2365 in the firewall
      When I start the server all goes as planned
      Server starts up
      Can see the server from my computer
      When I try to join, I get the lobby and click ok
      The loading screen comes up and the first white bar runs as normal
      The second white bar starts and says waiting for server to start authentication
      Then times out at 120 seconds
      On my second monitor I am watching the server load
      It gets to game started and it just sets there
      Database never starts, get the following error in server RPT
       2:09:23 "HIVE: Starting"
       2:09:24 Error in expression <erver_hiveReadWrite;
      _outcome = _result select 0;
      if (_outcome == "PASS") then {>
       2:09:24   Error position: <select 0;
      if (_outcome == "PASS") then {>
       2:09:24   Error select: Type String, expected Array,Config entry
       2:09:24 File z\addons\dayz_server\system\server_monitor.sqf, line 23
      Below are my Server RPT, Client RPT, HiveExt.ini, and server_monitor.sqf
      server RPT
      https://pastebin.com/6M9sG9RB
      client RPT
      https://pastebin.com/9ayVMXjF
      hiveext.ini
      https://pastebin.com/3wx9VDM9
      server_monitor.sqf
      https://pastebin.com/fUnU09Gp
      UPDATE   PROBLEM SOLVED
      Had to install all of the Visual C++  from 08 to 17   they were a little hard to find, but I did it.    Thanks to all that helped me.   @juandayz @icomrade  and more
      below is a pic of what I had to install to get it to work
      https://dl.dropboxusercontent.com/u/487376647/MS Visual C.PNG
      Here is a link to my drop box for a .rar and a .zip for all the MS Visual C++ that I used to get my dedicated server working.
      https://dl.dropboxusercontent.com/u/487376647/All Microsoft Visual C%2B%2B Redistributables.rar
      https://dl.dropboxusercontent.com/u/487376647/All Microsoft Visual C%2B%2B Redistributables.zip
    • By Gabriel12237
      Hello Community i need help .

      Sorry for my bad english. Im from germany and i need help.

      I Have Advanced trading and Single currency 3.0 (without global banking) from zupa, and when i sell or buy in the normal trading menu , the trader dont use coins from me. With advanced trading menu the trader use coins for the item.

      Pls help me.

      Thx
    • By Hoplox
      Hey, just something I've been wondering for a while, what would be the best specs to host ARMA 2 servers on? Currently i'm hosting on OVH MC-32 with the current specs:
      We're currently looking to upgrade to a server with better specs but i'd like to ask everyone what specs are you running and what kind of performance are you getting? I've been told a few times using a normal home CPU such as our current one instead of a E3 / E5 server CPU is not recommended but I've also heard the higher the clock speed the better the performance depending on single core stats. What are you opinions?
      Thanks.
  • Advertisement
  • Supporters
  • Discord

×
×
  • Create New...