Jump to content

Drop on map function


Recommended Posts

Hello, i have function

 

int game_drop_map(lua_State* L)
    {
        LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();

        LPITEM item = NULL;

        PIXEL_POSITION pos;

        long kordx = 0;
        long kordy = 0;

        // Id Itemu
        if (lua_isnumber(L, 1))
        {
            item = ITEM_MANAGER::instance().CreateItem((DWORD)lua_tonumber(L, 1));
        }
        //Kord x
        if (lua_isnumber(L, 2))
        {
            kordx = ((DWORD)lua_tonumber(L, 2));
        }
        // kord y
        if (lua_isnumber(L, 3))
        {
            kordy = ((DWORD)lua_tonumber(L, 3));
        }

        pos.x = kordx;
        pos.y = kordy;

        item->AddToGround(ch->GetMapIndex(), pos);
        item->StartDestroyEvent();
        item->SetOwnership(ch);

        return 0;
    }

 

 

item is on ground, but without ownership. Can you repair this function? 

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

7 minutes ago, avertuss said:

But I need a function that spawns item on which coordinates with the owner.

This should work:

Spoiler

 


int game_drop_map(lua_State* L)
    {
        if (lua_isnumber(L, 1))
        {
            const char * playername = lua_tostring(L, 1);
			LPCHARACTER ch = CHARACTER_MANAGER::instance().FindPC(playername);
        }else{
			sys_err("Need to have player name in first argument!");
			return 0
		}

        LPITEM item = NULL;

        PIXEL_POSITION pos;

        long kordx = 0;
        long kordy = 0;

        // Id Itemu
        if (lua_isnumber(L, 2))
        {
            item = ITEM_MANAGER::instance().CreateItem((DWORD)lua_tonumber(L, 1));
        }
        //Kord x
        if (lua_isnumber(L, 3))
        {
            kordx = ((DWORD)lua_tonumber(L, 3));
        }
        // kord y
        if (lua_isnumber(L, 4))
        {
            kordy = ((DWORD)lua_tonumber(L, 4));
        }
        

        pos.x = kordx;
        pos.y = kordy;

        item->AddToGround(ch->GetMapIndex(), pos);
        item->StartDestroyEvent();
        item->SetOwnership(ch);

        return 0;
    }

 

 

 

 

Kind Regards,

Frozen

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • 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.