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 06-21-2014, 03:04 AM
Esildor
Hill Giant
 
Join Date: Feb 2010
Posts: 207
Default Time remaining on a qglobal

Is there a way to have a qglobal's remaining time read and displayed to players?
Reply With Quote
  #2  
Old 06-21-2014, 08:09 PM
Mariomario
Hill Giant
 
Join Date: Jul 2004
Posts: 143
Default

There are a couple plugins that read and convert Unix timestamps. They are contained in the time_tools.pl
Code:
###Usage: my $TimeLeft = plugin::GetTimeLeft(UnixTime, ReturnType=0);
# Example: GetTimeLeft(1285623342);	# Check current time against a Unix Timestamp and return secs/mins/hours/days/years remaining
# Example: GetTimeLeft(1285623342, "H");	# Check current time against a Unix Timestamp and return hours remaining
# Returns 0 if no time is left
# ReturnType is one of the following: S seconds, M minutes, H hours, D days, Y years
Code:
###Usage: my $EndTime = plugin::GetEndTime("TypeDur", localtime=false);
# Example: GetEndTime("M60");	# Add 60 minutes to the current timestamp and return in unix time
# Example: GetEndTime("H5", 1);	# Add 5 hours to the current timestamp and return in readable local time
# TypeDur is set just like as it is for QGlobals
# S | seconds | "S15" = 15 seconds |
# M | minutes | "M30" = 30 minutes |
# H | hours   | "H12" = 12 hours   |
# D | days    | "D90" = 90 days    |
# Y | years   | "Y5" = 5 years     |
# localtime is an optional field
# If set to 1, it will return a readable date/time stamp, otherwise 0 (default) is unix time
You will need to combine these plugins with the DBI module to pull the Unix timestamp from the database.

Here is a sample of how I have it currently used on my server.
Code:
my $myInstance = $dbh->prepare("SELECT * FROM quest_globals WHERE charid = $charID and name like 'Skylance';");
$myInstance->execute();
my @thisInstance = $myInstance->fetchrow_array();
					
my $hours = plugin::GetTimeLeft($thisInstance[6],"H");
my $minutes = plugin::GetTimeLeft($thisInstance[6],"M");
my $seconds = plugin::GetTimeLeft($thisInstance[6],"S");
					
my $minLeft = $minutes % 60;
my $secLeft = $seconds % 60;
					
$instance = ("You are currently bound to this instance for $hours hour(s) $minLeft minutes $secLeft seconds.");
__________________
Wrath - Lead Admin and Owner of Enlightened Dark: Ascension

Enlightened Dark: Ascension
Reply With Quote
  #3  
Old 06-22-2014, 10:54 AM
Kingly_Krab
Administrator
 
Join Date: May 2013
Location: United States
Posts: 1,594
Default

Once this pull request gets committed, this will be possible without Perl DBI. There is a plugin, as mentioned, called plugin::GetTimeLeft(), I have re-written this plugin along with NatedogEZ to return time from Years downwards (includes months and weeks). The syntax for $client->GetGlobalTime() is $client->GetGlobalTime("qglobal_name", character_id, npc_id, zone_id); NatedogEZ and I did not default character_id, npc_id, and zone_id to 0, so you must specify 0 if you don't want it to search for specific NPCs or zones. Along with this commit comes $client->GetGlobal() which has the exact same syntax, $client->GetGlobal("qglobal_name", character_id, npc_id, zone_id); This will return the value of a quest global based on NPC or Client, as it is for mobs. This will allow you to do such things as check your target's quest global using $client->GetTarget()->GetGlobal(); if you meet the correct conditions. I apologize for rambling.

Here's the plugin, to use it do the following: $client->Message(Color #, plugin::GlobalTime($client->GetGlobalTime("qglobal_name", character_id, npc_id, zone_id)));
Code:
sub GlobalTime {
    my $time = $_[0];
    my $currentTime = time;
    my $difference = ($time - $currentTime);
    my ($years, $months, $weeks, $days, $hours, $minutes, $seconds) = 0;
 
    if ($difference <= 0) {
        return 0;
    }
    
    if ($difference > 31556926) {
        $years = int($difference / 31556926);
    }
    if ($difference > 2628000) {
        $months = int($difference / 2628000) % 12;
    }
    if ($difference > 604800) {
        $weeks = int($difference / 604800) % 4;
    }
    if ($difference > 86400) {
        $days = int($difference / 86400) % 7;
    }
    if ($difference > 3600) {
        $hours = int($difference / 3600) % 24;
    }
    if ($difference > 60) {
        $minutes = int($difference / 60) % 60;
    }
    $seconds = ($difference % 60);
    $ys = $years != 1 ? "Years":"Year";
    $mos = $months != 1 ? "Months":"Month";
    $ws = $weeks != 1 ? "Weeks":"Week";
    $ds = $days != 1 ? "Days":"Day";
    $hs = $hours != 1 ? "Hours":"Hour";
    $ms = $minutes != 1 ? "Minutes":"Minute";
    $ss = $seconds != 1 ? "Seconds":"Second";
    
    return "You have $years $ys, $months $mos, $weeks $ws, $days $ds, $hours $hs, $minutes $ms, and $seconds $ss remaining";
}
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 12:33 PM.


 

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 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3