Tent duping issue

dayz247

New Member
I couldn't find where anyone had addressed this before, so I figured I would share what I am doing.

To stop people from creating tents, filling with gear, killing their selves, and then always having a place to gear up (because the tents duplicate gear every server restart), I created the following:

deployable_fix.php
Code:
<?php
 
/*
argv values
1 = ip
2 = port
3 = username
4 = password
5 = database name
*/
 
 
// open a mysql connection
$con=mysqli_connect($argv[1] . ":" . $argv[2], $argv[3], $argv[4], $argv[5]);
 
//something went wrong
if (mysqli_connect_errno($con)) {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
 
// get the owner ids from the deployable table
$q1 = mysqli_query($con,"Select id,owner_id from instance_deployable order by id asc");
 
 
//looping through all the deployables
while ($r1 = mysqli_fetch_array($q1)) {
 
    // get the unique_id (so we can change deployable's owner if needed), and whether owner is dead
    $q2 = mysqli_query($con,"Select unique_id,is_dead from survivor where id=" . $r1[1]);
    $r2 = mysqli_fetch_array($q2);
 
    // The owner is dead
    if ($r2[1] == 1) {
 
        // use the unique_id to pull all the owner's instances from survivor table
        $q3 = mysqli_query($con,"Select id,is_dead from survivor where unique_id=" . $r2[0] . " order by is_dead asc");
     
        //loop through all the owner instances and find one that is alive, the first one should be alive but we will just be sure
        while ($r3 = mysqli_fetch_array($q3)) {
         
            // find one that is alive
            if ($r3[1] == 0) {
                // update the deployable item with the new owner id
                mysqli_query($con,"update instance_deployable set owner_id=" . $r3[0] . " where id=" . $r1[0]);
                echo "Corrected deployable: Deployable ID: " . $r1[0] . " New owner ID: " . $r3[0] . " \n";
                break;
            }         
        }
    }
}
 
mysqli_close($con);
 
 
?>

Then add a call to this script from your restart bat file:

Code:
set dbhost= IP
set dbport= port
set dbuser= username
set dbpass= password
set dbname= database
 
.path\to\php.exe path\to\deployable_fix.php %dbhost% %dbport% %dbuser% %dbpass% %dbname%


FYI: This also allows players to repack their old tents even after death.
 
Sorry what exactly?
- Could you please descripe more of how to put this in, e.g where exactly? and which files i need to either create or steal from the @DayZ folder

ect . Share your Server/Mission.pbo with only this in it?
 
This is not included in a pbo.

Instead simply create the first file as described, deployable_fix.php

Then insert the second into your restart.bat file.

The idea is to run the deployable_fix.php on every restart, as this is the script that corrects the incorrect owner issue on tents (also does for all deployables, but those aren't and issue).

For example: i placed deployable_fix.php in the @dayzcc_config\1\bec\config\restart_scripts

Then edited my restart .bat (located in @dayzcc_config\1\bec\config\restart_scripts) to run deployable_fix.php

BEC executes restart.bat every 6 hours on my server (as my configuration).
 
Wonderful. I was working on php scripts and was just going to start this same project.

to clarify for everyone who 'doesnt get it':
This is a php script that runs when the server starts and manipulates the database directly to change the tents owner to the currently alive ID. I suppose I could run this from my servers console but I have a virtual server ($17 per year) which has my backups and scripts running as a cron job.
And being a php file if you have a website, you can actually upload this deplayable_fix.php file to your website and create a link "Click here to update tent owners" which would execute this file.

Thanks!
 
Back
Top