Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $host = "localhost"; //The host IP. If the MySQL Server is on the same server as the DayZ Server, leave this as "localhost".
- $user = "username"; //User with SELECT and UPDATE privileges to the DayZ Database.
- $pass = "password"; //Password for user.
- $db = "databasename"; //The databasename of your DayZ Database.
- $port = 3306; // MySQL Server Port. Default is 3306. Only change if you're sure this isn't the port your MySQL Server uses.
- function repairVehicles($array, $host, $user, $pass, $db, $port) {
- $link = mysql_connect($host, $user, $pass, $port);
- if (!$link){
- die('Could not connect: ' . mysql_error());
- }
- mysql_select_db($db);
- foreach($array as &$string) {
- if($string != "[]") {
- $rawstring = $string;
- $string = explode(",", $string);
- foreach($string as $key => $v1) {
- if($key % 2) {
- $rest = explode("]",$v1);
- foreach($rest as $key2 => $v2) {
- if(is_numeric($v2)){
- $v2 = 1;
- }
- }
- $v1 = implode("]",$rest);
- }
- $string[$key] = $v1;
- }
- $string = implode(",",$string);
- $query = "UPDATE instance_vehicle SET parts='$string' WHERE parts='$rawstring'";
- mysql_query($query);
- }
- }
- mysql_close($link);
- }
- $link = mysql_connect($host, $user, $pass, $port);
- if (!$link){
- die('Could not connect: ' . mysql_error());
- }
- mysql_select_db($db);
- $query = mysql_query("SELECT parts FROM instance_vehicle");
- $input = array();
- $index = 0;
- while($row = mysql_fetch_array($query, MYSQL_ASSOC)){
- $input[$index] = $row['parts'];
- $index++;
- }
- mysql_query("UPDATE instace_vehicle SET damage='0'");
- mysql_close($link);
- repairVehicles($input, $host, $user, $pass, $db, $port);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement