Results 1 to 4 of 4

Thread: cod2 download data from mysql

  1. #1
    Private First Class
    Join Date
    Feb 2013
    Posts
    201
    Thanks
    4
    Thanked 10 Times in 7 Posts

    cod2 download data from mysql

    hello i try edit script for downloading data from mysql.
    when i trying download player stats [ rank etc...], script download another table.

    PHP Code:
    dane_gracza()
    {
        
    host getcvar("mysql_host");
        
    user getcvar("mysql_user");
        
    pass getcvar("mysql_pass");
        
    db getcvar("mysql_db");
        
    port getcvarint("mysql_port");
        
        
    mysql mysql_init();
        
        if ( ! 
    isDefined(mysql))
        {
            
    iprintln("^1mysql not defined!");
            return;    
        }    
        
        
    ret mysql_real_connect(mysqlhostuserpassdbport);
        if (!
    ret)
        {
            
    iprintln("^1errno="+mysql_errno(mysql) + "^3 error=''"+mysql_error(mysql) + "''\n");
            
    mysql_close(mysql);
            return 
    0;
        }      
        
    theQuery "SELECT * FROM cod2_users WHERE username = 'czolg'";                    
        
       
    iprintln("^1"+theQuery);
        
        
    ret mysql_query(mysqltheQuery);
        if (
    ret != 0)
        {
            
    iprintln("^1errno="+mysql_errno(mysql) + "^7 error=''"+mysql_error(mysql) + "''\n");
            
    mysql_close(mysql);
            return 
    0;
        }
        
        
    result mysql_store_result(mysql);
        
        
    iprintln("^3num_rows="+mysql_num_rows(result) + "^9 num_fields="+mysql_num_fields(result)+"\n");
        
        
    mysql_field_seek(result0);
        while (
    1)
        {
            
    result_name mysql_fetch_field(result);
            if (!
    isString(result_name))
                break;
                
            
    iprintln("^4field-name=" result_name+"\n");
        }
        
        while (
    1)
        {
            
    row mysql_fetch_row(result);
            if (!
    isDefined(row))
            {
                
    //std\io::print("row == undefined\n");
                
    break;
            }
            
    output "";
            for (
    i=0i<row.sizei++)
                
    output += row[i] + " ";
            
    std\io::print(output+"\n");
        }
        
        
    mysql_free_result(result);
        
        
    mysql_close(mysql);

    Click image for larger version. 

Name:	db.png 
Views:	69 
Size:	4.9 KB 
ID:	842Click image for larger version. 

Name:	sh.png 
Views:	71 
Size:	33.7 KB 
ID:	844
    Last edited by malyczolg; 15th February 2015 at 15:11.

  2. #2
    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
    Replace

    Code:
    std\io::print(output+"\n");
    with

    Code:
    printf(output+"\n");
    And replace your old std-files with these: https://github.com/kungfooman/cod2_std
    timescale 0.01

  3. #3
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    Quote Originally Posted by kung foo man View Post
    Code:
    printf(output+"\n");
    And replace your old std-files with these: https://github.com/kungfooman/cod2_std
    Or use printfline (it automatically adds a \n).

  4. #4
    Private First Class
    Join Date
    Feb 2013
    Posts
    201
    Thanks
    4
    Thanked 10 Times in 7 Posts
    work , thanks guys

Posting Permissions

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