Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×

SKO85

Member
  • Content Count

    5
  • Joined

  • Last visited

  • Medals

Community Reputation

0 Neutral

About SKO85

  • Rank
    Rookie
  1. Ok, I finally got it working. I have the following now and this seems to work great. For the noobs like me out there :) This is my test.sqf which is called in init.sqf. // Wait untill waitUntil {time > 0}; // Executed by Server. if (isDedicated) then { "packetTest" addPublicVariableEventHandler { _pcid = owner (_this select 1 select 0); _number1 = _this select 1 select 1; _number2 = _this select 1 select 2; _thesum = _number1 + _number2; packetTest = _thesum; _pcid publicVariableClient "packetTest"; }; }; // Executed by client only. if (!isDedicated && !isServer) then { sumNum = 0; "packetTest" addPublicVariableEventHandler { _thesum = _this select 1; hint str _thesum; }; systemChat "Debug: Loaded client packetTest handler."; }; In init.sqf I do: [] execVM "test.sqf"; The on-click script that triggers the call to the server is a separated file which i call whenever I press an action menu item: waitUntil {time > 0}; packetTest = [player, 22, sumNum]; publicVariableServer "packetTest"; sumNum = sumNum + 1; systemChat "Debug: Hit Test Script click."; You see that I increase the sumNum with +1 everytime I call the publicVariableServer. If you pass the same value all the time (so not chaning the publicVariable packetTest), the server-side handler will only be triggered once as the variable is not changing. At least this was so in my case. A good reference that helped me out: http://killzonekid.com/arma-scripting-tutorials-basic-multiplayer-coding/ I hope this helps someone. Cheers, SKO85
  2. Hi kylania, Thanks for the explaination. That makes sence. This is my use-case and what I am trying to do in the final setup. I have an action menu with an item which will need to trigger a call to the server. So I need to call a function on the server from th client. The server function will execute a MySQL Query (I am using Arma2NET with MySQL) and should return a list of items back. I need to call a function on the client from the server code to present it in a dialog, but for testing a HINT will be sufficient. So pseudo code: Server code (PSEUDO, NOT CORRECT SQF): fn_getStuffFromMySQL = { // Get results from MySQL. _results = <execute mysql query and fill results>; // Call client function (callback) and pass results. [_results] <clientCallbackFunc> }; Client code (PSEUDO, NOT CORRECT SQF): // Triggered when I press an item in the Admin Tool for example. my_menuItemAction = { // Execute function on server and collect results from MySQL. [] fn_getStuffFromMySQL; }; // Callback called from server side code. clientCallbackFunc = { hint "GOT SOMETHING FROM SERVER"; }; So basically this is the concept I want to use. I am creating some scripts and dialogs interacting with the MySQL database. For an example I would like to simply use something to send me numbers or text instead of doing complex stuff with MySQL now. So _results from server could be ["THIS IS A MESSAGE FROM SERVER"] or something similar. Is the use-case more clear now? If you need more input, just let me know. Is this the right way of doing this? Do I need to register these functions somehow in the init? [] execVM or something similar? Cheers, SKO85
  3. Thank you both for the quick reply. I have already checked the BIKI's and implemented some examples on the server, but somehow it does not work for me. In some cases it does not go further than the variable definition code or the definition handler. I have put an hint code or sideChat code to let me know that the script is loaded or executed with success, but I dont see those messages. If I remove the publicVariabel lines or handler definition, it shows the hint or sideChat message. It could be that I need to implement a some kind of WAIT call untill the required functions are loaded? I am a C#.NET developer, but quite new at SQF scripting. Is it possible to provide me an example of an init.sqf or other sqf file that is called from init.sqf? Some questions I have at this moment: Do i need to define the publicVariable before I can use it? Which construction is correct to define a server public variable? Example:myServerVar = []; publicVariableServer "myServerVar"; // or... myServerVar = []; publicVariable "myServerVar"; And after I defined the variable, I can define the handler for it? Or the public variable definition is not required for this? "myServerVar" addPublicVariableEventHandler { // Do some server-side coding here... }; Do i need to change my BE filters (add or remove something) to allow the public variable to work? I will check the other links, just in case I missed something. Cheers, SKO85
  4. Hi all, I am new at this point and trying to setup a simple communicatin between client and software. I am using Arma 2 OA, Dayz Epoch Server. I've placed this in an test.sqf file: if(isServer || isDedicated) { // Server? "packetServer" addPublicVariableEventHandler { packetClient = []; publicVariableClient "packetClient"; }; } else { // Client? "packetClient" addPublicVariableEventHandler { hint "MSG FROM SERVER"; }; publicVariableServer = "packetServer"; systemChat "Executed test.sqf"; }; The test.sqf is called within init.sqf like: [] execVM "test.sqf"; Any suggestions? Cheers, SKO85
  5. Will this work on Arma 2 OA? I am having trouble using publicVariableServer/Client commands and also the BIS_fnc_MP seems not to work. Can anyone please provide help how to setup the init.sqf as an example to init the handlers? I am trying to setup a server-client communication for an DayZ Epoch server script. My Example Code: if(isServer || isDedicated) { // Server? "packetServer" addPublicVariableEventHandler { packetClient = []; publicVariableClient "packetClient"; }; } else { // Client? "packetClient" addPublicVariableEventHandler { hint "MSG FROM SERVER"; }; publicVariableServer = "packetServer"; systemChat "Executed test.sqf"; }; Cheers, SKO85
×