Jump to content

Recommended Posts

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?

Link to comment
https://wrobot.eu/forums/topic/5032-useitem-script-on-specific-npc-only/
Share on other sites

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.

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

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...