Jump to content

Refresh vehicle spawn on restart possible?


Sporny

Recommended Posts

im quite sure this shouldnt be a big problem to do on linux.

 

instead of a batch you need a bash or shell to execute the refresh.

 

you have to look up how to access the mysql via bash but the syntax should be almost the same.

 

the only thing which im not sure about is how the restartroutine should look like... 

 

 

To cut it short, he explained it quite well what to do, all you have to do is to check how the commands are difrent in linux and to "translate" it.

Since I dont know them myself without looking them up I cant give you a finished example, sry ;-)

Link to comment
Share on other sites

If I understood it right the cache does simply "save" the database in an excluded file and syncs it from time to time with the "real" database.

Even if this isnt too accurate, I made a lot of changes in the database itself and they all showed up on the server, thats being saied i believe you can ignore the cache files in matter of implementing non locked vehicles.

 

An hole other thing is if it comes down to locked (hive) vehicles, there the cache is indeed important and so far no one figured rly out how to "bypass" it :)

Link to comment
Share on other sites

  • 3 months later...

The cache should not be a problem. Just do the changes in the db when the server is down in a restart.

Thats a part of a script I've used in my server to do cleanup tasks in the db. I guess I've started this from restarter.pl everytime before the server is actually started.

#!/usr/bin/perl
#
use DBI;
use warnings;
use strict;

use constant {
    INSTANCE  => 24,           # Chernarus instance
    DB_NAME   => 'epoch',      # Set database name
    DB_LOGIN  => 'your_db_user', # Set database login
    DB_PASSWD => 'your_db_user_pass', # Set database password
    DB_HOST   => 'localhost',  # Set database host
    DB_PORT   => 3306,         # Set database port (default 3306)
};

# connect to the db
my $dbh   = connect_to_db();

# Here you call your function for cleanup or whatever
clean_player_login_data();

# disconnect again
$dbh->disconnect;

exit;


#---------------------------------------------------------------------------
# SQL Query Sub-functions
#
sub connect_to_db {
    my $dbh = DBI->connect('dbi:mysql:'.DB_NAME.':'.DB_HOST.':'.DB_PORT, DB_LOGIN, DB_PASSWD,
              {'PrintError' => 1, 'RaiseError' => 1, 'AutoCommit' => 1})
              or die "Can't connect to mysql: $!";
    $dbh->{'mysql_auto_reconnect'} = 1;
    return $dbh;
}


# Clean player_login data older than 2 days
sub clean_player_login_data {
    my $sql = "DELETE FROM `Player_LOGIN` WHERE `Datestamp` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 2 DAY);";
    my $sth = $dbh->prepare ($sql);
    my $res = $sth->execute ();
    $sth->finish;
    return $res;
}

The perl script connects to the db and executes the function, here clean_player_login_data{}. The function called a few lines above. Of course you can create more functions.

The clean_player_login_data function is the example where you need to enter the query you've posted.

You could also have a look at a video I made some time ago which contains some useful sql queries:

" https://www.youtube.com/watch?v=jLLbjWttBZ4 "

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...