Jump to content

Quest - when player receive item from chat


Recommended Posts

  • Contributor

So you want something like this?

when x.use begin
    local rnd = math.random(1,100)
    if rnd >= 75 then
        pc.give_item2(189, 1)
        notice_all(pc.get_name().." got a fancy sword!")
    elseif rnd >= 50 then
        pc.give_item2(149, 1)
        notice_all(pc.get_name().." got a semi-fancy sword!")
    else
        pc.give_item2(19, 1)
        notice_all(pc.get_name().." got a not so fancy sword!")
    end
    pc.remove_item("x", 1)
end

You have to set the chest to ITEM_QUEST in item_proto and set all the drop in the quest. 

If you don't want to use quest for the chest drop then the notice_all is not possible using just a quest, you have to do it in the game file's source in c++.

Edited by TMP4
  • Love 1
Link to comment
Share on other sites

On 3/26/2021 at 9:42 AM, TMP4 said:

So you want something like this?


when x.use begin
    local rnd = math.random(1,100)
    if rnd >= 75 then
        pc.give_item2(189, 1)
        notice_all(pc.get_name().." got a fancy sword!")
    elseif rnd >= 50 then
        pc.give_item2(149, 1)
        notice_all(pc.get_name().." got a semi-fancy sword!")
    else
        pc.give_item2(19, 1)
        notice_all(pc.get_name().." got a not so fancy sword!")
    end
    pc.remove_item("x", 1)
end

You have to set the chest to ITEM_QUEST in item_proto and set all the drop in the quest. 

If you don't want to use quest for the chest drop then the notice_all is not possible using just a quest, you have to do it in the game file's source in c++.

Thanks for your reply.
Okay, since I don't want to do the drop via quest, I'll have to do it via source.
Can someone help me with an example how to do it please?

Link to comment
Share on other sites

  • Honorable Member

Find:

					if (item_get)
					{
						bSuccess = true;
					}

Change:

					if (item_get)
					{
						bSuccess = true;
						const TItemTable* Chest = ITEM_MANAGER::instance().GetTable(dwGroupNum);
						if (Chest) {
							char szBuf[128];
							snprintf(szBuf, sizeof(szBuf), "%s receive %s from %s", GetName(), item_get->GetName(), Chest->szLocaleName);
							BroadcastNotice(szBuf);
						}
					}

char_item.cpp

  • Love 1

 

Link to comment
Share on other sites

2 hours ago, Mali61 said:

Find:


					if (item_get)
					{
						bSuccess = true;
					}

Change:


					if (item_get)
					{
						bSuccess = true;
						const TItemTable* Chest = ITEM_MANAGER::instance().GetTable(dwGroupNum);
						if (Chest) {
							char szBuf[128];
							snprintf(szBuf, sizeof(szBuf), "%s receive %s from %s", GetName(), item_get->GetName(), Chest->szLocaleName);
							BroadcastNotice(szBuf);
						}
					}

char_item.cpp

Thank you!
How can I do it only if one or two special item are received out of the box?

Link to comment
Share on other sites

  • Premium
1 hour ago, Jordan said:

Thank you!
How can I do it only if one or two special item are received out of the box?

make some vectors of chests and items, then check it via item->GetVnum() and broadcast the notice if the item is one of the items of the chest you want to be noticed about when found.

Edited by Syreldar
  • Love 1

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

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.