ghanja
04-29-2015, 10:42 PM
If a PC/client is sitting and hasn't moved x,y,z coordinates (some damper to the z coordinate to account for those that would like to go around levitating people), they will earn credits.
Not a fan of this system, but different strokes for different folks and is simplistic enough that perhaps some can learn from it in some small way.
$AFKINCREMENTSNEEDED = 180;
sub EVENT_TIMER {
if ($timer eq "activitycheck$charid") {
my $cxcord = int($client->GetX());
my $cycord = int($client->GetY());
my $czcord = int($client->GetZ());
my $oxcord = plugin::REV($client, "oxcord");
my $oycord = plugin::REV($client, "oycord");
my $ozcord = plugin::REV($client, "ozcord");
my $afkcounter = plugin::REV($client, "afkcounter");
if (($client->IsSitting())
&& ($oxcord ~~ [$cxcord-5..$cxcord+5])
&& ($oycord ~~ [$cycord-5..$cycord+5])
&& ($ozcord ~~ [$czcord-20..$czcord+20])) {
++$afkcounter;
plugin::SEV($client, "afkcounter", $afkcounter);
if ($afkcounter == $AFKINCREMENTSNEEDED) {
$afkcounter = 0;
plugin::SEV($client, "afkcounter", $afkcounter);
$client->AddAlternateCurrencyValue(x, x);
$client->Message (15, "You've earned an AFK Server Loyalty Credit!");
}
} else {
$afkcounter = 0;
plugin::SEV($client, "afkcounter", $afkcounter);
}
plugin::SEV($client, "oxcord", $cxcord);
plugin::SEV($client, "oycord", $cycord);
plugin::SEV($client, "ozcord", $czcord);
}
}
sub EVENT_ENTERZONE {
quest::settimer ("activitycheck$charid",10); ## activity check increment
}
sub EVENT_ZONE {
quest::stoptimer ("activitycheck$charid");
}
sub EVENT_DISCONNECT {
quest::stoptimer ("activitycheck$charid");
}
Put in the player.pl for a specific zone (or that is how its coded).
Not a fan of this system, but different strokes for different folks and is simplistic enough that perhaps some can learn from it in some small way.
$AFKINCREMENTSNEEDED = 180;
sub EVENT_TIMER {
if ($timer eq "activitycheck$charid") {
my $cxcord = int($client->GetX());
my $cycord = int($client->GetY());
my $czcord = int($client->GetZ());
my $oxcord = plugin::REV($client, "oxcord");
my $oycord = plugin::REV($client, "oycord");
my $ozcord = plugin::REV($client, "ozcord");
my $afkcounter = plugin::REV($client, "afkcounter");
if (($client->IsSitting())
&& ($oxcord ~~ [$cxcord-5..$cxcord+5])
&& ($oycord ~~ [$cycord-5..$cycord+5])
&& ($ozcord ~~ [$czcord-20..$czcord+20])) {
++$afkcounter;
plugin::SEV($client, "afkcounter", $afkcounter);
if ($afkcounter == $AFKINCREMENTSNEEDED) {
$afkcounter = 0;
plugin::SEV($client, "afkcounter", $afkcounter);
$client->AddAlternateCurrencyValue(x, x);
$client->Message (15, "You've earned an AFK Server Loyalty Credit!");
}
} else {
$afkcounter = 0;
plugin::SEV($client, "afkcounter", $afkcounter);
}
plugin::SEV($client, "oxcord", $cxcord);
plugin::SEV($client, "oycord", $cycord);
plugin::SEV($client, "ozcord", $czcord);
}
}
sub EVENT_ENTERZONE {
quest::settimer ("activitycheck$charid",10); ## activity check increment
}
sub EVENT_ZONE {
quest::stoptimer ("activitycheck$charid");
}
sub EVENT_DISCONNECT {
quest::stoptimer ("activitycheck$charid");
}
Put in the player.pl for a specific zone (or that is how its coded).