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

Lua Chest System Problem

beenii

Well-Known Member
Joined
Jul 26, 2010
Messages
580
Solutions
1
Reaction score
57
unique.png


have this error:
image.png


then in game only have one chest with Unique ID 3000
image.png


how fix?
in game.cpp i find this:
Code:
Item* Game::getUniqueItem(uint16_t uniqueId)
{
    auto it = uniqueItems.find(uniqueId);
    if (it == uniqueItems.end()) {
        return nullptr;
    }
    return it->second;
}

bool Game::addUniqueItem(uint16_t uniqueId, Item* item)
{
    auto result = uniqueItems.emplace(uniqueId, item);
    if (!result.second) {
        std::cout << "Duplicate unique id: " << uniqueId << std::endl;
    }
    return result.second;
}

void Game::removeUniqueItem(uint16_t uniqueId)
{
    auto it = uniqueItems.find(uniqueId);
    if (it != uniqueItems.end()) {
        uniqueItems.erase(it);
    }
}

i try delete:
  1. auto it = uniqueItems.find(uniqueId);
  2. if (it != uniqueItems.end()) {
  3. uniqueItems.erase(it);
  4. }
but dont work, have same result
 
Open up your map in Remere's Map Editor and search for all unique ids and see if there are duplicated unique ids. If not, only thing that comes to mind is that you have some script adding unique ids to the server while starting/live
 
no, he has to use a custom script with ActionId the same and unique ID different for each chest.
aid =2000,2000,2000
uid =3000,3001,3002


By the way.. what's stopping a player from picking up that sword?
 
no, he has to use a custom script with ActionId the same and unique ID different for each chest.
aid =2000,2000,2000
uid =3000,3001,3002
By the way.. what's stopping a player from picking up that sword?

Yes, the idea was that they could only choose a weapon, but already modify the script to do that function.

and what prevents the player from grabbing that sword is actionid 8000.

-- No move items with actionID 8000
NOT_MOVEABLE_ACTION = 8000

in events\scripts\player.lua

Code:
    -- No move items with actionID 8000
    if item:getActionId() == NOT_MOVEABLE_ACTION then
        self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
        return false
    end



Open up your map in Remere's Map Editor and search for all unique ids and see if there are duplicated unique ids. If not, only thing that comes to mind is that you have some script adding unique ids to the server while starting/live

thanks for your suggestion, I already solved it by modifying the script
 
Back
Top