AddItem2 help!

Discussion in 'Help' started by Xavier, Jun 24, 2010.

  1. Xavier

    Xavier AdvExt64 Customers (IL)

    Hi!

    Need help with AddItem2 on php for dvampire dll from december 2009 and later.

    I used these function:

    Code:
    function AddItem2($char_id,$item_id,$item_amount,$item_enchant)
    {
    	global $cached_errors;
    	global $cached_ip,$cached_port;
    	global $lin2world;
    	$buf=pack("cVVVVVVVVV",55,$char_id,0,$item_id,$item_amount,$item_enchant,0,0,0,1).tounicode("admin");
    	$cachedsocket=@fsockopen($cached_ip,$cached_port,$errno,$errstr,1) or die($notconnected);
    	fwrite($cachedsocket,pack("s",(strlen($buf)+2)).$buf);
    	$len=unpack("v",fread($cachedsocket,2));
    	$rid=unpack("c",fread($cachedsocket,1));
    	for($i=0;$i<(($len[1]-4)/4);$i++){
    		$read=unpack("i",fread($cachedsocket,4));
    		$rs.=$read[1];
    	}
    	fclose($cachedsocket);
    	return GetError($rs);
    }
    These code occasionaly stoped working and cached returns error:
    [.\adminsocket.cpp][3454] No Admin Id

    Error appears with dvampire dll from december 2009 and later, with earlier versions all works fine.

    Any help will be appreciated.

    tnx/
     
  2. Sawk

    Sawk AdvExt64 Customers (GF/GE/HF)

    Try with that, I had that issue too and fixed it :

    $buf = pack("cVVVVVVVVV", 0x37, $charId, $warehouseType, $itemType, $itemAmount
    , $itemEnchant, $itemEroded, $itemBless, $itemWished, 1);

    and delete the .tounicode("admin"); it should work, I am using that fonction.

    If It doesn't work I will send you the full cached class that I am using.
     
  3. Xavier

    Xavier AdvExt64 Customers (IL)

    Tried your lines.. got same error.

    I've heard AddItem2 packet format changed after december, but not sure about that.

    Will be nice to have a look at your cached class.

    tnx/
     
  4. dVampire

    dVampire Administrator

    AddItem2 packet has new format:
    (d) char_id
    (d) warehouse_id
    (d) ItemType
    (d) Amount
    (d) Enchant
    (d) Damaged
    (d) Bless
    (d) Ident
    (d) Wished
    (d) nAttackAttrType
    (d) nAttackAttrValue
    (d) nDefAttrFire
    (d) nDefAttrWater
    (d) nDefAttrWind
    (d) nDefAttrEarth
    (d) nDefAttrHoly
    (d) nDefAttrUnholy
    (S) comment

    where d - Dword(int), S - unicode string
     
  5. Sawk

    Sawk AdvExt64 Customers (GF/GE/HF)

    This php class wasn't made by me, I am just using it and it works :
    Exemple of use :

    $
    Code:
    
    // Exemple of use
    // Options settings
    $options = array(
        "host" => "your_cached_ip",
        "port" => "your_cached_port",
    );
    
    // Create the new  cached object with the specified options
    $cache = new L2CachedClient($options);
    
    // Catching the error
    try 
    {
    	// Open the connection on the cache object
    	$cache->openConnection();
    } 
    	catch (Exception $e) 
    {
    	var_dump($e);
    }
    
    // Adding the item
    $cache->addItem2($charId, $warehouseType, $itemType, $itemAmount, $itemEnchant, $itemEroded, $itemBless, $itemWished);
    
    // Then you can use the method closeConnection() on $cache when you re done.
    
     
  6. Xavier

    Xavier AdvExt64 Customers (IL)

    Great thanks to dvampire for reply and commenting my issue.
    Now I use this code and it works smooth:

    $buf=pack("cVVVVVVVVVVVVVVVV",55,$char_id,0,$item_id,$item_amount,$item_enchant,0,0,0,1,0,0,0,0,0,0,0).tounicode("admin");





    But I found similar problem with modify_character packet for C6.
    this code works wrong:

    $buf=pack("cVVVVVVV",15,$char_id,$set_sp,$set_exp,$set_karma,$set_pk,$set_pkpardon,$set_duel).tounicode("admin");0,0).tounicode("admin");

    I think modify_character packet is different in C6 too.

    dvampire pleease help!!

    tnx\

    :)
     
  7. dVampire

    dVampire Administrator

    In 1st you put wrong number for AttackAttribType, for none you must put -2 (dont ask me why, its korean tricks)


    In modify_character packet and other packets which has exp field, this field must be 8bytes len, and than your packets must be like this:

    c 15
    d CharID
    d SP
    q Exp
    d Karma
    d PK
    d PKPardon
    d Duel
    S comment

    where d - DWORD(int 4 bytes), q - QWORD(__int64 8 bytes)
     
  8. bioplyn

    bioplyn AdvExt64 Customers (IL)

    I already fixed my problem. Sorry
     
    Last edited: Jan 18, 2011
  9. julioandolfo

    julioandolfo New Member

    First I want to thank you for the clarification, unable to make delivery of item work, is delivering the item to the character.

    however

    The item is coming with attribute, dark elemental +6

    What can it be?