Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Q&A

Quests::Q&A This is the quest support section

Reply
 
Thread Tools Display Modes
  #1  
Old 09-16-2011, 10:35 PM
revloc02c's Avatar
revloc02c
Hill Giant
 
Join Date: Aug 2010
Location: UT
Posts: 215
Default Check if itemid exists, with Perl

I made a quest where characters can create items that is similar to what Sonikboom did here. Items cannot be redeemed until the server resets which he says he does every night. His script then checks to see if a day has passed before he redeems the new item.

Is there a way in Perl to check to see if an item exists? If it does summon it, and if not tell the character they'll have to wait until server resets.
Reply With Quote
  #2  
Old 09-17-2011, 01:00 AM
Tabasco's Avatar
Tabasco
Discordant
 
Join Date: Sep 2009
Posts: 269
Default

I don't see any existing function that will do what you want.
With DBI installed you could query the tiems table, but that doesn't guarantee that the item actually exists in the shared memory block.

You could try this though:

questmgr.h (somewhere under public
Code:
bool IsValidItem(int32 itemid);
questmgr.cpp
Code:
bool QuestManager::IsValidItem(int32 itemid)
{
    return(database.GetItem(itemid));
}
perlparser.cpp
Code:
XS(XS__IsValidItem);
XS(XS__IsValidItem)
{
    dXSARGS;
    if (items != 1)
        Perl_croak(aTHX_ "Usage: IsValidItem(itemid)");

    int32       itemid = (int32)SvUV(ST(0));
    bool        RETVAL;
    dXSTARG;


    RETVAL = quest_manager.IsValidItem(itemid);
    XSprePUSH; PUSHu((IV)RETVAL);

    XSRETURN(1);
}
Then add to the boot_quest function in perlparser.cpp
Code:
newXS(strcpy(buf, "IsValidItem"), XS__IsValidItem, file);
I can test it fully in the morning, but for now I can at least tell you that it compiles.
Reply With Quote
  #3  
Old 09-17-2011, 02:20 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

I think something like this may work for you. You can look to see if the variable below is 0 or if it is not equal to the item ID you are feeding the command.

Code:
my $ItemID = 1001; # Set item id to verify here
my $VerifiedID = $client->GetItemStat($ItemID, "id");
if (!$VerifiedID)
{
quest::say("This item does not yet exist.");
}
else
{
quest::say("This item exists.");
}
Haven't actually tested this, but I think it will work.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #4  
Old 09-17-2011, 10:58 AM
revloc02c's Avatar
revloc02c
Hill Giant
 
Join Date: Aug 2010
Location: UT
Posts: 215
Default

Perfect Trev, it works.

That's just the kind of trick I was trying to find. Thank you.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 04:46 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3