//jail

Discussion in 'General' started by loest, Sep 9, 2010.

  1. loest

    loest New Member

    i was wonderin, there will be a command //jailstat [player|target]??

    since now when you jail some one, there is no way to know how much left.
     
  2. FidoW

    FidoW AdvExt64 Customers (IL)

    There is an easy way... querying sqlite, php allow it.

    PHP:
    ## Connecting Depmax DB and getting jailed list
    $db = new db('depmax');
    # Generating sorted array data and list
    $query "SELECT * FROM user_jailed ORDER BY jailed_until";
    $jail_list = array(); $i=0;
    foreach(
    $user_jail $db->do_query($query) as $user) {
      
    $jail_list[$user['char_id']] = array();
      
    $jail_list[$user['char_id']] = array_merge($jail_list[$user['char_id']],$user);
      
    // A list of char_id to be used in a query to gameserver
      
    $char_id_list .= $user['char_id'];
      if(
    sizeof($user_jail)-1>$i$char_id_list .= ",";
      
    $i++;
    }
    unset(
    $db);

    ## Connecting game server DB and merging data
    $db = new db(2);
    $char_name_list $db->do_query("
      SELECT char_id,char_name,lev,
        (CASE WHEN ((login>logout) OR (login IS NOT NULL AND logout IS NULL)) then 'Yes' else 'No' end) as 'online'
      FROM user_data 
      WHERE char_id IN (
    $char_id_list)
    "
    );
    foreach(
    $char_name_list as $char) {  
      
    $jail_list[$char['char_id']] = array_merge($jail_list[$char['char_id']],$char);
      
      
    // Calculating dates
      
    $jail_list[$char['char_id']]['until_date'] = adodb_date("d/m/Y H:i:s",$jail_list[$char['char_id']]['jailed_until']);
      if(
    $jail_list[$char['char_id']]['jailed_until']>2145913200
        
    $jail_list[$char['char_id']]['start_date'] = adodb_date("d/m/Y H:i:s",$jail_list[$char['char_id']]['jailed_until']-999999999);
      else 
    $jail_list[$char['char_id']]['start_date'] = "-Unknown-";  
    }
    unset(
    $db);
    The code is obviouslly incomplete and using a class that made easy the connection to multiples dbs.


    Some functions you may need in order to connect succesfully to sqlite are:
    (im going to copy directly from my db class)

    - connect -
    PHP:
        elseif ($this->CONFIG[$this->server]['sql_type'] == "sqlite") {
          
    $this->dbhandler = new PDO('sqlite:'.$this->CONFIG[$this->server]['dbaddress']);
        }
    - close -
    PHP:
    elseif ($this->CONFIG[$this->server]['sql_type'] == "sqlite") @sqlite_close($this->dbhandler);
    how to query... not hard, but i let you that as your job.
     
    Last edited: Sep 14, 2010
  3. loest

    loest New Member

    yeah, well i could look into sqlite, even using navicat, but the thing is, i would like to be able to that ingame :)
    i mean, when i log some ppl ask me for free them, and some have been in jail for long time, e.g if you make //char_stop and //jail, the jail system won't let them out, and well i guess this is not so hard to be made.

    ps fidow you have done i nice work :D sry if that isn't what i was looking. :D