• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Next tfs 1.0 question - AID

iSanto

Well-Known Member
Joined
Sep 20, 2011
Messages
157
Reaction score
65
I'm using tfs 1.0.

Why action id , which I had set by function doSetItemActionId(uid, aid) on item in player's backpack, after relogin has been deleted?
Is there any solution on this problem?
 
It's working. Thanks.

No... It's no working. It was working for a while. I don't know why. Is any solutions else?
 
Last edited by a moderator:
Code:
--[[ Moved from TFS 0.4 Dev to TFS 1.0 ]]--


--IDs items
ITEM_SPECIAL_CONTAINER = 23643
ITEM_SETTINGS_CONTAINER = 24301
ITEM_DEVILRY_CONTAINER = 23840
ITEM_OIL_LAMP = 24554

ITEM_EMPTY_DEVILRY_SLOT = 23890

ITEM_DEVILRY_HEALING_0 = 23884
ITEM_DEVILRY_MANA_0 = 23886

local settingsItems = {   
                        [5422] = 24293,
                        [5423] = 24300,
                        [5424] = 24293,
                        [5425] = 24482,
                        [5426] = 24287,
                        [5427] = 24300,
                        [5428] = 24293,
                        [5429] = 24294,
                        [5430] = 24501,
                        [5431] = 24300,
                        [5432] = 24293,
                        [5433] = 24499,
                        [5434] = 24287,
                        [5435] = 24300,
                        [5436] = 24293,
                        [5437] = 24286,
                        [5438] = 24491,
                        [5439] = 24300,
                        [5440] = 24293,
                        [5441] = 24302,
                        [5442] = 24292,
                        [5443] = 24300,
                        [5444] = 24293,
                        [5445] = 24290
                        }

function getTableNumbers(table) local a = 0; for _, x in pairs(table) do a=a+1 end; return a; end;

function onLogin(cid)
   
    if getPlayerStorageValue(cid, 29111) == 1 then
        return true
    end
   
    SPECIALCONTAINER = doPlayerAddItem(cid, ITEM_SPECIAL_CONTAINER, 1, false, CONST_SLOT_AMMO)
    SETTINGS_BP = doAddContainerItem(SPECIALCONTAINER, ITEM_SETTINGS_CONTAINER)
    DEVILRY_BP = doAddContainerItem(SPECIALCONTAINER, ITEM_DEVILRY_CONTAINER)
    OIL_LAMP = doAddContainerItem(SPECIALCONTAINER, ITEM_OIL_LAMP)
   
    Item(SETTINGS_BP):setAttribute("aid", 30100)
    Item(DEVILRY_BP):setAttribute("aid", 30099)
    Item(OIL_LAMP):setAttribute("aid", 30098)
   
       
    for i = 1, 6 do
        doAddContainerItem(DEVILRY_BP, ITEM_EMPTY_DEVILRY_SLOT)
    end
       
    for i=1, getTableNumbers(settingsItems) do
        l=i+5421;
        itemAid = doAddContainerItem(SETTINGS_BP, settingsItems[l])
        Item(itemAid):setAttribute("aid", l)
    end
       
    MANAGAIN0 = doAddContainerItem(DEVILRY_BP, ITEM_DEVILRY_MANA_0)
    Item(MANAGAIN0):setAttribute("aid", DEVILRY_MANAGAIN)
    setPlayerStorageValue(cid, DEVILRY_MANAGAIN, 0)
       
    HEALING0 = doAddContainerItem(DEVILRY_BP, ITEM_DEVILRY_HEALING_0)
    Item(HEALING0):setAttribute("aid", DEVILRY_HEALING)
    setPlayerStorageValue(cid, DEVILRY_HEALING, 0)
    setPlayerStorageValue(cid, DEVILRY_HASTE, 0)
    setPlayerStorageValue(cid, 29111, 1)
   
    return true
end

I think that i found a solution:

Code:
MY_ITEM = doPlayerAddItem(cid, ID)
Item(MY_ITEM):setAttribute("aid", 1000)

It set a AID but after relogin AID is deleting.
But...

Code:
ITEM = player:addItem(2382, 1)
    ITEM:setAttribute("aid", 700)

It set AID and after relogin remains unchanged.

Fell free to use it :D
Thanks for all replying.

Ohmm... I have found a real problem. Before, I have tested it on 2 type of items: movable and unmovable. What have i discovered? Items which are unmovable (but pickupable!) in player's slots or in his containers after relogin loses AID. But.. Normal items which are unmarked "unmovable" in checklist in dat editor, after setting AID by script and after relogin remains with AID.

Is someone who could look in source code where is it encoded? Or perchance fix it.
 
Last edited by a moderator:
here is the fix:
item.cpp
search for:
Code:
bool Item::serializeAttr(PropWriteStream& propWriteStream) const
search this inside:
Code:
if (isMoveable()) {
     uint16_t _actionId = getActionId();
     if (_actionId != 0) {
       propWriteStream.ADD_UCHAR(ATTR_ACTION_ID);
       propWriteStream.ADD_USHORT(_actionId);
     }
   }
replace it with:
Code:
     uint16_t _actionId = getActionId();
     if (_actionId != 0) {
       propWriteStream.ADD_UCHAR(ATTR_ACTION_ID);
       propWriteStream.ADD_USHORT(_actionId);
     }

this will prevent that only moveable items get the actionid set, so it'll set it to all items on loading.
 
Back
Top