Pulling data from SQL table in script

I haven't Sarge, I'm fairly new to this unfortunately and wasn't aware that extra debugging options were available. That would be very helpful in trying to find a resolution to it. Could you point me in the direction of tutorials to do so?


Look in your HiveExt.ini for "Level" you can set it to

trace, debug, information, notice, warning, error, critical, fatal, none

trace would give you the most detailed output maybe even too much info, naturally you only want to use it when debugging.
 
Apparently I'm going to have some difficulty doing so, my host prevents access to that and a few other files =/

Is there any other way around it or anything else I can try that anybody is aware of?
 
I've submitted a ticket to see if I can get the FTP permissions changed for that file, or have them edit it. All I'm getting at the moment in arma2oaserver.RPT is the following:
20:44:42 Server: Object 3:82 not found (message 94)
20:45:03 Server: Object 3:84 not found (message 94)
20:47:14 Server: Object 3:94 not found (message 94)
Does that mean anything to anyone? I get one additional line every time my script triggers, absolutely every time, tough the numbers vary, always incrementally higher each time.
 
Hi Sarge & all,

I've probably taken this a bit to the extreme, but my existing host would not allow me to edit hiveext.ini so I've purchased and set up a second server and deployed my script. I've set the debug level to trace as requested.

The issue now is that I'm getting no more information than previously, or more specifically, NO information. there's not a single line in HiveEXT.log that correlates to the time that the scripts run.

In ArmA2OA.RPT on my local machine I get the following each time I try to run the script:
"QUAN DEBUG: Value of _key: CHILD:999:select allowed_player_guid from player_domes WHERE id=1"
"QUAN DEBUG: Value of _result: any"
"QUAN DEBUG: Value of _status: any"
"QUAN DEBUG: Value of _result: any"
"QUAN DEBUG: Value of whitelist: any"

In ArmA2OAServer.RPT on the server I get the following each time I try to run the script (the timestamp and the numbers after "Object" alter each time):
6:57:00 Server: Object 3:53 not found (message 94)

Now to my mind, if there's nothing at all in HiveExt.log, surely that means that there's something wrong with the function I'm using to invoke the .dll. The entire script is here, this is it from the top line, and all that's missing at the bottom is more text and my kick and setpos.

Code:
// Define location that invader will be teleported to
_destination = [14133,13930,0];
 
// Define owner of the dome to reference the database table for the whitelist
_dome_id = 1;
 
// define query
_key = format["CHILD:999:select allowed_player_guid from player_domes WHERE id=%1", _dome_id];    // format the sql call for the hiveext.dll
diag_log format["QUAN DEBUG: Value of _key: %1",_key];
_result = _key call server_hiveReadWrite;  // execute the hive call
diag_log format["QUAN DEBUG: Value of _result: %1",_result];
 
_status = _result select 0;            // get the status of the result
diag_log format["QUAN DEBUG: Value of _status: %1",_status];
 
if (_status == "CustomStreamStart") then {    //check if the stream coming from the hive was opened
        _val = _result select 1;                  // get the number of entries that will be coming in the stream
        diag_log format["QUAN DEBUG: Value of stream check: %1",_val];
};
 
_result = _key call server_hiveReadWrite;
diag_log format["QUAN DEBUG: Value of _result: %1",_result];
 
_whitelist = _result select 0;            // will contain your actual value
diag_log format["QUAN DEBUG: Value of whitelist: %1",_whitelist];
 
// Identify whether user is permitted
if ((getPlayerUID player) in _whitelist) exitWith {
    titleText ["Welcome to this restricted area. Identity confirmed, enjoy your stay!", "PLAIN", 3]; titleFadeOut 10;
};
 
// If not, action expel messages
titleText ["WARNING - YOU HAVE ENTERED A RESTRICTED AREA.", "BLACK", 3]; titleFadeOut 3;

Is there something I'm missing here? Is there anything I need above the SQL-related part of the script? Do I need to define variables differently or something? I'm struggling to think of things I could have done so wrong as to not show up in HiveEXT.log at all!

Many thanks guys,
A.
 
Right, ok I might be getting somewhere here.

Nobody's allowed to laugh at this next bit please!

I googled the call to see if I could find other examples to compare mine to; when I googled "call server_hiveReadWrite" it presented me with many results, the first of which was a GitHub for server_hiveReadWrite.sqf. I hadn't been aware that the call was of an .sqf all this time.

I have investigated the compile folder of my server.pbo and there's no server_hiveReadWrite.sqf in there, so I'm guessing that's the reason why nothing is showing up in HiveEXT.log and why all of the variables after the call are returning "any".

Can anyone point me in the direction of the best way of installing the .sqf? Does it need to be just popped in that folder or does it need to be mentioned in any other files after doing so?

Many thanks,
A.
 
server_hiveReadWrite is a function within your server_functions.sqf - or at least should be :)
 
