Jump to content
Sign in to follow this  
Sporny

Refresh vehicle spawn on restart possible?

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 ;-)

Share this post


Link to post
Share on other sites

Thats no problem and i will try it on my testserver... but:

 

whats about the cache? the objects sould be deleted there too... or not?

 

i dont really understand the cache folder in linux servers.

Share this post


Link to post
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 :)

Share this post


Link to post
Share on other sites

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 "

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Advertisement
  • Supporters
  • Discord

×
×
  • Create New...