View Single Post
  #2  
Old 08-15-2017, 10:59 PM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default

Several ways, varying in complexity and/or "work".

1. Likely the easiest unless you want to go at the source to add a new export, is:
Code:
sub EVENT_ENTERZONE {
    my @noncombatzones = ("freeportn", "runnyeye", "nexus");
    if ($zonesn ~~ @noncombatzones) {
          ## do nothing
    } else {
          ## do something
    }
}
Or some variance of the above. I chose non-combat zones in case there are fewer of them than combat zones.

2. Read from the DB using DBI (though this would of course create a potential for many calls to the DB):

Code:
sub readcombat {
    my $read_zone = $_[0];
    $connect = plugin::MySQL_Connect();
    $query = "
        SELECT `cancombat`
        FROM zone
        WHERE `short_name` = ? LIMIT 1
    ";
    $qh = $connect->prepare($query);
    $qh->execute($read_zone);
    while (@row = $qh->fetchrow_array()){
        return $row[0];
    }
    return;
}

return 1;
Tossing the above in either an existing plugin file or creating its own. Using it:

Code:
sub EVENT_ENTERZONE {
    if (plugin::readcombat($zonesn)) {
       ## do this when combat is 1 (aka true)
    } else {
       ## do this when combat is 0 (aka false)
    }
}
3. Edit the source to add an LUA/Perl export and, I've been away again too long from C++ to do this on the spot and I wasn't nearly as proficient at it as some others (Akka, Kingly, demon, hell any of the dev team)

So there's a start I hope.
Reply With Quote