Right, so it is... Oh well, there goes that idea...

Could it, do you think, be anything to do with the variable names I've used? Or do I need to define them using "private" to ensure there's no conflict?
 
It would appear not. I've defined all the variables using "private" and prefixed all variable names with a random string to be safe, still the same =/
 
and to me it seems your issue is a different one ...

you need to execute the server_hive_readwrite on the SERVER, not on the client.

IF the condition for the db query is triggered on the clientside, you need something like this:

What i do for my R3F object saving is:

a) have a function on the server that writes to the db
b) have a PublicVariable EH on the Server, that calls that function
c) publish the PublicVariable to the server from the client if a save is needed.

examples (you will need to adjust! and understand em ...)

in publicEH_server.sqf i added:

Code:
// SARGE event handler to save relocated buildings
["SAR_savebuilding",        { (_this select 1) spawn SAR_save2hive; }            ] call registerServerRpc;

in server_functions i reference the sqf file that holds the db writing code:

Code:
SAR_save2hive                = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\SAR_save2hive.sqf";

in my clientfiles there's a file that gets called based on the addaction of a player selecting to save an object (the object_ID is passed to it):

Code:
SAR_savebuilding = _this select 0;
 
publicVariableServer "SAR_savebuilding";


IF your logic should only run on the server, add a

Code:
if(!isServer) exitWith {};

at the top of your code, and make sure your code is called within a server environment.

If that code is activated by a trigger (which i assume), you need to go the way that i described above, with PV'ing a variable that the server reacts upon. (reason being is that the trigger activation happens on the clientside)

Getting the value back to your client function is the next challenge ...

I would consider to define and create the trigger on the serverside, write a function to identify which player activated it, run the sql query, compare, and RE the messages that you want to display back to the client.

Sarge
 
Now that makes rather perfect sense, and would certainly explain why I'm seeing nothing in HiveEXT.log on the server lol.

I think the above is probably way over my head in terms of my scripting competency, but perhaps another approach. Your thoughts if you would;

The way I see it, I don't need to hand anything up to to the DB, the only reason that's the context we're looking at is because up to now the fact that this would be actioned client side had never occurred to me. What we're talking about here is a script that works perfectly if the UIDs I want are hard-coded into it. All I want is to add a convenience factor so that I don't have to unpack and repack PBOs every time I want to add or remove a person.

As you rightly said, this is triggered by a trigger in mission.sqm;
Code:
    class Sensors
    {
        items=1;
        class Item0
        {
            position[]={9999,0,9999};
            a=200;
            b=200;
            activationBy="ANY";
            repeating=1;
            interruptable=1;
            age="UNKNOWN";
            name="quandru_dome";
            expCond="(vehicle player) in thislist;";
            expActiv="quandru_dome = [] execVM ""domes\quandru_dome.sqf"";";
            expDesactiv="terminate quandru_dome; titleText [""You are leaving the restricted area, be safe out there!"", ""PLAIN"", 3]; titleFadeOut 5;";
            class Effects
            {
            };
        };
    }
I assume the way the trigger works is that the trigger too is looked for and executed client-side, having had mission.sqm downloaded when the user logs on.

