EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Quests::Q&A (https://www.eqemulator.org/forums/forumdisplay.php?f=599)
-   -   Altering Temp item (https://www.eqemulator.org/forums/showthread.php?t=41221)

ChaosSlayerZ 03-18-2017 11:52 PM

Altering Temp item
 
Greetings.

I know that temporary items get some sort of timestamp to track when they needed to be removed from a character if he logs off for more than 30 min I believe.

Would it be possible to retrieve this timestamp via quest and remove the item of a player while he still logged in?

I want to set up a quest where player only has like 30 min to turn in the item before it goes poof.

Another question - would it heavily tax the server if a quest script would go off every 30 min to go through all the stored characters in DB searching for item X and removing it?

Thanks!

GRUMPY 03-18-2017 11:57 PM

Quote:

Originally Posted by ChaosSlayerZ (Post 253543)
player only has like 30 min to turn in the item before it goes poof.

Wow, that sounds like a kewl challenge. Especially if that item was a pita to get it to drop, haha

ghanja 03-19-2017 01:32 PM

Sounds like the hot potato quest I once did, which, I cannot find now. So, this is all untested, but, along the lines of what I did (really wish I could find it, as many little neat quests were in that directory). Haven't tested any of the following for shit. If I come across that directory, then I'll share that quest, but in the meantime:

Code:

## /quests/global/global_player.pl may NOT work I would suggest placing this in each zone's /quests/<zonesn>/player.pl
sub EVENT_TIMER {
        if ($timer eq "tempcheck$charid")
        {
                foreach (0..30,251..340,2000..2015,2030..2190,2500,2501,2531..2550)
                {
                        if ($client->GetItemAt($_) and plugin::NoRentItem($client->GetItemIDAt($_)))
                        {
                                $slot_item_id = $client->GetItemIDAt($_);
                                if (!defined $qglobals{"looted$slot_item_id"})
                                {
                                        $client->Message(15, "Your ".$client->GetItemAt($_)->GetName()." has poofed!");
                                        $client->NukeItem($client->GetItemIDAt($_));
                                }
                        }
                }
        }
}





## /quests/global/global_player.pl
## ensure item you make as the "hot potato" (any and all) are LORE!
sub EVENT_LOOT {
        if (plugin::NoRentItem($looted_id))
        {
                if (!$client->GetGlobal("looted$looted_id"))
                {
                        $client->SetGlobal("looted$looted_id", 1, 5, "M30");
                        quest::settimer("tempcheck$charid", 30);
                }
        }
}





## /plugins/NoRentItem.pl
sub NoRentItem {
        my $ic = $_[0];
        my $dbh = plugin::MySQL_Connect();
        my $sth = $dbh->prepare("SELECT `norent` FROM `items` WHERE ID = ".$ic." LIMIT 1");
        $sth->execute();       
        @data = $sth->fetchrow_array();
        $sth->finish();
        $dbh->disconnect();
        if ($data[0] == 0) { return 1; }
        else { return 0; }
}

return 1;

global_player.pl is screwy in its behavior (not to say it doesn't work "correctly" it's just finicky) so I'd heed the suggestion within the code.

ChaosSlayerZ 03-19-2017 02:55 PM

Thank you so much!
I will study this and put into good use ;)

ghanja 03-19-2017 03:04 PM

Well. Don't thank me just yet. Decided to give this a whirl and perhaps I'm missing something simple but:

Code:

$client->GetItemIDAt($_)
Returns -1 for each slot. In fact, it returns -1 if any variable is used with it. Which, strikes me as odd. Maybe something is screwy with my test end.

Uleat 03-19-2017 03:10 PM

That's probably the best way to handle it for now.

We only use client logout time to determine when no rent items should be deleted.


There may be ways to use item timers (custom data) to do this..but, I've never seen it.

At some point, I'll be adding something called `ItemInstance::origin_tag` - which is a base64 encoded 16-byte text field. (Later clients can use this for hotkey assignments)

I don't know what live puts into this field..but, one of the things I'm looking at using is a creation timestamp.

ghanja 03-19-2017 07:12 PM

Ok. It should work. Oddly enough, GetItemIDAt was not working, it would return a -1 for every iteration of a loop when a variable was passed to it. Hardcoding GetItemIDAt(2) or any other valid slot number would work though. That is on a GM toon that had:

Been created days (and many restarts ago) -> world.exe flag <accountname> 255 -> #gm on -> #zone cshome -> "bought" GM items (and did a few days/months worth of melee killing, #cast killing, many many #zone's, etc.)

However. Immediately following a #summonitem 50100 and equipping it (forcing a save I'm sure, though dont see how that matters, the toon has existed for quite some time), the GetItemIDAt when using a variable would work.

Strange, real strange.

Maze_EQ 03-20-2017 10:04 AM

Ghanja, would you like me to post your hot potato/coffee quest?

I have it from Sanctuary backups.

ghanja 03-20-2017 12:58 PM

Quote:

Originally Posted by Maze_EQ (Post 253581)
Ghanja, would you like me to post your hot potato/coffee quest?

I have it from Sanctuary backups.

That was code that Secrets did (I believe it was him), it was for a specific item (or two?). But, if you do post any code from there that I did, know, variable declarations from hell (with meaningful names) as I was trying to make it all so he could understand what the lines of code did. Not the most "optimized" work, but.. yeah. Your call.


All times are GMT -4. The time now is 05:44 PM.

Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.