This assumes you have DBI Perl installed (instructions are in the Wiki). And, it's by far untested (even for syntax, sorry away from my home PC for the holidays):
Code:
## global_player.pl
sub EVENT_TIMER {
if ($timer eq "RecordCharacter") {
RecordCharacterMemmedSpells($charid);
}
}
sub EVENT_SAY {
if ($text=~/#loadspells/i) {
if (defined $qglobals{"memmedspells"}) {
LoadMemmedSpells();
} else {
$client->Message(15, "You have no spell slots in custom memory!");
}
}
}
sub EVENT_CONNECT {
LoadMemmedSpells() if (defined $qglobals{"memmedspells"});
quest::settimer("RecordCharacter", 10);
}
sub LoadMemmedSpells {
$client->UnmemSpellAll(1); ## just a sanity thing
foreach my $i (0..9) { ## forget current maximum spell slots
if (defined $qglobals{"memmedspellslot$i"}) {
$client->MemSpell($qglobals{"memmedspellslot$i"}, $i, 1);
}
}
}
sub RecordCharacterMemmedSpells {
my $dbh = plugin::MySQL_Connect();
my $sth = $dbh->prepare("
SELECT slot_id, spell_id
FROM character_memmed_spells
WHERE id = ?
");
$sth->bind_param(1,$_[0]);
$sth->execute();
if ($sth->rows() > 0) {
quest::setglobal("memmedspells", 1, 5, "F");
while (my @row = $sth->fetchrow_array()) {
quest::setglobal("memmedspellslot$row[0]", $row[1], 5, "F");
}
}
$sth->finish();
$dbh->disconnect();
}
(shrug) hopefully someone comes in and gives it a look over, second+ set of eyes never hurt.
*Edit: The code above is sort of moot now after having been enlightened by Kingly's post. But will leave it for those that like Perl.