Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Randomly add items to Bazaar merchant each restart
- ### Stores items in merchantlist_temp
- ### Reads items from Bazaar.txt list
- ##################################################################################
- ##################################################################################
- #::: Variables
- $merchant1 = 500000;
- #::: Script Body
- #::: Read database name, user and password from eqemu config file
- read_eqemu_config_xml();
- get_mysql_path();
- #::: Clear previous entries from merchantlist_temp table
- sub read_eqemu_config_xml {
- open (CONFIG, "eqemu_config.xml");
- while (<CONFIG>){
- chomp;
- $o = $_;
- if($o=~/\<\!--/i){
- next;
- }
- if($o=~/database/i && $o=~/\<\//i){
- $in_database_tag = 0;
- }
- if($o=~/database/i){
- print "IN DATABASE TAG\n" if $debug;
- $in_database_tag = 1;
- }
- if ($o=~/<longname>/i){
- ($long_name) = $o =~ /<longname>(.*)<\/longname>/;
- print "Long Name: '" . $long_name . "'/n" if $debug;
- }
- if($in_database_tag == 1){
- @left = split (">", $o);
- @right = split ("<", $left[1]);
- $tag_data = trim($right[0]);
- if($0=~/<username>/i && $in_database_tag){
- $user = $tag_data;
- print "Database User: '" . $user . "'\n" if $debug;
- }
- if($o=~/<password>/i && $in_database_tag){
- $pass = $tag_data;
- print "Database Pass: '" . $pass . "'\n" if $debug;
- }
- if($o=~/<db>/i){
- $db = $tag_data;
- print "Database Name: '" . $db . "'\n" if $debug;
- }
- if($o=~/<host>/i){
- $host = $tag_data;
- print "Database Host: '" . $host . "'\n" if $debug;
- }
- }
- }
- close(CONFIG);
- }
- sub get_mysql_path {
- $has_mysql_path = `echo %PATH%`;
- if($has_mysql_path=~/MySQL|MariaDB/i){
- @mysql = split(';', $has_mysql_path);
- foreach my $v (@mysql){
- if($v=~/MySQL|MariaDB/i){
- $v =~s/\n//g;
- $path = trim($v) . "/mysql";
- last;
- }
- }
- }
- #::: Path not found, error and exit
- if($path eq ""){
- print "[Error:Bazaar.pl] MySQL path not found, please add the path for automatic merchant script to continue... \n\n";
- exit;
- }
- }
- sub get_mysql_result {
- my $run_query = $_[0];
- if(!$db){ return; }
- return `"$path" --host $host --user $user --password="$pass" $db -N -B -e "$run_query"`;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement