Jump to content

Recommended Posts

Hello,

This is the item remove in my source, it doesn't work when using in my quests

What's its prob ? 

 

    int item_remove(lua_State* L)
    {
        LPITEM item = CQuestManager::instance().GetCurrentItem();

        if(!item || CQuestManager::instance().GetCurrentCharacterPtr() != item->GetOwner())
        {
            lua_pushboolean(L, 0);
            return 0;
        }
        
        int count = (int)lua_tonumber(L, 1);
        
        item->SetCount(item->GetCount() - count);
        lua_pushboolean(L, 1);
        
        return 1;
    }

Link to comment
https://metin2.dev/topic/7714-itemremove-not-working/
Share on other sites

I'm using item.remove() , if i use it like this : item.remove(1) , would it work ?

I want to remove an item from a player depending on its id in the item table.

The item is selected of course , i mean the player drag and drop the item to the npc.

Edited by PeaceMaker
Link to comment
https://metin2.dev/topic/7714-itemremove-not-working/#findComment-48359
Share on other sites

  • Premium

Yes. Use item.remove(1) and it's been working.

Or replace a function to this:

int item_remove(lua_State* L)
    {
        LPITEM item = CQuestManager::instance().GetCurrentItem();

        if(!item || CQuestManager::instance().GetCurrentCharacterPtr() != item->GetOwner())
        {
            lua_pushboolean(L, 0);
            return 0;
        }
        
        item->SetCount(-item->GetCount());
        lua_pushboolean(L, 1);
        
        return 1;
    }

  • Love 1
Link to comment
https://metin2.dev/topic/7714-itemremove-not-working/#findComment-48393
Share on other sites

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.