Results 1 to 5 of 5

Thread: Convert playerstats from scriptdata to mysql table

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Had the same problem once, you might be able to pick what you need:

    PHP Code:

    <?php
        
    echo "scriptdata2mysql by 123123231 29.05.2013\n";
        
        
    mysql_connect("127.0.0.1:3306""root""asd");
        
    mysql_select_db("cod2_test");

        
    $numFiles 0;
        
    $numStats 0;
        
    $numErrors 0;
        
        foreach (
    glob("*.serverstats") as $filename)
        {
            
    $guid substr($filename0, -strlen(".serverstats"));
            
    $content file_get_contents($filename);
            
            
    $stats explode("\n"$content);
            
            foreach (
    $stats as $stat)
            {
                
    $tmp explode(","$stat);
                
    $n count($tmp) . " ";
                if (
    $n != 3)
                    continue;
                
    $key $tmp[0];
                
    $value $tmp[1];
                
    //echo "$n $guid $key => $value\n";
                
                
    mysql_query("INSERT INTO `stats` (`guid`, `key`, `value`) VALUES ($guid, '$key', '$value')");
                
                if (
    mysql_error())
                {
                    echo 
    mysql_error() . "\n";
                    
    $numErrors++;
                }
                
    $numStats++;
            }
            
    $numFiles++;
        }
        
        echo 
    "Done! Files=$numFiles Stats=$numStats Errors=$numErrors\n";
    timescale 0.01

  2. The Following User Says Thank You to kung foo man For This Useful Post:

    Ni3ls (8th May 2019)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •