PDA

View Full Version : Alternate Currency - Granted Hourly


utbbop
01-10-2015, 02:17 AM
Hello All,
Disclaimer: I am just getting set up with a server and am very new to this!

I wanted to know if anyone could help me get some framework going for granting players an Alternate Currency at a defined time interval of being online. I am thinking this would be something that gets added to a global quest file rather than a zone specific quest file?

Any thoughts or help would be appreciated. I can edit this heck out of some code to make it do what I want normally but I struggle with anything new and without framework. Any assistance would be huge...

Thanks guys!

Kingly_Krab
01-10-2015, 06:21 AM
You can achieve this like this. sub EVENT_CONNECT {
quest::settimer("Crystals", 3600);
}

sub EVENT_TIMER {
if ($timer eq "Crystals") {
quest::stoptimer("Crystals");
my $radiant = quest::ChooseRandom(1..5);
my $ebon = quest::ChooseRandom(1..5);
$client->AddCrystals($radiant, $ebon);
$client->Message(315, "You have recieved $radiant Radiant Crystals and $ebon Ebon Crystals. You now have " . plugin::commify($client->GetRadiantCrystals()) . " Radiant Crystals and " . plugin::commify($client->GetEbonCrystals()) . " Ebon Crystals.");
quest::settimer("Crystals", 3600);
}
}

Urkel
01-10-2015, 02:22 PM
cant wait to afk on your server and become the best!

utbbop
01-12-2015, 12:33 PM
You can achieve this like this. sub EVENT_CONNECT {
quest::settimer("Crystals", 3600);
}

sub EVENT_TIMER {
if ($timer eq "Crystals") {
quest::stoptimer("Crystals");
my $radiant = quest::ChooseRandom(1..5);
my $ebon = quest::ChooseRandom(1..5);
$client->AddCrystals($radiant, $ebon);
$client->Message(315, "You have recieved $radiant Radiant Crystals and $ebon Ebon Crystals. You now have " . plugin::commify($client->GetRadiantCrystals()) . " Radiant Crystals and " . plugin::commify($client->GetEbonCrystals()) . " Ebon Crystals.");
quest::settimer("Crystals", 3600);
}
}

Thanks a ton!
Going to play with this a bit and will let you know if I have any questions!

utbbop
01-12-2015, 12:34 PM
cant wait to afk on your server and become the best!

lol. Well thats the plan.
Welcome to IdleQuest.

utbbop
01-12-2015, 01:00 PM
You can achieve this like this. sub EVENT_CONNECT {
quest::settimer("Crystals", 3600);
}

sub EVENT_TIMER {
if ($timer eq "Crystals") {
quest::stoptimer("Crystals");
my $radiant = quest::ChooseRandom(1..5);
my $ebon = quest::ChooseRandom(1..5);
$client->AddCrystals($radiant, $ebon);
$client->Message(315, "You have recieved $radiant Radiant Crystals and $ebon Ebon Crystals. You now have " . plugin::commify($client->GetRadiantCrystals()) . " Radiant Crystals and " . plugin::commify($client->GetEbonCrystals()) . " Ebon Crystals.");
quest::settimer("Crystals", 3600);
}
}

Having some trouble getting this to work. Might be because Ebon and Radiant crystals arent showing up in-game/in my client. They show as Unknown DB Strings.

Any feedback as to why? Is it my client (UF)?

I have added a new currency called Planar Crystals of which I will use instead of Radiant and Ebon Crystals, but this is not showing up in-game at all in the Alt Currency Inventory window...

utbbop
01-12-2015, 03:26 PM
Having some trouble getting this to work. Might be because Ebon and Radiant crystals arent showing up in-game/in my client. They show as Unknown DB Strings.

Any feedback as to why? Is it my client (UF)?

I have added a new currency called Planar Crystals of which I will use instead of Radiant and Ebon Crystals, but this is not showing up in-game at all in the Alt Currency Inventory window...

Found some threads on dbstr.txt and was able to fix my unknown strings. Still cant get this to work.

I added this code to global_player.pl and I reduced the timer from 3600 to 10, for testing purposes, and nothing is happening.

Can you confirm that plugin::commify($client->GetRadiantCrystals()) is correct? Specifically the "commify". Havent seen that before and cant find it listed here: http://wiki.eqemulator.org/p?Ultimate_Perl_Reference&frm=Main

Thanks for the help..

rencro
01-12-2015, 03:45 PM
Can you confirm that plugin::commify($client->GetRadiantCrystals()) is correct? Specifically the "commify". Havent seen that before and cant find it listed here: http://wiki.eqemulator.org/p?Ultimat...rence&frm=Main


