View Full Version : Setglobal Question:
So_1337
06-25-2008, 09:57 AM
Very quick question, which I believe should have an easy answer if it's possible.
sub EVENT_DEATH {
quest::setglobal(aten,1,3,"H108");
}
If I instead wanted that variable above to last forever, I would change "H108" to "F". That's easy. What if I wanted to have it write a timestamp to the database for when the event actually occurred? I guess the first question is, is there a perl value that accomplishes that? Substitute $timestamp or an equivalent? And the second is, since I wouldn't want to put that in the expiration field, is the value field big enough to hold it?
Just looking for an idea on how this might be done. Appreciate any suggestions.
trevius
06-25-2008, 07:53 PM
Anytime I want to keep track of an event, I simply use the following:
quest::write("bossdeaths.txt","$mname was killed by $name the $class.");
I think that would be the best way to do what you want, but there is only 1 problem which I too would like resolved; there isn't a way to do a timestamp in this command as far as I can tell. If you could use this command and have it do a timestamp with a $timestamp identifer, that would be awesome. I wonder how hard it would be to get that identifier added into the source. Unfortunately I am not a coder yet, or I would do it myself lol.
So_1337
06-26-2008, 07:41 AM
Wow, I had no idea there was such a quest::command! I must've skipped over it in the list. That's near enough to what I need, actually. If I need a timestamp, I can check the time the file was last modified after it's been written to. Thanks a ton! =)
AndMetal
06-27-2008, 03:47 PM
there isn't a way to do a timestamp in this command as far as I can tell. If you could use this command and have it do a timestamp with a $timestamp identifer, that would be awesome.
This is actually a lot easier than it seems.
Since we are using Perl, we have the benefits of all that Perl offers, including time (http://perldoc.perl.org/functions/time.html) & localtime (http://perldoc.perl.org/functions/localtime.html).
If you wanted to define a variable $timestamp to have the current time, you could add this to your quest:
$timestamp = localtime(time);
Simple as that. Then, you could add it to your output file:
quest::write("bossdeaths.txt","[$timestamp]: $mname was killed by $name the $class.");
trevius
06-27-2008, 11:02 PM
Sweet! That worked perfectly!
Here is a test quest:
#test quest
sub EVENT_SAY {
$timestamp = localtime(time);
if ($text =~/Hail/i) {
quest::say ("Why, hello there $name! Pleasure meeting you here.");
quest::write("test.txt","[$timestamp]: $name, the $class, hailed $mname"); }
}
It put the following output into my test.txt file:
[Fri Jun 27 21:41:56 2008]: Trevazar, the Warrior, hailed Larren000
Now, if I could only get it to add guildname in somehow, since $uguildid doesn't seem to work. Not a big deal though. Getting that timestamp working was what I wanted the most. Thanks again AndMetal!
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.