Sql, 999 method.

Tai

Member
can anyone with the skills tell me if this is valid.

I have added the following to server_functions.sqf, not sure if thats the best place, essentially I wana have the following sql called on a restart so the database is updated before the server fully starts.

Code:
_key = format["CHILD:999:UPDATE instance_deployable d LEFT JOIN (SELECT DISTINCT d.owner_id, s.unique_id FROM instance_deployable d LEFT JOIN survivor s ON s.id = d.owner_id WHERE s.is_dead =1 ) AS dead ON dead.owner_id = d.owner_id LEFT JOIN survivor live ON live.unique_id = dead.unique_id SET d.owner_id = live.id WHERE live.is_dead =0", dayZ_instance];
_data = "HiveEXT" callExtension _key;
diag_log("SERVER: Updated Build ID's...");

is my syntax correct or am I missing anything ? dont fully understand how this is working just grabbed the _key from another file as it was clear it was calling an sql query..

thanks in advance.

this is for the base building mod, what it will do, or what I am trying to make it do is run this sql every restart which will compile every players buildings down to their current survivor id, making them able to move their buildings even if they died during the previous 3 hours ..

hope thats clear enough for you all.
 
I see you followed my advice.
And it seems to be correct btw .
Iam using a batch file for this sins i have alot of other stuff that needs to be executed before restart .
 
I thot that might be part of the root dayz code, so I guess I am missing something then ?
 
Thats set in init.sqf , I moved my code bellow its decliration around line 14 in that file, is there anything else I need to do ?

Also if its in Init.sqf in mission.pbo will that execute in time so that the updated database values will be taken into account for that play session ?
 
I thot that might be part of the root dayz code, so I guess I am missing something then ?

if your query doesnt check for the dayz Instance you dont need that. Actually, you don't even need a format statement then.

a simple string like

Code:
_key = "CHILD:999:UPDATE instance_deployable d LEFT JOIN (SELECT DISTINCT d.owner_id, s.unique_id FROM instance_deployable d LEFT JOIN survivor s ON s.id = d.owner_id WHERE s.is_dead =1 ) AS dead ON dead.owner_id = d.owner_id LEFT JOIN survivor live ON live.unique_id = dead.unique_id SET d.owner_id = live.id WHERE live.is_dead =0";

is sufficient then.
 
Wait, so couldn't you do this with the mission SQM too? Theoretically making stuff such as the aircraft carrier spawn before vehicles (vehicles in the mission.SQM). That might fix the problem of vehicles spawning on buildings!
 
I see you followed my advice.
And it seems to be correct btw .
Iam using a batch file for this sins i have alot of other stuff that needs to be executed before restart .

any chance you could let me know where you put your code , I want my above to be executed really before the server starts digging into the database, so that when its starting it will run my query, update all the players base building owner id's to their current survivor id, and then start the server so that during that fresh start all players id's are in sync with all their base objects.

cant seem to figure out where to put it, and sadly dont have a test server to test on so when trying this out I either have to keep our server down for ages or just test once every three hours.

thanks for any help in advance.
 
Still unsure where to put this, the places i have tried have not worked..

Just need the code to run once just before a restart is there not a file thats called as the server gets a restart order or something that I can insert this code into.
 
Run it via a SQL query that's triggered by BEC or any another schedule you're running.
 
put it in your init.sqf, before server_monitor is called. Include to wait until your script has finished.
 
Back
Top