It is "explained" here:
http://wiki.eqemulator.org/p?Perl_Plugins_Master_Reference&frm=Main

Here are the helpful comments on it: If you need an example for this, you need help

Good luck..

trevius
01-12-2015, 04:13 PM
Ebon/Radiant crystals are not the same as alternate currency. The clients that have them (I think SoF+) all treat them separately from alternate currency. If you try to add Ebon/Radiant crystals as an alternate currency, they will show up as unknown-dbstr unless you edit client files. Instead of having Ebon/Radiant Crystals in the Alt Currency tab of your inventory, they should have their own little boxes similar to plat/gold/silver/copper in your main inventory window.

The crystals are loaded from the player profile, which differs from alt currency that loads from a specific packet for that. And, crystals have their own update packets for changing the amount displayed in the inventory window. They also use different vendor classes that are specific for Ebon or Radiant crystals, where Alt Currency vendors can be set to use 1 of any of the 19ish different standard alt currencies.

utbbop
01-12-2015, 04:20 PM
Can you confirm that plugin::commify($client->GetRadiantCrystals()) is correct? Specifically the "commify". Havent seen that before and cant find it listed here: http://wiki.eqemulator.org/p?Ultimat...rence&frm=Main


It is "explained" here:
http://wiki.eqemulator.org/p?Perl_Plugins_Master_Reference&frm=Main

Here are the helpful comments on it: If you need an example for this, you need help

Good luck..

Ok, understood.
Still cant get it working though.

Tested some different code to make sure my currency and everything was working and it is. This appears to be an issue with the code in general or where I am putting it. I even tried switching from EVENT_CONNECT to EVENT_ZONE and it wont work.

Hmmmmm, going to keep trying...

utbbop
01-12-2015, 04:21 PM
Also, I switched from $client->AddCrystals to $client->AddAlternateCurrencyValue and cant get it to work with the timer...

sub EVENT_CONNECT {
quest::settimer("Pearls", 10);
}

sub EVENT_TIMER {
if ($timer eq "Pearls")
{
quest::stoptimer("Pearls");
$client->AddAlternateCurrencyValue(15, 1)
$client->Message(315, "You have recieved 1 Planar Pearl. You now have ". plugin::commify($client->GetAlternateCurrencyValue(15))."" );
quest::settimer("Pearls", 10);
}
}

utbbop
01-12-2015, 07:48 PM
Also, I switched from $client->AddCrystals to $client->AddAlternateCurrencyValue and cant get it to work with the timer...

sub EVENT_CONNECT {
quest::settimer("Pearls", 10);
}

sub EVENT_TIMER {
if ($timer eq "Pearls")
{
quest::stoptimer("Pearls");
$client->AddAlternateCurrencyValue(15, 1)
$client->Message(315, "You have recieved 1 Planar Pearl. You now have ". plugin::commify($client->GetAlternateCurrencyValue(15))."" );
quest::settimer("Pearls", 10);
}
}

I have compared this to my other quests that use a timer and it seems formatted correctly. Not sure why I cant get it working. Is it something related to global_player.pl? Or perhaps something related to my EVENT?

Thanks all!

trevius
01-13-2015, 01:06 PM
Well, you are missing the ; at the end of this line:

$client->AddAlternateCurrencyValue(15, 1)

You can run "perl -c global_player.pl" from command line and it will tell you of any syntax errors you have so you can fix them.

Also, for general troubleshooting purposes, I always simplify my script down as much as possible to verify things are working as expected. My suggestion would be to remove/comment out all of that except for a shout/debug message like this:

sub EVENT_CONNECT {
quest::settimer("Pearls", 10);
}

sub EVENT_TIMER {
if ($timer eq "Pearls")
{
quest::shout("IT WORKS!");
}
}

With that, you should see the IT WORKS! shout every 10 seconds. If you aren't seeing that, then either EVENT_CONNECT isn't working properly, or you don't have your global_player.pl in the templates folder.

Once you get that working, you can add your other stuff line by line and test as you go. Once it stops working, you will know where the issue is and just need to figure out why. One example might be that you could have a bad function name.

Most likely in this case, your problem is probably due to you trying to use the $client variable inside EVENT_TIMER which does not export that variable and cannot support it properly.

Alternatively, you could set an entity variable on the client and then loop through the client list and check each for the entity variable you set, and apply your currency that way. It is a bit more complex to do this properly, but it is probably the best way.

You could probably set the entity variables to a unix timestamp using time(). Then, in the timer you would check if the current timestamp is 1 hour later than what the client's entity variable is.