Skip to content
View in the app

A better way to browse. Learn more.

WRobot

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Useitem script on specific npc only

Featured Replies

So i have a quest where i need to useitem on npc to spawn some small npcs that i have to kill for quest objective to complete. I use this code:

Thread t = new Thread(() =>
{
    uint itemId = 24501;
    int questId = 9849;
    while (robotManager.Products.Products.IsStarted)
    {
        if (Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause)
        {
            if (!Quest.HasQuest(questId))
                break;
            if (ObjectManager.Target.IsValid && ObjectManager.Target.IsAlive)
            {
                ItemsManager.UseItem(itemId);
            }
        }
        Thread.Sleep(500);
    }
});
t.Start();

But before he turns this quest, he has to do 3 more other quests nearby, and he keeps casting this item on other mobs from those 2 other quests, even tho this quest is already completed. Is it possible to add break if quest is completed but not turned yet? Or add only specific npcid to use this itemid on only?

yeah... if you look at the code:

            if (!Quest.HasQuest(questId))
                break;
            if (ObjectManager.Target.IsValid && ObjectManager.Target.IsAlive)
            {
                ItemsManager.UseItem(itemId);

That means between the time that code is run, and you hand in the quest... it will attempt to use the item.  This looks suspect.

In this scenario all you can really do is do your other 2 quests first, then run the code and to the 'item quest' and hand in.  Alternatively, run code, pulse quest, hand in, pulse other 2 quests hand in.

 

in the end if your running that kind of code, you want to pulse the quest then turn in asap.

  • Author

So i can do it like this?

Thread t = new Thread(() =>
{
    uint itemId = 24501;
    int questId = 9849;
    while (robotManager.Products.Products.IsStarted)
    {
        if (Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause)
        {
            if (!Quest.HasQuest(questId))
                break;
            if (ObjectManager.Target.IsValid && ObjectManager.Target.IsAlive && ObjectManager.Target.Entry == 17157)
            {
                ItemsManager.UseItem(itemId);
            }
        }
        Thread.Sleep(500);
    }
});
t.Start();

Seems to work, thanks!

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.