Would an easier approach be to define somewhere a global variable, write something server-side which populates that global variable (even if it was only once when the server starts or something that'd be fine), and then have the script reference that global variable on the server rather than a locally defined one? Would that work?

I understand this would limit functionality slightly in that the whitelist would only update on a server restart, but that wouldn't matter so much. It still leaves the convenience of editing through SQL and leaving it to take effect after next scheduled restart :)
 
Try the following approach:

on the server, run a script that populates an array with the values for "Triggername/id whatever" "whitelisted UIDs" for all your triggers.

publicvariable this array.

Then access in your client script this global array and filter for the needed trigger.

I recommend to read this one:

http://killzonekid.com/category/games/arma-2/

This is one of the best resources you can find in regards of Arma 2 scripting.

cheers, Sarge
 
Wow, right, outstanding resource!

In one of his tutorials (I read fast) he mentions defining global variables in init.sqf but am I right in thinking that won't solve my problem? init.sqf seems also to be inside the mission.pbo structure and won't do what I want therefore either.

I'm guessing I'd need to write a script to go into the init folder in the server.pbo, define a variable and do the SQL pull there, and publicvariable the resulting array? Does everything in the init folder of server.pbo get run on startup?
 
what you can do is add your script to init.sqf, within a isdedicated or isserver section.

i personally would populate your global array in server_monitor.sqf and broadcast it from there. (or call your script from server_monitor.sqf, preferably after your vehicles and objects were spawned.

Sarge
 
first, in your HiveExt.ini you must use trace debug logging to log ALL queries.

second,
CHILD:999:select allowed_player_guid from player_domes WHERE id=%1

is wrong.

CHILD:999:select allowed_player_guid from player_domes WHERE id=%1:[]:

is correct

Third, there is a chance if your have quotes in the data returned that it can mess up the format command:

diag_log format["QUAN DEBUG: Value of _result: %1",_result];
 
Hi there,

I ran into same problems as you guys

I try to fix the problem of the BaseBuilding Mod that shifting Objects will change their Code as the Code is tied to the ObjectUID. The ObjectUID isn't read from the database but rather calculated via the function.

Code:
_worldspace call dayz_objectUID2

I think we could fix this if we get the ObjectUID from the database cause it doesn't change there, the only thing which changes when a objects shifts is the coordinates (worldspace).

So I'm completely new at this CHILD thing and I need to throw it into the servermonitor, that on every restart all objects will be updated with the ObjectUID out of the database.

Code:
_key = format["CHILD:999:select ObjectUID from Object_data where instance_id = ?:[%1]:", dayZ_instance];    // format the sql call for the hiveext.dll call for the hiveext.dll
diag_log format["KIKYOU DEBUG: Value of _key: %1",_key];
_result = _key call server_hiveReadWrite;  // execute the hive call
diag_log format["KIKYOU DEBUG: Value of _result: %1",_result];
 
_status = _result select 0;            // get the status of the result
diag_log format["KIKYOU DEBUG: Value of _status: %1",_status];
 
if (_status == "CustomStreamStart") then {    //check if the stream coming from the hive was opened
_val = _result select 1;                  // get the number of entries that will be coming in the stream
diag_log format["KIKYOU DEBUG: Value of stream check: %1",_val];
};
 
_result = _key call server_hiveReadWrite;
diag_log format["KIKYOU DEBUG: Value of _result: %1",_result];
 
_ouid = _result select 0;            // will contain your actual value
diag_log format["KIKYOU DEBUG: Value of _ouid: %1",_ouid];
 
_object setVariable ["ObjectUID", _ouid, true];

Will it maybe work like that? I'm really not sure how to format this to get the ObjectUID ;)
Code:
_key = format["CHILD:999:select ObjectUID from Object_data where instance_id = ?:[%1]:", dayZ_instance];

Thanks!
 
I'm running into same problem as you Andy Murtagh but the function is integrated into my server_monitor.sqf which is inside the server.pbo. So I don't think that the problem is the execution from client side

Code:
18:58:12 "KIKYOU DEBUG: Value of _result: <null>"
18:58:12 "KIKYOU DEBUG: Value of _ouid: any"

Thats what I see after the above posted code. Is there any mistake I made?

Thanks! :)

Edit: The HiveExt.log says that 999 isn't valid so I think the Epoch Hive has no 999, too :/
 
I want to change the SurvivorID of a tent.

Anyone an idea why this will not work ?
its a script calles from mission.pbo

I dont get any logging info about this. Set logging to trace.

Code:
private["_objectUID","_obj","_result"];
 
_obj = _this select 3;
_objectUID    = _obj getVariable["ObjectUID","0"];
_survivorID    = dayz_characterID;
 
//Take ownership client side (working)
_obj setVariable ["characterID",dayz_characterID,true];
 
//get some more info
cuttext [format ["ObjectUID: %1",_objectUID],"PLAIN DOWN",2];
sleep 3;
cuttext [format ["survivorID: %1",_survivorID],"PLAIN DOWN",2];
sleep 3;
 
//The important part
_key = format["CHILD:999:UPDATE `instance_deployable` SET `owner_id` = ?:[%1]: WHERE `unique_id` = %2",_survivorID,_objectUID];
cuttext [format ["sqlquery: %1",_key],"PLAIN DOWN",2];
sleep 3;
//_key = format["CHILD:999:UPDATE `instance_deployable` SET `owner_id` = %1 WHERE `unique_id` = %2",_survivorID,_objectUID];
//_result =_key call server_hiveWrite;
_key call server_hiveReadWrite;
sleep 3;
//_object setVariable ["needUpdate",false,true];
cuttext ["Owned tents dont despawn as long you are alive.","PLAIN DOWN",2];
sleep 3;
cuttext [format ["result: %1",_result],"PLAIN DOWN",2];




Ive found this:
//DbName in TBLNAME is either Character or Object
//The requested Table must be previously-enabled for custom data queries through HiveExt.ini

How can i set this and do i need this for 999 too ?

ive tried _key = "CHILD:999:UPDATE `instance_deployable` SET `owner_id` = 100 WHERE `unique_id` = 72899232342 too. It just dont do anything.
 
Okay, get it to work with a publiceventhandler.

now i get:

13:29 HiveExt: [Error] Error executing |CHILD:998:UPDATE `instance_deployable` SET `owner_id` = 100 WHERE `unique_id` = "98606189280335"|
 
998 ? that one is bugged, you should use 999. Or did the hiveext.dll rewrite your request ?
 
Back
Top