• 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!

clean script only for a particular item

Morcega Negra

Banned User
Joined
Aug 4, 2015
Messages
102
Solutions
1
Reaction score
8
how I do a global event that the clean in just a particular item?
I would like to have a clean only item id 7636
but like a normal clean, just clean the items from the floor,
not clean these items in protection zone
 
if you only want to clean single items then I suggest to use onMoveItem function to register item positions.
Later you can use these positions or pointers to clean the items.

position can be tile (the easiest and best thing to track and manipulate)
map containers (a bit trickier but not too hard)
player bag (you don't rly want to go that deep with lua)
player depot (use lua at your own risk)
 
If you want go about doing this by source editing you need to edit this part of game.cpp
Code:
void Game::cleanMapEx(uint32_t& count)
 
If the interested one doesn't even post the server and client version we won't advance further.
 
If the interested one doesn't even post the server and client version we won't advance further.
I'd like to know how to achieve this same feature (TFS 1.2, 10.9) I don't want to clean the item, I want to move a particular item to pos on clean.
 
Ok, so i got this:
Code:
local map = {     -- map
fromX = 30,
fromY = 30,
fromZ = 7,
--------------
toX = 220,
toY = 180,
toZ = 7,
}

function onSay(cid, words, param)
    local clean = 0
    if clean == 0 then
        for x = map.fromX, map.toX do
            for y = map.fromY, map.toY do
                for z = map.fromZ, map.toZ do
                    local pos = {x=x, y=y, z=z, stackpos = 255}
                    local thing = getThingFromPos(pos)
                    if thing.itemid == 2001 then
                        doRemoveItem(thing.uid)
                    end
                end
            end
        end
        doPlayerSendCancel(cid,"clean item 2001 is done.")
    else
        doPlayerSendCancel(cid,"clean is fail.")
    end
end
Its working, but..
1. its clean only floor 0 (very fast) if i want also clean flor +1 and -1, so i change fromZ to 6 and toZ = 8, then is server lag, and console spam. 1 floor - very fast, and 3 floors very long? hm
2. its clean only if item 2001 is 1st on stack, if its trashed by anything it wont clean. i was try to change stackpos to 254 or 253 but no fix.
3. if i want to add some more items i have to do that like this? :
Code:
if thing.itemid == 2001 or thing.itemid == 2002 or thing.itemid == 2003 or thing.itemid == 2004 or thing.itemid == 2005 then
or is some better style?
 
I'd like to know how to achieve this same feature (TFS 1.2, 10.9) I don't want to clean the item, I want to move a particular item to pos on clean.
map.cpp
change
Code:
for (Item* item : *itemList) {
    if (item->isCleanable()) {
        toRemove.push_back(item);
    }
}
to
Code:
Tile* toPosition = getTile(33553, 32555, 7);
for (Item* item : *itemList) {
    if (item->getID() == 2392) {
        g_game.internalMoveItem(item->getParent(), toPosition, INDEX_WHEREEVER, item, item->getItemCount(), nullptr, FLAG_NOLIMIT);                           
    }
    else {
        if (item->isCleanable()) {
            toRemove.push_back(item);
        }
    }
}
relocates Fire Swords to Roshamuul
 
Tile* toPosition = getTile(33553, 32555, 7); for (Item* item : *itemList) { if (item->getID() == 2392) { g_game.internalMoveItem(item->getParent(), toPosition, INDEX_WHEREEVER, item, item->getItemCount(), nullptr, FLAG_NOLIMIT); } else { if (item->isCleanable()) { toRemove.push_back(item); } } }
moves all map items as in crates, barrels, trash, etc.. toPosition if I try to use if (item->getID() == 3058, 3059, 3065, 3066) :(
How can I add an array (vector) to this to make this work?
 
Last edited:
moves all map items as in crates, barrels, trash, etc.. toPosition if I try to use if (item->getID() == 3058, 3059, 3065, 3066) :(
How can I add an array to this to make this work?
Code:
Tile* toPosition = getTile(33553, 32555, 7);
std::vector<int> relocateItems = {3058, 3059, 3065, 3066};
for (Item* item : *itemList) {
    bool willRelocate = false;
    for (int relocateItem : relocateItems) {
        if (item->getID() == relocateItem) {
            willRelocate = true;
            break;
        }
    }

    if (willRelocate) {
        g_game.internalMoveItem(item->getParent(), toPosition, INDEX_WHEREEVER, item, item->getItemCount(), nullptr, FLAG_NOLIMIT);
    } else {
        if (item->isCleanable()) {
            toRemove.push_back(item);
        }
    }                           
}
 
how I do a global event that the clean in just a particular item?
I would like to have a clean only item id 7636
but like a normal clean, just clean the items from the floor,
not clean these items in protection zone
you wanna remove the empty vials.
only remove from potion.lua, its a ot. nobody wanna carry these items, only put on shop the potions price. - 5gp
 
If the interested one doesn't even post the server and client version we won't advance further.

Rules for the Support board

We ask you follow these rules and policies exactly as presented below. If you want to read the general rules for this forum (OTLand) you can find them here.
The purpose of these rules is to keep a certain level of civility and order so that people have an easier time helping out.

5. Incomplete Problem Description:
- Post as much useful information as possible. If the problem is about something on your server, post the server version and client version. Also always post the errors you get and the scripts with the problems.
 
Back
Top